From nobody Sun Feb 8 19:51:00 2026 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FDD725E809 for ; Tue, 11 Mar 2025 16:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741709318; cv=none; b=QVmVIRrTzOejz1RFQ11hEPrZk1G9ecovGn6qTEORCm/7D2bZPI9lsv6shovIO13HtUKj3YzJDscTcKXjwh3R92lwpKDcssnrYdxU+8X7beEibAKlnP7RRreQjeGUbLEPPrkb8Km7XhkdYaY0IglRUzqwGbPnmaYHN52s88zP7ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741709318; c=relaxed/simple; bh=l0PCUhBXASLDRPE0V1mUAP8XYiUY2TDG0y8AdPdT3hs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m5IaNQqD7tLVcW8V/1c+DuF9t9IKz4VyetBjCxZi63DIA3NVf8PEVxtmOSzCt0n6rrkK8xSA563EA9+ghTJpn5nQQpM7TKnBOKm5RQeRgpaZBaMXjkHcok1qjkndiTlRMGcdPzifvVjNN9nHhIpKRDz+BvtrsrcW3hW8YC8da0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=X/1gEMZP; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="X/1gEMZP" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-30bf7d0c15eso48582691fa.0 for ; Tue, 11 Mar 2025 09:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741709314; x=1742314114; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e5rCPhsAPbcHexhTKW956Un6CdUeaMwNbF4Qw3OxTxc=; b=X/1gEMZPy2gj3MDGVOg+pGqde63nzvwid6ousqgiHOZwKJ4eZ0XP6C/yd7QtepWuNt 2nlCT1Uo9os5q4za+MJKcS9/TKOp1P+ZIrpPmy0OtebrCFzyyFz7NdhaJHgU7Mlajz21 Lxs918+ovmtjBchlttZpCedBvAozplp8j8T9zmWQcrsn36WqS1IJky/C/PLv7kCRJtLQ /kzxGGp02bgLOEyeUH/o6DL6aY3LGL09WrLuZ+LtpHU9X1v8R+OYfywrf2ruWE0EtXls ZGoQS34nq4rlfs51L8IG4vFVGJUba/4KEU06NLfsEdWrcKu/3j6twsXkaWJbWm6TXyAk CaBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741709314; x=1742314114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e5rCPhsAPbcHexhTKW956Un6CdUeaMwNbF4Qw3OxTxc=; b=sZXKcOEaOsTT9tZ8tOLVCdXsL8I31DfFazlAkImH53YfBycHeXDJV1aBNfaDKih8Bo mLiqd/tB96AdB7aWduRTbtEc2VBter25qXKATIc7vBppLHI7dhi0s+GXWYQh98Jlfy2M fxhZS2awen1eeZ8n7gQqPYqAyX7Qvtf0uO24v8rNa5rLoQQIPe0hKVpSB/QGEBpEtjRv bwlOwI2C/lvkkymhcBUx7TLMtwa8mHe+N5NRxji2HaMZzjskJZ98RLpzJJQIJwamEX/L hqcpS5zXTU1Htyc7BSexW4Kj0vSiM62WgVIsLbFSCUcrwJoSi+CSOq4kU7w92kA0sdgv mx7w== X-Forwarded-Encrypted: i=1; AJvYcCVdb1ut4XFxe5JHQcwdO/F8Pwfst7G8C7rclorQ6lxwmENueZDAUUan4ZRiKBXWB6VKRYpD51UFXypi9Bk=@vger.kernel.org X-Gm-Message-State: AOJu0YzmMbbWDMApxyUAXii1PUybl8goffe3Q8sMhmkbbeFBcjoNSZFA 0r8e6OQB0ZHCqBRX5LJMSlpD9eD51USxBZDdC8X3L/G3z+S83KS07B44jBbnTHk= X-Gm-Gg: ASbGncs+hh0+0PDl4XQXCenSjg4LU7q6J6QyjTRrBw3Jk9tJHhTVBIRf+RTkBf9oUbD +ifOnsoH115Hu5ZZTTu1mqIndyNugMym7hUrIQlA3ddeuDaorTFlzYmmQuGLoh9BIINiqNTqhVQ C98/BttWArAxwYpaNAaYffx0QrTRe4pee16chhpMnw165j026K2TFzrxch04P5BNWiSjqxWRgYB BZV9DBta2HMvo/ir6dB1JEYBJQwDQesdxC5dy3Mo6/1N0J4u09v9yrJFCDZUCrv/zecwuBz7Yuz m0Uoiix7vreKlqEXSlahQVnCqAK1bOrw2gfLQoC8TDMEKj0S3IYErIcoPpSf2eBa+/4N1MzVfAa VTGcV5J/A7ONpzdCHQN4= X-Google-Smtp-Source: AGHT+IH6xH3iIw5WZ9UvcU1KhACB9sxLwodKE2eiTaozFPA2Kckvhc5eL9CtKwpWSsZqvDw73UKNyg== X-Received: by 2002:a2e:95ce:0:b0:30b:b9e4:13b0 with SMTP id 38308e7fff4ca-30bf4518301mr57630211fa.12.1741709313621; Tue, 11 Mar 2025 09:08:33 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30be9918c54sm20761671fa.62.2025.03.11.09.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 09:08:33 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] PM: s2idle: Drop redundant locks when entering s2idle Date: Tue, 11 Mar 2025 17:08:22 +0100 Message-ID: <20250311160827.1129643-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250311160827.1129643-1-ulf.hansson@linaro.org> References: <20250311160827.1129643-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The calls to cpus_read_lock|unlock() protects us from getting CPUS hotplugged, while entering suspend-to-idle. However, when s2idle_enter() is called we should be far beyond the point when CPUs may be hotplugged. Let's therefore simplify the code and drop the use of the lock. Signed-off-by: Ulf Hansson --- Changes in v2: - Added a comment in the code. --- kernel/power/suspend.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 09f8397bae15..90fb06ca07d2 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -91,6 +91,8 @@ static void s2idle_enter(void) { trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true); =20 + /* CPUs can't be hotplugged here so let's not protect for it. */ + raw_spin_lock_irq(&s2idle_lock); if (pm_wakeup_pending()) goto out; @@ -98,8 +100,6 @@ static void s2idle_enter(void) s2idle_state =3D S2IDLE_STATE_ENTER; raw_spin_unlock_irq(&s2idle_lock); =20 - cpus_read_lock(); - /* Push all the CPUs into the idle loop. */ wake_up_all_idle_cpus(); /* Make the current CPU wait so it can enter the idle loop too. */ @@ -112,8 +112,6 @@ static void s2idle_enter(void) */ wake_up_all_idle_cpus(); =20 - cpus_read_unlock(); - raw_spin_lock_irq(&s2idle_lock); =20 out: --=20 2.43.0 From nobody Sun Feb 8 19:51:00 2026 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6611B25FA14 for ; Tue, 11 Mar 2025 16:08:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741709319; cv=none; b=Wqg2sJRp6Trd7St6VhuSgBXDxBMmtGGYZW6nEiWf61aaIaSLIm50YkpWS0E2xjRjdW5oidA/6UE9aXRT5TdRE3Cv5a9RfLd/JDLdXH1lE63MicOsQvT7M9FmUL6RbuKlvNn+4ty9JhGGzP0Xo0YOHU+cnb3rF9BiY2pLSN55Kp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741709319; c=relaxed/simple; bh=0JyQVQNXAvmJ1/n8UxRyRWsOn+wf5nWtMrbcEr1qgqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YPzR1TzD+StDYv7nEOrIs4XQ2evtksu9mAEyfnE72VURYH2dDFSCdliYLLj0VqFUnnhKqsnpDeCQt/oy98MVsn9K16vmZla9aDPPyF0xC+lWiUPRtTL3nEnpuVDMnckknOUEaFgbgxbBgGGIZnfGxN+c3/6H+ice7WZQkOHbhzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hTbbffLr; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hTbbffLr" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-30613802a6bso61271141fa.1 for ; Tue, 11 Mar 2025 09:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741709315; x=1742314115; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kcjlvQ20Z+LP3Azhfy6nFMLexKDv2Y/3x8IawyIsoTw=; b=hTbbffLrkgs8aWE0ihiJgubeavcGhEQG6xM/foE2BNKjgqINpGUMGbOOqm8crtsKFU XVES0G8uZ99YcU3NYYD7YCN6XjCBLHb6qyBkR9wvQC3UcMp2m4jNrSoHaJm+hnbrbaRf WFmH2La8YZe+zMSQgaK7WHL52wS4lbLk2PwEf+Tww33CUtTm9Uy+4EG8nGN4MULxrdHh IpiE65qmMQIUJPcCLQMtbYuFTN5Oty5XUrdNFH31AnLfkQ6I/K1I7TMX6JSTWshiHqV7 7SeNq06JmQXDjQ7siQwXvd8DFt+4QxG6jgjaAFKNCNsGaw4DLRQCu9FllDvHO1Z0d8gj 86lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741709315; x=1742314115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kcjlvQ20Z+LP3Azhfy6nFMLexKDv2Y/3x8IawyIsoTw=; b=LTMSt5ofbTgOJmbngOcLKGqXfoSFMqPniJ3C41QQtBdtjatCnGeqB0HAKHXZEBQ6sd hxGz2bu1DWW9YQ7tK3HTMx+ziNe3Xhi6YTIio5ExoWhzMJmN935B4yZfryUOqTexbdsA HYCDUd+D90kkG29Q7UC3pX49LksSJYD1JocRwsS2Q6iDr76Tuc009YkZyw7CnwhogL8a C7ebjroadi1oIrfBuoc5uVCg0qmh/onGzeHko5eKtdf+08yOHpL2GRZfk0H9MrwsWzAb 4o8UXHu3Q4jn9E3/3WQfTs0Zyx9RrmCezQXmE20khJe8Z9UX8SEbrqUbvefM/ReWvg0g o2Hw== X-Forwarded-Encrypted: i=1; AJvYcCWoWlvKnPeQ7n98KBc3KLflfD1J0eIoH7brMfqXNofl7rJLQXqK3dfaN1HrlQUfboc/N7Uwf+X28wRme+A=@vger.kernel.org X-Gm-Message-State: AOJu0YwzqO3XDdCHjKUudIwsAEvu3Qiw2lZ5cvkj6NskbkG06nuiSM2K OgLKK/MuueIpLegjuv40burXuuIfJykMhm5eUG8P3TNoJlchcUUooW/ctHu1Tbs= X-Gm-Gg: ASbGncuSxXoG5lMM+e1rEKt3b5jJosknd8FHB+Xq4TVhluMkOzSc0oPsD1NTiv4Dy+2 W0i1BwvBFMT0fesZlf4Uessy7ussUQ9KS28CPIZg9kY8u4enBMeImgOPtYne2iFgPRqOSS2KCDr PDiE6g2/+/5yiGX5807ljm/iyfUc253gQhn7GoefXDlNt2E6zGp7GPnhtQftEQv1LkxifTaICRd QnJHgA58bxH2PNCOrdah7nnpQn8RABtFZMJz8pXANjxf7aA8tetAV2suYFwGoTI60mxjKAYaaWS NCE9ZvOfz88x7PFMQz58Xxxaq3+cChbUIYoXq1J1k/ARnZ6Ax0Ah/fYn+TzkdcCoQ1ZRBCZqiyn y4Ve8qDNdvUHHJe1Men0= X-Google-Smtp-Source: AGHT+IHqEinybzI7v0pVnETj2v5LwyPFnNPlZDH83XrlF6Z5frt4mvnADmS29mGe3LSIyUVtpKjvJA== X-Received: by 2002:a2e:a9a7:0:b0:30b:cef8:de87 with SMTP id 38308e7fff4ca-30bf44fa059mr66552361fa.4.1741709315430; Tue, 11 Mar 2025 09:08:35 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30be9918c54sm20761671fa.62.2025.03.11.09.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 09:08:34 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] PM: s2idle: Extend comment in s2idle_enter() Date: Tue, 11 Mar 2025 17:08:23 +0100 Message-ID: <20250311160827.1129643-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250311160827.1129643-1-ulf.hansson@linaro.org> References: <20250311160827.1129643-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The s2idle_lock must be held while checking for a pending wakeup and while moving into S2IDLE_STATE_ENTER, to make sure a wakeup doesn't get lost. Let's extend the comment in the code to make this clear. Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. Suggested by Rafael. --- kernel/power/suspend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 90fb06ca07d2..b7aa1db278ff 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -91,8 +91,12 @@ static void s2idle_enter(void) { trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true); =20 - /* CPUs can't be hotplugged here so let's not protect for it. */ - + /* + * The s2idle_lock must be held while checking for a pending wakeup and + * while moving into S2IDLE_STATE_ENTER, to make sure a wakeup doesn't + * get lost. Note also that CPUs can't be hotplugged here so let's not + * protect for it. + */ raw_spin_lock_irq(&s2idle_lock); if (pm_wakeup_pending()) goto out; --=20 2.43.0