Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3390428ybd; Tue, 25 Jun 2019 01:35:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPbTTxDBJdp/jeJPk5JKXL5WjTfC2SNAQVudSxZWHLXJsPWlSLhxKMOoRgeRwt+a5omFgc X-Received: by 2002:a63:5a4b:: with SMTP id k11mr20226551pgm.143.1561451721892; Tue, 25 Jun 2019 01:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561451721; cv=none; d=google.com; s=arc-20160816; b=bx9i1tq+Ioa0TJgMBXl9rEeGUVpSGnZVnu590kn3wKAzUR5uFjHXlBz7y/QHBMJpmf CiLfzpcnVSw1WJsQ+gUajC3tBsH/kGH+Zc1umfUtm3u9kTOisBn1lA+GIB2pPPoAPd3b Ot61jZfvw3lgrjIo2jS0eNq6lLb0FU9w7zTcgvJ9yq6Rqa3bJyxvm9i2CsbliQJQM+tK VzQnBd3AXd4FFfKYPWNkVIJwBxHqo0A7SZtbtm6pSvNbwyqJ1c3T8BkVJtGe+cRp3uyl vltOecNjgTem/jl+yC+sCIYKfyyBRV/abY3/84s39X1OLHmSW/WGfpCQUvWf/Zddfn1G cq6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=aFiAewJnhCZARhf+ZqoTzp3Hdge67LZiaXUFhLNjVq4=; b=u/cLz5YiRJE6zMZPI5j7+CH3wZIQDgGzFIyqksPQffeC7yfVdX0OcCIBlY0knWZACW 8HnblTgeh+i+XZgzPAmyXGHq/08qav86MU4XeAdwBDgrdjndiJn6w2u4SQciQ3/lo1Zp tBgKZu0aMZcxRqTwcGcxC9XtSue+wa1sw1M0HoUNo0XrDlkzNQXCybieuUc0jKzkkn3M Mh+1GsZzz+jqg1UodGbE18XyXpjzwn3LlO5uuP5HP33n/OGuydDMCdrXg4jIK2XMrWuC BJNXWC2V7NCOxvXAGIrvMyQsnVqlZTzS+W4QR+UJnBMoIop2NZp3v7xo42ssZH1UGCsu c2JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=iaMHChIs; 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=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si12832986pla.22.2019.06.25.01.35.05; Tue, 25 Jun 2019 01:35:21 -0700 (PDT) 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=@zytor.com header.s=2019061801 header.b=iaMHChIs; 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=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728774AbfFYIdo (ORCPT + 99 others); Tue, 25 Jun 2019 04:33:44 -0400 Received: from terminus.zytor.com ([198.137.202.136]:48665 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfFYIdo (ORCPT ); Tue, 25 Jun 2019 04:33:44 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5P8WtfC3531147 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 25 Jun 2019 01:32:56 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5P8WtfC3531147 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561451577; bh=aFiAewJnhCZARhf+ZqoTzp3Hdge67LZiaXUFhLNjVq4=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=iaMHChIsQGB/J9h5j1v4Arkc6W0GYfdMPEmvS10ZxIPTMkDPgRCxaljU2UY2Uu2RB LRgKtFJM6fMnGl5LVzuGqUaSWUwEwpQx34Tber01SQEdI7hirmM0shjcvIWpA/Oz9c Kvl+gGXBDtEKOrws0ay3ama+cRNUjwOfZ3wH1GZ0rT0AlUboQTrY8lGKJU83W8H8UO zWjH3Nk1j8WSMOEeyYNSMt4tEcLnUBn4qEi8BHt3RKu8GwcudBJsasng+vKnmp/w+x ivNVD/t9D9AsFfV+eu9sxd058ZNXCMwW6FIsBB0x2JllNykp1WrNVqF84JgLIKB4Kq s2gUuKaH2gqyQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5P8WtUA3531144; Tue, 25 Jun 2019 01:32:55 -0700 Date: Tue, 25 Jun 2019 01:32:55 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Patrick Bellasi Message-ID: Cc: viresh.kumar@linaro.org, balsini@android.com, pjt@google.com, tkjos@google.com, tj@kernel.org, patrick.bellasi@arm.com, rafael.j.wysocki@intel.com, joelaf@google.com, mingo@kernel.org, vincent.guittot@linaro.org, surenb@google.com, dietmar.eggemann@arm.com, smuckle@google.com, torvalds@linux-foundation.org, tglx@linutronix.de, hpa@zytor.com, morten.rasmussen@arm.com, peterz@infradead.org, linux-kernel@vger.kernel.org, quentin.perret@arm.com, juri.lelli@redhat.com Reply-To: balsini@android.com, viresh.kumar@linaro.org, patrick.bellasi@arm.com, tkjos@google.com, tj@kernel.org, pjt@google.com, mingo@kernel.org, joelaf@google.com, rafael.j.wysocki@intel.com, tglx@linutronix.de, torvalds@linux-foundation.org, smuckle@google.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, surenb@google.com, hpa@zytor.com, peterz@infradead.org, morten.rasmussen@arm.com, linux-kernel@vger.kernel.org, juri.lelli@redhat.com, quentin.perret@arm.com In-Reply-To: <20190621084217.8167-6-patrick.bellasi@arm.com> References: <20190621084217.8167-6-patrick.bellasi@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/core: Allow sched_setattr() to use the current policy Git-Commit-ID: 1d6362fa0cfc8c7b243fa92924429d826599e691 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1d6362fa0cfc8c7b243fa92924429d826599e691 Gitweb: https://git.kernel.org/tip/1d6362fa0cfc8c7b243fa92924429d826599e691 Author: Patrick Bellasi AuthorDate: Fri, 21 Jun 2019 09:42:06 +0100 Committer: Ingo Molnar CommitDate: Mon, 24 Jun 2019 19:23:46 +0200 sched/core: Allow sched_setattr() to use the current policy The sched_setattr() syscall mandates that a policy is always specified. This requires to always know which policy a task will have when attributes are configured and this makes it impossible to add more generic task attributes valid across different scheduling policies. Reading the policy before setting generic tasks attributes is racy since we cannot be sure it is not changed concurrently. Introduce the required support to change generic task attributes without affecting the current task policy. This is done by adding an attribute flag (SCHED_FLAG_KEEP_POLICY) to enforce the usage of the current policy. Add support for the SETPARAM_POLICY policy, which is already used by the sched_setparam() POSIX syscall, to the sched_setattr() non-POSIX syscall. Signed-off-by: Patrick Bellasi Signed-off-by: Peter Zijlstra (Intel) Cc: Alessio Balsini Cc: Dietmar Eggemann Cc: Joel Fernandes Cc: Juri Lelli Cc: Linus Torvalds Cc: Morten Rasmussen Cc: Paul Turner Cc: Peter Zijlstra Cc: Quentin Perret Cc: Rafael J . Wysocki Cc: Steve Muckle Cc: Suren Baghdasaryan Cc: Tejun Heo Cc: Thomas Gleixner Cc: Todd Kjos Cc: Vincent Guittot Cc: Viresh Kumar Link: https://lkml.kernel.org/r/20190621084217.8167-6-patrick.bellasi@arm.com Signed-off-by: Ingo Molnar --- include/uapi/linux/sched.h | 4 +++- kernel/sched/core.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h index ed4ee170bee2..58b2368d3634 100644 --- a/include/uapi/linux/sched.h +++ b/include/uapi/linux/sched.h @@ -51,9 +51,11 @@ #define SCHED_FLAG_RESET_ON_FORK 0x01 #define SCHED_FLAG_RECLAIM 0x02 #define SCHED_FLAG_DL_OVERRUN 0x04 +#define SCHED_FLAG_KEEP_POLICY 0x08 #define SCHED_FLAG_ALL (SCHED_FLAG_RESET_ON_FORK | \ SCHED_FLAG_RECLAIM | \ - SCHED_FLAG_DL_OVERRUN) + SCHED_FLAG_DL_OVERRUN | \ + SCHED_FLAG_KEEP_POLICY) #endif /* _UAPI_LINUX_SCHED_H */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b74de86b68c7..6d519f3f9789 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4897,6 +4897,8 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr, if ((int)attr.sched_policy < 0) return -EINVAL; + if (attr.sched_flags & SCHED_FLAG_KEEP_POLICY) + attr.sched_policy = SETPARAM_POLICY; rcu_read_lock(); retval = -ESRCH;