public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on selftest on UP systems
@ 2025-01-25  9:36 Andrea Righi
  2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state Andrea Righi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrea Righi @ 2025-01-25  9:36 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min; +Cc: linux-kernel

Introduce a new portable scx helper to check whether a task can migrate and
use it in the dsp_local_on selftest, so that it can run also on UP systems.

Andrea Righi (2):
      tools/sched_ext: Add helper to check task migration state
      sched_ext: selftests/dsp_local_on: Fix selftest on UP systems

 tools/sched_ext/include/scx/common.bpf.h             | 11 +++++++++++
 tools/testing/selftests/sched_ext/dsp_local_on.bpf.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state
  2025-01-25  9:36 [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on selftest on UP systems Andrea Righi
@ 2025-01-25  9:36 ` Andrea Righi
  2025-01-25 17:14   ` [PATCH v2 " Andrea Righi
  2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 2/2] sched_ext: selftests/dsp_local_on: Fix selftest on UP systems Andrea Righi
  2025-01-27 19:00 ` [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on " Tejun Heo
  2 siblings, 1 reply; 5+ messages in thread
From: Andrea Righi @ 2025-01-25  9:36 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min; +Cc: linux-kernel

Introduce a new helper for BPF schedulers to determine whether a task
can migrate or not (supporting both SMP and UP systems).

Fixes: e9fe182772dc ("sched_ext: selftests/dsp_local_on: Fix sporadic failures")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 tools/sched_ext/include/scx/common.bpf.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
index f3e15e9efa76..745440f38f84 100644
--- a/tools/sched_ext/include/scx/common.bpf.h
+++ b/tools/sched_ext/include/scx/common.bpf.h
@@ -404,6 +404,17 @@ static __always_inline const struct cpumask *cast_mask(struct bpf_cpumask *mask)
 	return (const struct cpumask *)mask;
 }
 
+/*
+ * Return true if task @p cannot migrate to a different CPU, false
+ * otherwise.
+ */
+static bool is_migration_disabled(const struct task_struct *p)
+{
+	if (bpf_core_field_exists(p->migration_disabled))
+		return p->migration_disabled;
+	return false;
+}
+
 /* rcu */
 void bpf_rcu_read_lock(void) __ksym;
 void bpf_rcu_read_unlock(void) __ksym;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH sched_ext/for-6.14-fixes 2/2] sched_ext: selftests/dsp_local_on: Fix selftest on UP systems
  2025-01-25  9:36 [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on selftest on UP systems Andrea Righi
  2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state Andrea Righi
@ 2025-01-25  9:36 ` Andrea Righi
  2025-01-27 19:00 ` [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on " Tejun Heo
  2 siblings, 0 replies; 5+ messages in thread
From: Andrea Righi @ 2025-01-25  9:36 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min; +Cc: linux-kernel

In UP systems p->migration_disabled is not available. Fix this by using
the portable helper is_migration_disabled(p).

Fixes: e9fe182772dc ("sched_ext: selftests/dsp_local_on: Fix sporadic failures")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 tools/testing/selftests/sched_ext/dsp_local_on.bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c b/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
index 758b479bd1ee..c02b2aa6fc64 100644
--- a/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
+++ b/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
@@ -43,7 +43,7 @@ void BPF_STRUCT_OPS(dsp_local_on_dispatch, s32 cpu, struct task_struct *prev)
 	if (!p)
 		return;
 
-	if (p->nr_cpus_allowed == nr_cpus && !p->migration_disabled)
+	if (p->nr_cpus_allowed == nr_cpus && !is_migration_disabled(p))
 		target = bpf_get_prandom_u32() % nr_cpus;
 	else
 		target = scx_bpf_task_cpu(p);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state
  2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state Andrea Righi
@ 2025-01-25 17:14   ` Andrea Righi
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea Righi @ 2025-01-25 17:14 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min; +Cc: linux-kernel

Introduce a new helper for BPF schedulers to determine whether a task
can migrate or not (supporting both SMP and UP systems).

Fixes: e9fe182772dc ("sched_ext: selftests/dsp_local_on: Fix sporadic failures")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 tools/sched_ext/include/scx/common.bpf.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

ChangeLog v1 -> v2:
 - add missing inline

diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
index f3e15e9efa76..f254a39b86a5 100644
--- a/tools/sched_ext/include/scx/common.bpf.h
+++ b/tools/sched_ext/include/scx/common.bpf.h
@@ -404,6 +404,17 @@ static __always_inline const struct cpumask *cast_mask(struct bpf_cpumask *mask)
 	return (const struct cpumask *)mask;
 }
 
+/*
+ * Return true if task @p cannot migrate to a different CPU, false
+ * otherwise.
+ */
+static inline bool is_migration_disabled(const struct task_struct *p)
+{
+	if (bpf_core_field_exists(p->migration_disabled))
+		return p->migration_disabled;
+	return false;
+}
+
 /* rcu */
 void bpf_rcu_read_lock(void) __ksym;
 void bpf_rcu_read_unlock(void) __ksym;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on selftest on UP systems
  2025-01-25  9:36 [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on selftest on UP systems Andrea Righi
  2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state Andrea Righi
  2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 2/2] sched_ext: selftests/dsp_local_on: Fix selftest on UP systems Andrea Righi
@ 2025-01-27 19:00 ` Tejun Heo
  2 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2025-01-27 19:00 UTC (permalink / raw)
  To: Andrea Righi; +Cc: David Vernet, Changwoo Min, linux-kernel

On Sat, Jan 25, 2025 at 10:36:05AM +0100, Andrea Righi wrote:
> Introduce a new portable scx helper to check whether a task can migrate and
> use it in the dsp_local_on selftest, so that it can run also on UP systems.
> 
> Andrea Righi (2):
>       tools/sched_ext: Add helper to check task migration state
>       sched_ext: selftests/dsp_local_on: Fix selftest on UP systems

Ah, you already did.

Applied to sched_ext/for-6.14-fixes.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-27 19:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-25  9:36 [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on selftest on UP systems Andrea Righi
2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 1/2] tools/sched_ext: Add helper to check task migration state Andrea Righi
2025-01-25 17:14   ` [PATCH v2 " Andrea Righi
2025-01-25  9:36 ` [PATCH sched_ext/for-6.14-fixes 2/2] sched_ext: selftests/dsp_local_on: Fix selftest on UP systems Andrea Righi
2025-01-27 19:00 ` [PATCH sched_ext/for-6.14-fixes 0/2] sched_ext: Fix dsp_local_on " Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox