lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aJqZihOivRztpRtP@slm.duckdns.org>
Date: Mon, 11 Aug 2025 15:31:54 -1000
From: 'Tejun Heo' <tj@...nel.org>
To: liuwenfang <liuwenfang@...or.com>
Cc: 'David Vernet' <void@...ifault.com>, 'Andrea Righi' <arighi@...dia.com>,
	'Changwoo Min' <changwoo@...lia.com>,
	'Ingo Molnar' <mingo@...hat.com>,
	'Peter Zijlstra' <peterz@...radead.org>,
	'Juri Lelli' <juri.lelli@...hat.com>,
	'Vincent Guittot' <vincent.guittot@...aro.org>,
	'Dietmar Eggemann' <dietmar.eggemann@....com>,
	'Steven Rostedt' <rostedt@...dmis.org>,
	'Ben Segall' <bsegall@...gle.com>, 'Mel Gorman' <mgorman@...e.de>,
	'Valentin Schneider' <vschneid@...hat.com>,
	"'linux-kernel@...r.kernel.org'" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 3/3] sched_ext: Fix cpu_released while changing sched
 policy of the running task

On Sun, Jul 20, 2025 at 09:41:03AM +0000, liuwenfang wrote:
> Priority inheritance policy should be cared, eg., one SCX task can be
> boosted to REAL-TIME while holding a mutex lock, and then restored while
> releasing the lock. The value cpu_released is fixed when changing the
> sched class of the running task.
> 
> Signed-off-by: Wenfang Liu liuwenfang@...or.com
> ---
>  kernel/sched/ext.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index ddf4bd060..e3b9032e2 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -3899,11 +3899,30 @@ static void switching_to_scx(struct rq *rq, struct task_struct *p)
>  
>  static void switched_from_scx(struct rq *rq, struct task_struct *p)
>  {
> +	if (task_current(rq, p))
> +		switch_class(rq, p);

switch_class() should probably be named to something more specific - e.g.
maybe_cpu_release()?

>  	scx_ops_disable_task(p);
>  }
>  
>  static void wakeup_preempt_scx(struct rq *rq, struct task_struct *p,int wake_flags) {}
> -static void switched_to_scx(struct rq *rq, struct task_struct *p) {}
> +static void switched_to_scx(struct rq *rq, struct task_struct *p)
> +{
> +	lockdep_assert_rq_held(rq);
> +
> +	if (static_branch_unlikely(&scx_ops_cpu_preempt) &&
> +	    unlikely(rq->scx.cpu_released) && task_current(rq, p)) {
> +		/*
> +		 * If the previous sched_class for the current CPU was not SCX,
> +		 * notify the BPF scheduler that it again has control of the
> +		 * core. This callback complements ->cpu_release(), which is
> +		 * emitted in switch_class().
> +		 */
> +		if (SCX_HAS_OP(cpu_acquire))
> +			SCX_CALL_OP(SCX_KF_REST, cpu_acquire, rq, cpu_of(rq), NULL);
> +		rq->scx.cpu_released = false;
> +	}
> +}

and most of this can be factored into e.g. maybe_cpu_acquire() so that the
same code is not duplicated between here and balance_one()?

Also, please target the for-6.17-fixes branch of the sched_ext tree.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git for-6.17-fixes

Thank you.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ