Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-06 Thread Joel Fernandes
On Tue, Dec 01, 2020 at 08:20:50PM +0100, Peter Zijlstra wrote: > On Tue, Dec 01, 2020 at 02:11:33PM -0500, Joel Fernandes wrote: > > On Wed, Nov 25, 2020 at 12:15:41PM +0100, Peter Zijlstra wrote: > > > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > > > > > +/* >

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-06 Thread Joel Fernandes
Hi Peter, On Tue, Dec 01, 2020 at 08:34:51PM +0100, Peter Zijlstra wrote: > On Tue, Dec 01, 2020 at 02:20:28PM -0500, Joel Fernandes wrote: > > On Wed, Nov 25, 2020 at 12:10:14PM +0100, Peter Zijlstra wrote: > > > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > >

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-03 Thread Josh Don
On Tue, Dec 1, 2020 at 11:55 PM Peter Zijlstra wrote: > > Then disallow sharing a task cookie when the tasks are in different > cgroups or disallow cgroup movement when they share a cookie. Yes, we could restrict task cookie sharing to tasks that are in the same cgroup. Then the cookie easily

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Peter Zijlstra
On Tue, Dec 01, 2020 at 10:36:18PM -0800, Josh Don wrote: > On Tue, Dec 1, 2020 at 11:35 AM Peter Zijlstra wrote: > > > > So I don't think that later patch is right... That is, it works, but > > afaict it's massive overkill. > > > > COOKIE_CMP_RETURN(task_cookie); > >

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Josh Don
On Tue, Dec 1, 2020 at 11:35 AM Peter Zijlstra wrote: > > So I don't think that later patch is right... That is, it works, but > afaict it's massive overkill. > > COOKIE_CMP_RETURN(task_cookie); > COOKIE_CMP_RETURN(group_cookie); > COOKIE_CMP_RETURN(color); > > So if

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Peter Zijlstra
On Tue, Dec 01, 2020 at 02:20:28PM -0500, Joel Fernandes wrote: > On Wed, Nov 25, 2020 at 12:10:14PM +0100, Peter Zijlstra wrote: > > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > +void sched_core_tag_requeue(struct task_struct *p, unsigned long cookie, > > > bool

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Peter Zijlstra
On Tue, Dec 01, 2020 at 02:11:33PM -0500, Joel Fernandes wrote: > On Wed, Nov 25, 2020 at 12:15:41PM +0100, Peter Zijlstra wrote: > > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > > > +/* > > > + * Ensure that the task has been requeued. The stopper ensures that

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Joel Fernandes
On Wed, Nov 25, 2020 at 12:10:14PM +0100, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > +void sched_core_tag_requeue(struct task_struct *p, unsigned long cookie, > > bool group) > > +{ > > + if (!p) > > + return; > > + > > + if

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Joel Fernandes
On Wed, Nov 25, 2020 at 12:11:28PM +0100, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > + * sched_core_tag_requeue - Common helper for all interfaces to set a > > cookie. > > sched_core_set_cookie() would be a saner name, given that

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Joel Fernandes
On Wed, Nov 25, 2020 at 12:15:41PM +0100, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > +/* > > + * Ensure that the task has been requeued. The stopper ensures that the > > task cannot > > + * be migrated to a different CPU while its core

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Joel Fernandes
On Wed, Nov 25, 2020 at 12:07:09PM +0100, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > Also, for the per-task cookie, it will get weird if we use pointers of any > > emphemeral objects. For this reason, introduce a refcounted object who's >

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Joel Fernandes
On Wed, Nov 25, 2020 at 02:03:22PM +0100, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > +static bool sched_core_get_task_cookie(unsigned long cookie) > > +{ > > + struct sched_core_cookie *ptr = (struct sched_core_cookie *)cookie; > > + > >

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-12-01 Thread Joel Fernandes
On Wed, Nov 25, 2020 at 01:54:47PM +0100, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > +/* Per-task interface */ > > +static unsigned long sched_core_alloc_task_cookie(void) > > +{ > > + struct sched_core_cookie *ptr = > > +

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-30 Thread Balbir Singh
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > In order to prevent interference and clearly support both per-task and CGroup > APIs, split the cookie into 2 and allow it to be set from either per-task, or > CGroup API. The final cookie is the combined value of both and

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-25 Thread Peter Zijlstra
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > +static bool sched_core_get_task_cookie(unsigned long cookie) > +{ > + struct sched_core_cookie *ptr = (struct sched_core_cookie *)cookie; > + > + /* > + * NOTE: sched_core_put() is not done by

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-25 Thread Peter Zijlstra
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > +/* Per-task interface */ > +static unsigned long sched_core_alloc_task_cookie(void) > +{ > + struct sched_core_cookie *ptr = > + kmalloc(sizeof(struct sched_core_cookie), GFP_KERNEL); > + > + if (!ptr)

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-25 Thread Peter Zijlstra
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > +/* > + * Ensure that the task has been requeued. The stopper ensures that the task > cannot > + * be migrated to a different CPU while its core scheduler queue state is > being updated. > + * It also makes sure to

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-25 Thread Peter Zijlstra
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > + * sched_core_tag_requeue - Common helper for all interfaces to set a cookie. sched_core_set_cookie() would be a saner name, given that description, don't you think?

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-25 Thread Peter Zijlstra
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > +void sched_core_tag_requeue(struct task_struct *p, unsigned long cookie, > bool group) > +{ > + if (!p) > + return; > + > + if (group) > + p->core_group_cookie = cookie; > + else > +

Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-25 Thread Peter Zijlstra
On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > Also, for the per-task cookie, it will get weird if we use pointers of any > emphemeral objects. For this reason, introduce a refcounted object who's sole > purpose is to assign unique cookie value by way of the object's

[PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork

2020-11-17 Thread Joel Fernandes (Google)
In order to prevent interference and clearly support both per-task and CGroup APIs, split the cookie into 2 and allow it to be set from either per-task, or CGroup API. The final cookie is the combined value of both and is computed when the stop-machine executes during a change of cookie. Also,