Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp489118imu; Fri, 25 Jan 2019 05:58:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN6vroShfeh0br6OEckZWVPB1/eIft9sgIYlB/1CRjRWVhQoegrPHCgkPee+L4f+gteg3e/x X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr10957057plq.195.1548424719375; Fri, 25 Jan 2019 05:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548424719; cv=none; d=google.com; s=arc-20160816; b=JoQXAnKn49uXw3ScUqmSyRv2DmmEwczuiB9li+oMS1em0RwtW3434nP+wUm9zMXeYl 9xZoyqgbmQ/437McZeqO5x/N5XbUX6R/ARzFUzNTmCEv1Xxcsc9fsYHR3+FJJphnjktG UGdoJNrqsggMeYbo3YlEeGTrd7Db8fc8uFu/IaqC5FaQPRl5q78FaGl/NnrwCVcMj4DS UuX9PFg+kEEl9VW5CKDcM+6b2fjcYI8O9JF7+n5fg23QMytZZvmWdy+cpckLDQAr378D HcnKl9BpKhXRQaMB4CZoWygPD4CFwSgABl7vgrheazH/hRe1wowgZk7nbB7ASjRCZgrn 652w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=isKIZLHvDy4G7/JJd0SWz3JorDTm2gi1KhTLX9kC+50=; b=pF/sZ3qpeQvnVKS6AKMipYfgqZIMTqU4m+joXsW5/dgcf35DaZkZViJZE0HrfcnZkb 9Z+2UIJw3fQzNOM6mNa5QbXBsryNueDIlulBZKYioZwJvKd6H0dozWLPSroshh7IbTYZ rmnoUgF7UrSPMY1LGvV3RaJxcRt0IlI8PU0oewOKTsC8/+5LoRuI30Qc1NOsvd9OJ7yy 716MchpeSkvoBDoDExaq4n38QNDDDNNh4b25PJvZj5bNSXkDdPOvsancHr4iEwYXFUmM MB/AcDHoRZfwr3KTSXNODbUmrd+FXqaT6NTcuQ7n2Xnz0qzpeJUEdD9KcMmXL3wu+vv3 WNlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=ae9Ce5Hf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si25213095pgn.57.2019.01.25.05.58.23; Fri, 25 Jan 2019 05:58:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=ae9Ce5Hf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbfAYN4u (ORCPT + 99 others); Fri, 25 Jan 2019 08:56:50 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40999 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbfAYN4u (ORCPT ); Fri, 25 Jan 2019 08:56:50 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so10384042wrs.8 for ; Fri, 25 Jan 2019 05:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=isKIZLHvDy4G7/JJd0SWz3JorDTm2gi1KhTLX9kC+50=; b=ae9Ce5HfcC42GyeyRAtkqlER6uZQRYfuTBWKl17hZwU3ygeEuuN6SOIR9MhwuDjiHm Qy+ekSlS06P2HWILFZIWmBc5iQT5QVGqL7VRoXFsVnH9bCEyZ6lbiIbvziWzDA+tyK7W olYPoGA9nUwxgSIVaJ7DoxnoWx2fRGyJ9jsfsdJUwzYpjPFepK2yKSJ+cVGRow+TcCIC rieIvr2fqEP/+N0pTNAziOeVa2U/yPytfLnz2pbnWQlxrXM2ifwrK2B2dir9vL/oiXLg hZuih3nUNKEilCaRjP3G72nYWi5nc9JBBH1qC94hg5L9Gi38pR5Lb8dlfiB+Ba6HKKxw etIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=isKIZLHvDy4G7/JJd0SWz3JorDTm2gi1KhTLX9kC+50=; b=lMvsHlCGr8jTqFn4LU5kYQtnTJCjFZynLhAyDeb4hfL+QrWd5yamSJGg5eb2to/CSz NjKINqnYaXgtAayNgySjqgyjK5ShqNUe5jUIUGmb4DwWD+rhui+iqD3cqAMs6vbCclIV pvY+xBQjDQItXsi6oInw5x1NDZKjj9QIwXsoie/UDi3ZIBOLRPa1JBsP3hWgYSlMmgJB r2Qd7aGmf5Bwavm18cxAr+Z4Aozwr+QV21pBTCNUPpyLcIzTCPUlPqQcLpjfygyTqAhd Qt95QBJRZcGuZWQrXtls/tOMoZ8lXb+oNpOKyw9YBEO7cTZo6LKB9RtpoPutbSgohuYf xVkw== X-Gm-Message-State: AJcUukd7uqnvc//Sk8FWkfEqSBExODg9khvolfakAOAvNYzHBd37UUeJ lI203Nl9/ZWjkUJ0+jNM9vNMhg== X-Received: by 2002:adf:f091:: with SMTP id n17mr11537008wro.292.1548424608755; Fri, 25 Jan 2019 05:56:48 -0800 (PST) Received: from google.com ([2a00:79e0:d:203:9bb:78dc:3222:caef]) by smtp.gmail.com with ESMTPSA id p6sm135680949wrx.50.2019.01.25.05.56.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 25 Jan 2019 05:56:48 -0800 (PST) Date: Fri, 25 Jan 2019 13:56:46 +0000 From: Alessio Balsini To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v6 01/16] sched/core: Allow sched_setattr() to use the current policy Message-ID: <20190125135646.j4j2onitam4mwvcw@google.com> References: <20190115101513.2822-1-patrick.bellasi@arm.com> <20190115101513.2822-2-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115101513.2822-2-patrick.bellasi@arm.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Patrick, What do you think about the following minor changes: On Tue, Jan 15, 2019 at 10:14:58AM +0000, Patrick Bellasi wrote: > /* SCHED_ISO: reserved but not implemented yet */ > #define SCHED_IDLE 5 > #define SCHED_DEADLINE 6 > +/* Must be the last entry: used to sanity check attr.policy values */ I would remove this comment: - the meaning of SCHED_POLICY_MAX is evident, and - should we hint on how the value is used? That comment will be removed the next time SCHED_POLICY_MAX is used for something else. This is what should also happen to the comment of SETPARAM_POLICY: now sched_setparam() is no more the only code path accessing SETPARAM_POLICY. > +#define SCHED_POLICY_MAX 7 +#define SCHED_POLICY_MAX SCHED_DEADLINE This would make it compliant with the definition of MAX. > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -4560,8 +4560,17 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr, > if (retval) > return retval; > > - if ((int)attr.sched_policy < 0) > + /* > + * A valid policy is always required from userspace, unless > + * SCHED_FLAG_KEEP_POLICY is set and the current policy > + * is enforced for this call. > + */ > + if (attr.sched_policy >= SCHED_POLICY_MAX && + if (attr.sched_policy > SCHED_POLICY_MAX && In line with the previous update. > + !(attr.sched_flags & SCHED_FLAG_KEEP_POLICY)) { > return -EINVAL; Thanks, Alessio