Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp555191pxb; Wed, 11 Nov 2020 10:09:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzf8k3IBQbPfRJ1BJd9YnJt9mz6BkdaFlVH9+4LskEe1rJB8wcEQnYRPoJ5E+a9iofV0FJ0 X-Received: by 2002:a05:6402:22ab:: with SMTP id cx11mr772035edb.98.1605118162275; Wed, 11 Nov 2020 10:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605118162; cv=none; d=google.com; s=arc-20160816; b=vyDCEM4OLH01h54Xhbekd+4P8ocPABgfLfMdVfrlnHuSMv1BK8zavgM90NkxnTf298 9ApCH5S2UIPLydGLg9FUH85gy+sIJPg0EcDOE0U9wMIVcbTocbYXnePu/VXdVt007jA+ beG2Jfj+0HQzWHVto3zfwZRI+hnjhdeaEywXuXotZTEgHPxbq5N/B2EnNMEMJBW8E8s0 OU8Ayf55s02XBxsz65LG2vOQlMRZV0d1QOM69FJheSm5DJCWbG+JUnBt6KhBFgVxIdrh 7ZOUhAy05wt7qoZB0LMraMcgM7LCAEUxZYgv5EYfYumEYWh7/ATNnqXXqAHp/Du6yi// 1TsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=P16FHAb3A4K3ENj/hrLU4GXYLbiPalcs86Yi2WMI2eY=; b=tTvsEKxzUcZKmvHi0YSebx8FSf2Y4R5PzoFHlAaABGHAi3D+yS1qR9PvOOEWsTo1rN wG0hD2tBdMpu+N+xUyLLJV9+EbOn3JtxYfgFa3ls/rvFFaM/GauJL9qa2+STo1Zyzdqq 3a7knmYuaAnGGS2e+mXr9WvgW5k2d1e/qa0NNQGp5gIoPeMZwOdcU3UNhfn7KHb5ak5T 0/qzojdCfyOKQrGax1+qzBez7hq1nYalqWP2w+CCh9j3pRN0d1jc/5Xu+4+CS+FU5zBd XB1sPTeBQaVrmdUj5ce3D/7H9Trc8V2y2LBJ/S5UtWPZnZRiLUqhdi2/xqgqWLzRTUly ceUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KSrP7M7u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m30si2031518edj.103.2020.11.11.10.08.57; Wed, 11 Nov 2020 10:09:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KSrP7M7u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726104AbgKKSFI (ORCPT + 99 others); Wed, 11 Nov 2020 13:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbgKKSFH (ORCPT ); Wed, 11 Nov 2020 13:05:07 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6315C0613D1 for ; Wed, 11 Nov 2020 10:05:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=P16FHAb3A4K3ENj/hrLU4GXYLbiPalcs86Yi2WMI2eY=; b=KSrP7M7uBk+P2PqH5o5SAgPiBP kLPtQxCkWxr0r/ShpK1GZzfDdbwgPsPG+wO1/R6flMpPUNieRLFZMt0Uz62ZNWTLyKoNYV6GmJtGZ 1bjTJ4Cn4JR/xwsCmpYH/Tbu99u50ryBHpGCogWfiKQS5PeG73eE+GW6rt8KyPp4O0NwKLFhThfqx wEtSs1fy9YoWu7H/wCAwSBtqS4aiRuflJ2OOIbuqbTKniEWCkDS89OdwEKNGvmwtiZ8PCIFph32kK 9FJXQkQzTBgeHiLeROYsTUwp0dyJ02Pm9weS7Jt9c9vik3ecsL4vVa2cIfGBfOenqaD8HVZudhmOJ UijpnExA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcuU6-0007By-6L; Wed, 11 Nov 2020 18:04:42 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9739D301E02; Wed, 11 Nov 2020 19:04:41 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7D31F20A2A303; Wed, 11 Nov 2020 19:04:41 +0100 (CET) Date: Wed, 11 Nov 2020 19:04:41 +0100 From: Peter Zijlstra To: Dietmar Eggemann Cc: Yun Hsiang , linux-kernel@vger.kernel.org, qais.yousef@arm.com, patrick.bellasi@matbug.net, kernel test robot Subject: Re: [PATCH v5 1/1] sched/uclamp: add SCHED_FLAG_UTIL_CLAMP_RESET flag to reset uclamp Message-ID: <20201111180441.GJ2628@hirez.programming.kicks-ass.net> References: <20201103023756.1012088-1-hsiang023167@gmail.com> <20201110122108.GG2594@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 11, 2020 at 06:41:07PM +0100, Dietmar Eggemann wrote: > diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h > index c852153ddb0d..b9165f17dddc 100644 > --- a/include/uapi/linux/sched/types.h > +++ b/include/uapi/linux/sched/types.h > @@ -115,8 +115,8 @@ struct sched_attr { > __u64 sched_period; > > /* Utilization hints */ > - __u32 sched_util_min; > - __u32 sched_util_max; > + __s32 sched_util_min; > + __s32 sched_util_max; So that's UAPI, not sure we can change the type here. > }; > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 3dc415f58bd7..caaa2a8434b9 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1413,17 +1413,24 @@ int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, > static int uclamp_validate(struct task_struct *p, > const struct sched_attr *attr) > { > - unsigned int lower_bound = p->uclamp_req[UCLAMP_MIN].value; > - unsigned int upper_bound = p->uclamp_req[UCLAMP_MAX].value; > + int util_min = p->uclamp_req[UCLAMP_MIN].value; > + int util_max = p->uclamp_req[UCLAMP_MAX].value; > > - if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) > - lower_bound = attr->sched_util_min; > - if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) > - upper_bound = attr->sched_util_max; > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) { > + util_min = attr->sched_util_min; > > - if (lower_bound > upper_bound) > - return -EINVAL; > - if (upper_bound > SCHED_CAPACITY_SCALE) > + if (util_min < -1 || util_min > SCHED_CAPACITY_SCALE) > + return -EINVAL; > + } > + > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) { > + util_max = attr->sched_util_max; > + > + if (util_max < -1 || util_max > SCHED_CAPACITY_SCALE) > + return -EINVAL; > + } Luckily we can write that range as a single branch like: if (util_{min,max} + 1 > SCHED_CAPACITY_SCALE+1) which assumes u32 :-) > + > + if (util_min != -1 && util_max != -1 && util_min > util_max) > return -EINVAL; I think that will compile as is, otherwise write it like ~0u, which is the same bit pattern.