Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Peter Zijlstra
On Thu, Mar 14, 2019 at 03:07:53PM +, Patrick Bellasi wrote: > On 14-Mar 14:32, Peter Zijlstra wrote: > > On Thu, Mar 14, 2019 at 12:13:15PM +, Patrick Bellasi wrote: > > > > I'd be most impressed if they pull this off. Check the generated code > > > > and see I suppose :-) > > > > > > On

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Suren Baghdasaryan
On Thu, Mar 14, 2019 at 8:41 AM Patrick Bellasi wrote: > > On 14-Mar 08:29, Suren Baghdasaryan wrote: > > On Thu, Mar 14, 2019 at 7:46 AM Patrick Bellasi > > wrote: > > > On 13-Mar 14:32, Suren Baghdasaryan wrote: > > > > On Fri, Feb 8, 2019 at 2:06 AM Patrick Bellasi > > > > wrote: > > [...]

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 14-Mar 08:29, Suren Baghdasaryan wrote: > On Thu, Mar 14, 2019 at 7:46 AM Patrick Bellasi > wrote: > > On 13-Mar 14:32, Suren Baghdasaryan wrote: > > > On Fri, Feb 8, 2019 at 2:06 AM Patrick Bellasi > > > wrote: [...] > > > > The rq::uclamp::bucket[clamp_id][] array is scanned every time

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Suren Baghdasaryan
On Thu, Mar 14, 2019 at 7:46 AM Patrick Bellasi wrote: > > On 13-Mar 14:32, Suren Baghdasaryan wrote: > > On Fri, Feb 8, 2019 at 2:06 AM Patrick Bellasi > > wrote: > > > > > > Utilization clamping allows to clamp the CPU's utilization within a > > > [util_min, util_max] range, depending on the

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 14-Mar 14:32, Peter Zijlstra wrote: > On Thu, Mar 14, 2019 at 12:13:15PM +, Patrick Bellasi wrote: > > > I'd be most impressed if they pull this off. Check the generated code > > > and see I suppose :-) > > > > On x86 the code generated looks exactly the same: > > > >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 15:15, Patrick Bellasi wrote: > On 12-Mar 13:52, Dietmar Eggemann wrote: > > On 2/8/19 11:05 AM, Patrick Bellasi wrote: [...] > > > + * within each bucket the exact "requested" clamp value whenever all > > > tasks > > > + * RUNNABLE in that bucket require the same clamp. > > > + */ >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 14:01, Suren Baghdasaryan wrote: > On Wed, Mar 13, 2019 at 8:15 AM Patrick Bellasi > wrote: > > > > On 12-Mar 13:52, Dietmar Eggemann wrote: > > > On 2/8/19 11:05 AM, Patrick Bellasi wrote: [...] > > > > +static inline unsigned int uclamp_bucket_value(unsigned int > > > >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 14:32, Suren Baghdasaryan wrote: > On Fri, Feb 8, 2019 at 2:06 AM Patrick Bellasi > wrote: > > > > Utilization clamping allows to clamp the CPU's utilization within a > > [util_min, util_max] range, depending on the set of RUNNABLE tasks on > > that CPU. Each task references two "clamp

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Peter Zijlstra
On Thu, Mar 14, 2019 at 12:13:15PM +, Patrick Bellasi wrote: > > I'd be most impressed if they pull this off. Check the generated code > > and see I suppose :-) > > On x86 the code generated looks exactly the same: > >https://godbolt.org/z/PjmA7k Argh, they do mult by inverse to avoid

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Peter Zijlstra
On Thu, Mar 14, 2019 at 11:03:30AM +, Patrick Bellasi wrote: > void uclamp_rq_dec_id(struct rq *rq, int clamp_id, int bucket_id) { > if (__builtin_expect(!!(rq->uclamp[clamp_id].bucket[bucket_id].tasks), 1)) > return; > rq->uclamp[clamp_id].bucket[bucket_id].tasks--; > } >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 14:23, Suren Baghdasaryan wrote: > On Wed, Mar 13, 2019 at 6:52 AM Peter Zijlstra wrote: > > > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > +/* > > > + * When a task is enqueued on a rq, the clamp bucket currently defined > > > by the > > > + * task's

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 14:08, Suren Baghdasaryan wrote: > On Wed, Mar 13, 2019 at 12:46 PM Peter Zijlstra wrote: > > > > On Wed, Mar 13, 2019 at 03:23:59PM +, Patrick Bellasi wrote: > > > On 13-Mar 15:09, Peter Zijlstra wrote: > > > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 20:48, Peter Zijlstra wrote: > On Wed, Mar 13, 2019 at 04:12:29PM +, Patrick Bellasi wrote: > > On 13-Mar 14:40, Peter Zijlstra wrote: > > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > > +static inline unsigned int uclamp_bucket_id(unsigned int clamp_value)

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 20:46, Peter Zijlstra wrote: > On Wed, Mar 13, 2019 at 03:23:59PM +, Patrick Bellasi wrote: > > On 13-Mar 15:09, Peter Zijlstra wrote: > > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > > > +static inline void uclamp_rq_update(struct rq *rq, unsigned int >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 20:39, Peter Zijlstra wrote: > On Wed, Mar 13, 2019 at 03:59:54PM +, Patrick Bellasi wrote: > > On 13-Mar 14:52, Peter Zijlstra wrote: > > > Because of backetization, we potentially end up tracking tasks with > > different requested clamp values in the same bucket. > > > > For

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-14 Thread Patrick Bellasi
On 13-Mar 20:30, Peter Zijlstra wrote: > On Wed, Mar 13, 2019 at 03:59:54PM +, Patrick Bellasi wrote: > > On 13-Mar 14:52, Peter Zijlstra wrote: > > > > +static inline void uclamp_rq_dec_id(struct task_struct *p, struct rq > > > > *rq, > > > > + unsigned int

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Suren Baghdasaryan
On Fri, Feb 8, 2019 at 2:06 AM Patrick Bellasi wrote: > > Utilization clamping allows to clamp the CPU's utilization within a > [util_min, util_max] range, depending on the set of RUNNABLE tasks on > that CPU. Each task references two "clamp buckets" defining its minimum > and maximum

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Suren Baghdasaryan
On Wed, Mar 13, 2019 at 6:52 AM Peter Zijlstra wrote: > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > +/* > > + * When a task is enqueued on a rq, the clamp bucket currently defined by > > the > > + * task's uclamp::bucket_id is reference counted on that rq. This also >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Suren Baghdasaryan
On Wed, Mar 13, 2019 at 12:46 PM Peter Zijlstra wrote: > > On Wed, Mar 13, 2019 at 03:23:59PM +, Patrick Bellasi wrote: > > On 13-Mar 15:09, Peter Zijlstra wrote: > > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > > > +static inline void uclamp_rq_update(struct rq

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Suren Baghdasaryan
On Wed, Mar 13, 2019 at 8:15 AM Patrick Bellasi wrote: > > On 12-Mar 13:52, Dietmar Eggemann wrote: > > On 2/8/19 11:05 AM, Patrick Bellasi wrote: > > > > [...] > > > > > +config UCLAMP_BUCKETS_COUNT > > > + int "Number of supported utilization clamp buckets" > > > + range 5 20 > > > +

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Wed, Mar 13, 2019 at 04:12:29PM +, Patrick Bellasi wrote: > On 13-Mar 14:40, Peter Zijlstra wrote: > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > +static inline unsigned int uclamp_bucket_id(unsigned int clamp_value) > > > +{ > > > + return clamp_value /

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Wed, Mar 13, 2019 at 03:23:59PM +, Patrick Bellasi wrote: > On 13-Mar 15:09, Peter Zijlstra wrote: > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > +static inline void uclamp_rq_update(struct rq *rq, unsigned int clamp_id) > > > +{ > > > + struct uclamp_bucket

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Wed, Mar 13, 2019 at 03:59:54PM +, Patrick Bellasi wrote: > On 13-Mar 14:52, Peter Zijlstra wrote: > Because of backetization, we potentially end up tracking tasks with > different requested clamp values in the same bucket. > > For example, with 20% bucket size, we can have: > Task1:

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Wed, Mar 13, 2019 at 03:59:54PM +, Patrick Bellasi wrote: > On 13-Mar 14:52, Peter Zijlstra wrote: > > > +static inline void uclamp_rq_dec_id(struct task_struct *p, struct rq *rq, > > > + unsigned int clamp_id) > > > +{ > > > + unsigned int bucket_id =

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 13-Mar 18:22, Peter Zijlstra wrote: > On Wed, Mar 13, 2019 at 04:12:29PM +, Patrick Bellasi wrote: > > Yes, the for looks better, but perhaps like that: > > > > unsigned int bucket_id = UCLAMP_BUCKETS; > > > > /* > > * Both min and max clamps are MAX aggregated, thus the

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Wed, Mar 13, 2019 at 04:12:29PM +, Patrick Bellasi wrote: > Yes, the for looks better, but perhaps like that: > > unsigned int bucket_id = UCLAMP_BUCKETS; > > /* >* Both min and max clamps are MAX aggregated, thus the topmost >* bucket with some tasks defines

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 13-Mar 14:40, Peter Zijlstra wrote: > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > +static inline unsigned int uclamp_bucket_id(unsigned int clamp_value) > > +{ > > + return clamp_value / UCLAMP_BUCKET_DELTA; > > +} > > + > > +static inline unsigned int

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 13-Mar 14:52, Peter Zijlstra wrote: > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > +/* > > + * When a task is enqueued on a rq, the clamp bucket currently defined by > > the > > + * task's uclamp::bucket_id is reference counted on that rq. This also > > + * immediately

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 13-Mar 15:06, Peter Zijlstra wrote: > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > +static void __init init_uclamp(void) > > +{ > > + unsigned int clamp_id; > > + int cpu; > > + > > + for_each_possible_cpu(cpu) > > + memset(_rq(cpu)->uclamp, 0,

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 13-Mar 15:09, Peter Zijlstra wrote: > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > +static inline unsigned int uclamp_none(int clamp_id) > > +{ > > + if (clamp_id == UCLAMP_MIN) > > + return 0; > > + return SCHED_CAPACITY_SCALE; > > +} > > + > > +static

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 12-Mar 13:52, Dietmar Eggemann wrote: > On 2/8/19 11:05 AM, Patrick Bellasi wrote: > > [...] > > > +config UCLAMP_BUCKETS_COUNT > > + int "Number of supported utilization clamp buckets" > > + range 5 20 > > + default 5 > > + depends on UCLAMP_TASK > > + help > > + Defines the

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > +static inline unsigned int uclamp_none(int clamp_id) > +{ > + if (clamp_id == UCLAMP_MIN) > + return 0; > + return SCHED_CAPACITY_SCALE; > +} > + > +static inline void uclamp_rq_update(struct rq *rq, unsigned

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > +static void __init init_uclamp(void) > +{ > + unsigned int clamp_id; > + int cpu; > + > + for_each_possible_cpu(cpu) > + memset(_rq(cpu)->uclamp, 0, sizeof(struct uclamp_rq)); > + Is that really needed?

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > +/* > + * When a task is enqueued on a rq, the clamp bucket currently defined by the > + * task's uclamp::bucket_id is reference counted on that rq. This also > + * immediately updates the rq's clamp value if required. > + * > + *

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > +static inline unsigned int uclamp_bucket_id(unsigned int clamp_value) > +{ > + return clamp_value / UCLAMP_BUCKET_DELTA; > +} > + > +static inline unsigned int uclamp_bucket_value(unsigned int clamp_value) > +{ > + return

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Patrick Bellasi
On 13-Mar 09:19, Peter Zijlstra wrote: > On Tue, Mar 12, 2019 at 03:50:43PM +, Patrick Bellasi wrote: > > On 12-Mar 16:20, Peter Zijlstra wrote: > > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > > +/* Integer ceil-rounded range for each bucket */ > >

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-13 Thread Peter Zijlstra
On Tue, Mar 12, 2019 at 03:50:43PM +, Patrick Bellasi wrote: > On 12-Mar 16:20, Peter Zijlstra wrote: > > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > > +/* Integer ceil-rounded range for each bucket */ ^^^ > > > +#define

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-12 Thread Patrick Bellasi
On 12-Mar 16:20, Peter Zijlstra wrote: > On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > > +/* Integer ceil-rounded range for each bucket */ > > +#define UCLAMP_BUCKET_DELTA ((SCHED_CAPACITY_SCALE / UCLAMP_BUCKETS) + 1) > > Uhm, should that not me ((x+y-1)/y), aka.

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-12 Thread Peter Zijlstra
On Fri, Feb 08, 2019 at 10:05:40AM +, Patrick Bellasi wrote: > +/* Integer ceil-rounded range for each bucket */ > +#define UCLAMP_BUCKET_DELTA ((SCHED_CAPACITY_SCALE / UCLAMP_BUCKETS) + 1) Uhm, should that not me ((x+y-1)/y), aka. DIV_ROUND_UP(x,y) ? The above would give 4 for 9/3, which is

Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-03-12 Thread Dietmar Eggemann
On 2/8/19 11:05 AM, Patrick Bellasi wrote: [...] +config UCLAMP_BUCKETS_COUNT + int "Number of supported utilization clamp buckets" + range 5 20 + default 5 + depends on UCLAMP_TASK + help + Defines the number of clamp buckets to use. The range of each

[PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting

2019-02-08 Thread Patrick Bellasi
Utilization clamping allows to clamp the CPU's utilization within a [util_min, util_max] range, depending on the set of RUNNABLE tasks on that CPU. Each task references two "clamp buckets" defining its minimum and maximum (util_{min,max}) utilization "clamp values". A CPU's clamp bucket is active