From nobody Wed Dec 17 19:18:23 2025 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 CF9B91E9B37 for ; Fri, 3 Oct 2025 15:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759503793; cv=none; b=eiesoTrq/xvm1cLuP6TeOGFmw5GWi7OK7Z9jvqAicSkU9s7TOu1vWNOd6dnf0jZ77kOBEplzWm1Tr42nhT6FQfFgR4uZPTxek9JvciFbiRVkiFAwXF3z5X5Es4QKR54C7EgVRKg4QDIIgCWCArJkefLOolmFAQ3V6gB5oBywOC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759503793; c=relaxed/simple; bh=XK4CQ3RlnbdYdO+YvNeTusWRbzxZGhvL/oHJx9n5/uo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t3YL8941cG0+gUM5R0DrpfFsJ0z5MRsC0fUhZnvyh/bau3n+GdCDkFPtCdwmXqEkniv0qTR+TkVhITvTsV9DzOd53cLIoz/+bTjRNa5FgWlXuj+WEJgQoOut0tjAJ0F4hByGW7yU63+2Z21xoXo/+F8MgBQAjelO0pPJ377Wp0Y= 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=wj6siZ0C; arc=none smtp.client-ip=209.85.167.52 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="wj6siZ0C" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-57a604fecb4so2988096e87.1 for ; Fri, 03 Oct 2025 08:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1759503790; x=1760108590; 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=4hihU1RjeShMW+xMGPqIOaGj65BRsX1zPODZiqAoHCE=; b=wj6siZ0CQAD2w5j80Q9f69/jhIatYT3zMxq6MTxb9BX0OTUQ4rUf6sgp18TcX5TfDg /wjzo651mM8z0VyVD3bDvHunTjodm3dCUjBLi6EwqbJ6aZob5UpvLd72iw73j36mTQJU EdH9Hk2Z8OqeRZZz4+aJwIaZpJH7iwJoXlKWcjRKdWfGOoRp/p2G+hYJsdM2g2rqIluJ 5wG+9pjAObsUrWM1L4DPkX04lPh3j1eBmrau5GROuSGu3RRzaoEM0vf0c/LSlWyYPmOE 9KF3hG5E/cnxuNGx/8C90jMuxK4YD65Cupx/nmTHEI+a6npzYvWRZrtxMZMaYX0AbXwP fKKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759503790; x=1760108590; 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=4hihU1RjeShMW+xMGPqIOaGj65BRsX1zPODZiqAoHCE=; b=nOjGtUJTjJzbHoBknOv90n/bw89TToVqw+RbKJ02ETkwWJ2q9jipSyFuqYxyfPLEFC w1CAvb/22k+JS7/7s8INne32TjjqxucxDzvIclqmy+7XdviwFmiq6NpOKtSAhaKrgIGa RmT8sSRjZCQAY/gPjk2Je41gDyMZYNUpVeCwfI4W7p9PwsIqDbz/8X4XsjhZnk6JdO6U PC8s+5KIciC3WVx1SU0oxndTAl997kA8MvTuocObVn9JQfP0byuomRHEGgYBMNPNaE0p Yw9Jmyf7hVdr9OLDWOMGsDpuwgQqcgKHHfIQHZNWM5786ndeGbfe9J4Cn7e0AOvwRcHc REtg== X-Forwarded-Encrypted: i=1; AJvYcCWSOYj6aLq6d6IljyKY+pBIoYbgcYc1/TOebMsKErbQrSN2NWUi9r2unzXKXTmEqzFOTyQqsWhl4bZn93U=@vger.kernel.org X-Gm-Message-State: AOJu0Ywmc/4AEmFKCT9ztpSsXqoFNt4nOTHQ0a5t3HcuaoU+F6NZbmUD akC460xL9g1Gk8y7vbyBE5CYYiZk8zflvp2Ut2Dmwyjka9dphbt10+pGSEywo5gGbBU= X-Gm-Gg: ASbGncuIkWilu8iCcSVQe0oXL+pE0+Ycsq33mHXaO9L0XAlXfoSoKyFG2CNaeyr2atp d6p9ZyNjgRjwyEmm3VXlcJAQBOVFJVx6ScakX6aWIseRTP6Zj/elsjENiAPxqNdb7hHL/f3zGX4 sWKP0QT4rSSMbkHzmkZWxgYgQHSnogc4XJRsmgXzaw9f6ybzo7fcpGCXPUcP2Kf2nrDB8iSeuf5 Y0J7gbGqE1Pca4y3DmeEHghbQJFqr0KOSamXW8QwJu/LptpI+N8HvGffYS733Unu186kilEC0AA d+4dj6zK7njVqWB6Qj4gdfwD4+x38nDo/GjsPmobKkfW3O6Ki9WR2Vtq3PF9lRTDcCngZTBaJre gswttwU5gU37dS5LbW56fTKcMocktjcgqoEHsQo8ogbYJGFRvGU+lX7CzZwF6GgU95Wr8kag7C+ LYvihb+A91E12MKOB2Ugg6hXJb X-Google-Smtp-Source: AGHT+IHu4PqHQYTqpy6vc1bGma7aV+0D6GP0m2nkuDc3p3Rnn6+vAHAZZGlxtp7LPL+ZjpY/yp6VSw== X-Received: by 2002:a05:6512:b23:b0:57f:492:3263 with SMTP id 2adb3069b0e04-58cb9f0b45dmr790708e87.1.1759503789674; Fri, 03 Oct 2025 08:03:09 -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 2adb3069b0e04-58b011343b6sm1933369e87.35.2025.10.03.08.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Oct 2025 08:03:09 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Catalin Marinas , Will Deacon , Mark Rutland , Thomas Gleixner Cc: Maulik Shah , Sudeep Holla , Daniel Lezcano , Vincent Guittot , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 1/3] smp: Introduce a weak helper function to check for pending IPIs Date: Fri, 3 Oct 2025 17:02:43 +0200 Message-ID: <20251003150251.520624-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251003150251.520624-1-ulf.hansson@linaro.org> References: <20251003150251.520624-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" When governors used during cpuidle, tries to find the most optimal idlestate for a CPU or a group of CPUs, they are known to quite often fail. One reason for this, is that we are not taking into account whether there has been an IPI scheduled for any of the CPUs that are affected by the selected idlestate. To enable pending IPIs to be taken into account for cpuidle decisions, let's introduce a new helper function, cpus_has_pending_ipi(). Moreover, let's use the __weak attribute for the default implementation, to allow this to be implemented on a per architecture basis. Signed-off-by: Ulf Hansson --- include/linux/smp.h | 5 +++++ kernel/smp.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/smp.h b/include/linux/smp.h index 18e9c918325e..476186e5e69c 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -168,6 +168,7 @@ int smp_call_function_any(const struct cpumask *mask, =20 void kick_all_cpus_sync(void); void wake_up_all_idle_cpus(void); +bool cpus_has_pending_ipi(const struct cpumask *mask); =20 /* * Generic and arch helpers @@ -216,6 +217,10 @@ smp_call_function_any(const struct cpumask *mask, smp_= call_func_t func, =20 static inline void kick_all_cpus_sync(void) { } static inline void wake_up_all_idle_cpus(void) { } +static inline bool cpus_has_pending_ipi(const struct cpumask *mask) +{ + return false; +} =20 #define setup_max_cpus 0 =20 diff --git a/kernel/smp.c b/kernel/smp.c index 56f83aa58ec8..ec524db501b5 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -1088,6 +1088,24 @@ void wake_up_all_idle_cpus(void) } EXPORT_SYMBOL_GPL(wake_up_all_idle_cpus); =20 +/** + * cpus_has_pending_ipi - Check for pending IPIs for CPUs + * @mask: The CPU mask for the CPUs to check. + * + * This function may be overriden by an arch specific implementation, which + * should walk through the CPU-mask and check if there are any pending IPIs + * being scheduled for any of the CPUs in the CPU-mask. + * + * Note, the default implementation below doesn't have the capability to c= heck + * for IPIs, hence it must return false. + * + * Returns true if there is a pending IPI scheduled. + */ +bool __weak cpus_has_pending_ipi(const struct cpumask *mask) +{ + return false; +} + /** * struct smp_call_on_cpu_struct - Call a function on a specific CPU * @work: &work_struct --=20 2.43.0