From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick Bellasi Subject: Re: [PATCH v2 02/12] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups Date: Mon, 23 Jul 2018 14:36:15 +0100 Message-ID: <20180723133615.GB2683@e110439-lin> References: <20180716082906.6061-1-patrick.bellasi@arm.com> <20180716082906.6061-3-patrick.bellasi@arm.com> <20180720151156.GA31421@e110439-lin> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Suren Baghdasaryan Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle List-Id: linux-pm@vger.kernel.org On 20-Jul 17:25, Suren Baghdasaryan wrote: [...] > > ---8<--- > > > > /* Uclamp flags */ > > #define SCHED_FLAG_UTIL_CLAMP_STRICT 0x11 /* Roll-back on failure */ > > #define SCHED_FLAG_UTIL_CLAMP_MIN 0x12 /* Update util_min */ > > #define SCHED_FLAG_UTIL_CLAMP_MAX 0x14 /* Update util_max */ > > #define SCHED_FLAG_UTIL_CLAMP ( \ > > SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX) > > > > Having ability to update only min or only max this way might be indeed > very useful. > Instead of rolling back on failure I would suggest to check both > inputs first to make sure there won't be any error before updating. > This would remove the need for SCHED_FLAG_UTIL_CLAMP_STRICT (which I > think any user would want to set to 1 anyway). > Looks like uclamp_group_get() can fail only if uclamp_group_find() > fails to find a slot for uclamp_value or a free slot. So one way to do > this search before update is to call uclamp_group_find() for both > UCLAMP_MIN and UCLAMP_MAX beforehand and if they succeed then pass > obtained next_group_ids into uclamp_group_get() to avoid doing the > same search twice. This requires some refactoring of > uclamp_group_get() but I think the end result would be a cleaner and > more predictable solution. Yes, that sound possible... provided we check all the groups under the same uclamp_mutex, it should be possible to find the group_ids before actually increasing the refcount. ... will look into this for the next reposting. -- #include Patrick Bellasi