Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:55, Peter Zijlstra wrote: > On Wed, Nov 07, 2018 at 02:48:09PM +, Patrick Bellasi wrote: > > On 07-Nov 14:35, Peter Zijlstra wrote: > > You mean se_count overflow ? > > Yah.. > > > > And I'm not really a fan of hiding that error in a define like you keep > > > doing. > > > >

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:55, Peter Zijlstra wrote: > On Wed, Nov 07, 2018 at 02:48:09PM +, Patrick Bellasi wrote: > > On 07-Nov 14:35, Peter Zijlstra wrote: > > You mean se_count overflow ? > > Yah.. > > > > And I'm not really a fan of hiding that error in a define like you keep > > > doing. > > > >

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:44, Peter Zijlstra wrote: > On Wed, Nov 07, 2018 at 02:24:28PM +, Patrick Bellasi wrote: > > On 07-Nov 14:44, Peter Zijlstra wrote: > > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > > > +static void uclamp_group_get(struct uclamp_se *uc_se, unsigned int

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:44, Peter Zijlstra wrote: > On Wed, Nov 07, 2018 at 02:24:28PM +, Patrick Bellasi wrote: > > On 07-Nov 14:44, Peter Zijlstra wrote: > > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > > > +static void uclamp_group_get(struct uclamp_se *uc_se, unsigned int

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:42, Peter Zijlstra wrote: > On Wed, Nov 07, 2018 at 02:19:49PM +, Patrick Bellasi wrote: > > On 07-Nov 13:19, Peter Zijlstra wrote: > > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > > +struct uclamp_se { > > > > + unsigned int value :

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:42, Peter Zijlstra wrote: > On Wed, Nov 07, 2018 at 02:19:49PM +, Patrick Bellasi wrote: > > On 07-Nov 13:19, Peter Zijlstra wrote: > > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > > +struct uclamp_se { > > > > + unsigned int value :

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 02:48:09PM +, Patrick Bellasi wrote: > On 07-Nov 14:35, Peter Zijlstra wrote: > You mean se_count overflow ? Yah.. > > And I'm not really a fan of hiding that error in a define like you keep > > doing. > > The #define is not there to mask an overflow, it's there to

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 02:48:09PM +, Patrick Bellasi wrote: > On 07-Nov 14:35, Peter Zijlstra wrote: > You mean se_count overflow ? Yah.. > > And I'm not really a fan of hiding that error in a define like you keep > > doing. > > The #define is not there to mask an overflow, it's there to

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:37, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +static int __setscheduler_uclamp(struct task_struct *p, > > +const struct sched_attr *attr) > > +{ > > + unsigned int lower_bound =

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 15:37, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +static int __setscheduler_uclamp(struct task_struct *p, > > +const struct sched_attr *attr) > > +{ > > + unsigned int lower_bound =

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 14:35, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +/** > > + * uclamp_group_get: increase the reference count for a clamp group > > + * @uc_se: the utilization clamp data for the task > > + * @clamp_id: the clamp index affected by the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 14:35, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +/** > > + * uclamp_group_get: increase the reference count for a clamp group > > + * @uc_se: the utilization clamp data for the task > > + * @clamp_id: the clamp index affected by the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 02:24:28PM +, Patrick Bellasi wrote: > On 07-Nov 14:44, Peter Zijlstra wrote: > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > +static void uclamp_group_get(struct uclamp_se *uc_se, unsigned int > > > clamp_id, > > > +

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 02:24:28PM +, Patrick Bellasi wrote: > On 07-Nov 14:44, Peter Zijlstra wrote: > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > +static void uclamp_group_get(struct uclamp_se *uc_se, unsigned int > > > clamp_id, > > > +

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 02:19:49PM +, Patrick Bellasi wrote: > On 07-Nov 13:19, Peter Zijlstra wrote: > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > +struct uclamp_se { > > > + unsigned int value : SCHED_CAPACITY_SHIFT + 1; > > > + unsigned int group_id

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 02:19:49PM +, Patrick Bellasi wrote: > On 07-Nov 13:19, Peter Zijlstra wrote: > > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > +struct uclamp_se { > > > + unsigned int value : SCHED_CAPACITY_SHIFT + 1; > > > + unsigned int group_id

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +static int __setscheduler_uclamp(struct task_struct *p, > + const struct sched_attr *attr) > +{ > + unsigned int lower_bound = p->uclamp[UCLAMP_MIN].value; > + unsigned int upper_bound =

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +static int __setscheduler_uclamp(struct task_struct *p, > + const struct sched_attr *attr) > +{ > + unsigned int lower_bound = p->uclamp[UCLAMP_MIN].value; > + unsigned int upper_bound =

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 14:44, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +/** > > + * uclamp_group_get: increase the reference count for a clamp group > > + * @uc_se: the utilization clamp data for the task > > + * @clamp_id: the clamp index affected by the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 14:44, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +/** > > + * uclamp_group_get: increase the reference count for a clamp group > > + * @uc_se: the utilization clamp data for the task > > + * @clamp_id: the clamp index affected by the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 13:19, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +struct uclamp_se { > > + unsigned int value : SCHED_CAPACITY_SHIFT + 1; > > + unsigned int group_id : order_base_2(UCLAMP_GROUPS); > > Are you sure about ob2()

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 13:19, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > +struct uclamp_se { > > + unsigned int value : SCHED_CAPACITY_SHIFT + 1; > > + unsigned int group_id : order_base_2(UCLAMP_GROUPS); > > Are you sure about ob2()

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 01:57:38PM +, Patrick Bellasi wrote: > On 07-Nov 14:16, Peter Zijlstra wrote: > > Please write cmpxchg loops in the form: > > > > atomic_long_t *ptr = _maps[clamp_id][group_id].adata; > > union uclamp_map old, new; > > > > old.data =

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Wed, Nov 07, 2018 at 01:57:38PM +, Patrick Bellasi wrote: > On 07-Nov 14:16, Peter Zijlstra wrote: > > Please write cmpxchg loops in the form: > > > > atomic_long_t *ptr = _maps[clamp_id][group_id].adata; > > union uclamp_map old, new; > > > > old.data =

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 14:16, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > +static void uclamp_group_put(unsigned int clamp_id, unsigned int group_id) > > { > > + union uclamp_map *uc_maps = _maps[clamp_id][0]; > > + union uclamp_map uc_map_old,

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Patrick Bellasi
On 07-Nov 14:16, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > > > +static void uclamp_group_put(unsigned int clamp_id, unsigned int group_id) > > { > > + union uclamp_map *uc_maps = _maps[clamp_id][0]; > > + union uclamp_map uc_map_old,

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +/** > + * uclamp_group_get: increase the reference count for a clamp group > + * @uc_se: the utilization clamp data for the task > + * @clamp_id: the clamp index affected by the task > + * @clamp_value: the new clamp value for the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +/** > + * uclamp_group_get: increase the reference count for a clamp group > + * @uc_se: the utilization clamp data for the task > + * @clamp_id: the clamp index affected by the task > + * @clamp_value: the new clamp value for the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +/** > + * uclamp_group_get: increase the reference count for a clamp group > + * @uc_se: the utilization clamp data for the task > + * @clamp_id: the clamp index affected by the task > + * @clamp_value: the new clamp value for the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +/** > + * uclamp_group_get: increase the reference count for a clamp group > + * @uc_se: the utilization clamp data for the task > + * @clamp_id: the clamp index affected by the task > + * @clamp_value: the new clamp value for the

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +static void uclamp_group_put(unsigned int clamp_id, unsigned int group_id) > { > + union uclamp_map *uc_maps = _maps[clamp_id][0]; > + union uclamp_map uc_map_old, uc_map_new; > + long res; > + > +retry: > + > +

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +static void uclamp_group_put(unsigned int clamp_id, unsigned int group_id) > { > + union uclamp_map *uc_maps = _maps[clamp_id][0]; > + union uclamp_map uc_map_old, uc_map_new; > + long res; > + > +retry: > + > +

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +struct uclamp_se { > + unsigned int value : SCHED_CAPACITY_SHIFT + 1; > + unsigned int group_id : order_base_2(UCLAMP_GROUPS); Are you sure about ob2() ? seems weird we'll end up with 0 for

Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-11-07 Thread Peter Zijlstra
On Mon, Oct 29, 2018 at 06:32:57PM +, Patrick Bellasi wrote: > +struct uclamp_se { > + unsigned int value : SCHED_CAPACITY_SHIFT + 1; > + unsigned int group_id : order_base_2(UCLAMP_GROUPS); Are you sure about ob2() ? seems weird we'll end up with 0 for

[PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-10-29 Thread Patrick Bellasi
Utilization clamping requires each CPU to know which clamp values are assigned to tasks that are currently RUNNABLE on that CPU: multiple tasks can be assigned the same clamp value and tasks with different clamp values can be concurrently active on the same CPU. A proper data structure is

[PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups

2018-10-29 Thread Patrick Bellasi
Utilization clamping requires each CPU to know which clamp values are assigned to tasks that are currently RUNNABLE on that CPU: multiple tasks can be assigned the same clamp value and tasks with different clamp values can be concurrently active on the same CPU. A proper data structure is