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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250529115129.GA541982@bytedance>
Date: Thu, 29 May 2025 19:51:48 +0800
From: Aaron Lu <ziqianlu@...edance.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Valentin Schneider <vschneid@...hat.com>,
	Ben Segall <bsegall@...gle.com>,
	K Prateek Nayak <kprateek.nayak@....com>,
	Josh Don <joshdon@...gle.com>, Ingo Molnar <mingo@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Xi Wang <xii@...gle.com>, linux-kernel@...r.kernel.org,
	Juri Lelli <juri.lelli@...hat.com>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Steven Rostedt <rostedt@...dmis.org>, Mel Gorman <mgorman@...e.de>,
	Chengming Zhou <chengming.zhou@...ux.dev>,
	Chuyi Zhou <zhouchuyi@...edance.com>,
	Jan Kiszka <jan.kiszka@...mens.com>,
	Florian Bezdeka <florian.bezdeka@...mens.com>
Subject: Re: [PATCH 2/7] sched/fair: prepare throttle path for task based
 throttle

On Fri, May 23, 2025 at 03:40:14PM +0800, Aaron Lu wrote:
> On Thu, May 22, 2025 at 01:07:28PM +0200, Peter Zijlstra wrote:
> > On Tue, May 20, 2025 at 06:41:05PM +0800, Aaron Lu wrote:
> > > @@ -8851,6 +8913,7 @@ static struct task_struct *pick_task_fair(struct rq *rq)
> > >  {
> > >  	struct sched_entity *se;
> > >  	struct cfs_rq *cfs_rq;
> > > +	struct task_struct *p;
> > >  
> > >  again:
> > >  	cfs_rq = &rq->cfs;
> > > @@ -8871,7 +8934,14 @@ static struct task_struct *pick_task_fair(struct rq *rq)
> > >  		cfs_rq = group_cfs_rq(se);
> > >  	} while (cfs_rq);
> > >  
> > > -	return task_of(se);
> > > +	p = task_of(se);
> > > +	if (throttled_hierarchy(cfs_rq_of(se))) {
> > > +		/* Shuold not happen for now */
> > > +		WARN_ON_ONCE(1);
> > > +		task_throttle_setup_work(p);
> > > +	}
> > > +
> > > +	return p;
> > >  }
> > 
> > So the final code is a little different, because you're removing the
> > return value from check_cfs_rq_runtime().
> > 
> > But would not that exact return value be the thing you're now checking
> > for again?
> >
> 
> Ah yes.
> 
> > That is; at the end of the series, would not something like:
> > 
> > static struct task_struct *pick_task_fair(struct rq *rq)
> > {
> > 	struct sched_entity *se;
> > 	struct cfs_rq *cfs_rq;
> > 	struct task_struct *p;
> > 	bool throttled;
> > 
> > again:
> > 	cfs_rq = &rq->cfs;
> > 	if (!cfs_rq->nr_queued)
> > 		return NULL;
> > 
> > 	throttled = false;
> > 
> > 	do {
> > 		if (cfs_rq->curr && cfs_rq->curr->on_rq)
> > 			update_curr(cfs_rq);
> > 
> > 		throttled |= check_cfs_rq_runtime(cfs_rq);
> > 
> > 		se = pick_next_entity(rq, cfs_rq);
> > 		if (!se)
> > 			goto again;
> > 
> > 		cfs_rq = group_cfs_rq(se);
> > 	} while (cfs_rq);
> > 
> > 	p = task_of(se);
> > 	if (unlikely(throttled))
> > 		task_throttle_setup_work(p);
> > 	return p;
> > }
> > 
> > make it more obvious / be simpler?
> 
> Thanks for the suggestion, will follow it in next version.

Found a tiny difference while testing: check_cfs_rq_runtime() could
return false for a cfs_rq whose throttled_hierarchy() is true. The
reason is, that still throttled cfs_rq may be assigned runtime by
another cpu doing distribute_cfs_runtime() and has an async unthrottle
queued but didn't process it yet. The end result is, it has a positive
runtime_remaining but isn't unthrottled yet. I think this doesn't make
much difference but thought it might be worth mentioning.

A side note, now that check_cfs_rq_runtime() only marks cfs_rq's
throttle status and returns a signal, it no longer does dequeuing
stuffs, I suppose there is no need to call it in put_prev_entity()?
Because that signal is now only useful in pick time and we always run
check_cfs_rq_runtime() on every cfs_rq encountered during pick.

Also, check_enqueue_throttle() doesn't look useful either because
enqueued task will go through pick and we will add a throttle work to it
if needed. I removed these stuffs and run some tests, didn't notice
anything wrong yet but perhaps I missed something, comments?

Best regards,
Aaron

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ