Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp221086ybe; Mon, 2 Sep 2019 00:00:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8qIfcVJQBuEu/vyOyrIY0QPEyCYAYHtCzFEfQX99BqtSgePQERqXyk18SeR6yO4C54AxR X-Received: by 2002:aa7:8bc2:: with SMTP id s2mr10248133pfd.13.1567407604995; Mon, 02 Sep 2019 00:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567407604; cv=none; d=google.com; s=arc-20160816; b=pvuiVdtOPVWu4IYw3fqS9DR9gDrSeKiH2/HeIfqu78aFz9N0AVBOHGVmCOffhHVcZ5 rrwGMsav4u/JjZcEksEEE0K5bBMadLcQnC7HfSyE0XRT53S6QHucijzD2IErOzKugKjU C3qdfZobuVNAkdde6gNtj9yO70+cEd/Ic74m/ftI3TP0TOktOs8Nmdvz/0ea20dLou7O BnmlaUeBqONHhVEPbW+Wdx/VSfRTUg+VQ1dDE9L8AvCJPu2U+HuCh+yo4KK2blj7gj8r rmcQI1uLwA2+pqK51xSDMNCT/dufREzs7GGk75QPY24LNDusOT3XbBVkNgu4Ou+OlCKb y20g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=eK+IXEqNp7iCI9AWhqRTvcGFy5FfRRsXgv6hVTGB6hw=; b=w4M5iztTIJj9AhIngrzyugqf0XXkSaGmwY6VGoGELJXA/gfq4IJ9c4v1W3bJSFFXEd x+XNFyIjPxvYY0EaXR9sKmTm6EAn9ALwQjmHcHS/7ueY9A2ymZ1WtnzLMfaTjyYp1LXM 6EU3lgTN7GGqS55b4QYWkDELrd3lOJeJ9tuq8b+8YeglNmYJZEU9XtylfwA+U/IGWBxT 9soznB1eYomjbQ79Jd23tCbc7JBiysGx6pfJeqlr4w0mv3o9QDe0FKExCUQUWIqRFdTU n1AiaYMd+8qinET4i2QtDs3c1JqMbk4nzE9ZM42FK5gXWnBIhNZFKBv5+kmoJuN6NS68 S3sg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si812087pls.164.2019.09.01.23.59.49; Mon, 02 Sep 2019 00:00:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729528AbfIBGov (ORCPT + 99 others); Mon, 2 Sep 2019 02:44:51 -0400 Received: from foss.arm.com ([217.140.110.172]:48920 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbfIBGov (ORCPT ); Mon, 2 Sep 2019 02:44:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66E80337; Sun, 1 Sep 2019 23:44:50 -0700 (PDT) Received: from darkstar (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 21E333F71A; Sun, 1 Sep 2019 23:47:08 -0700 (PDT) References: <20190822132811.31294-1-patrick.bellasi@arm.com> <20190822132811.31294-6-patrick.bellasi@arm.com> <20190830094834.GB2369@hirez.programming.kicks-ass.net> User-agent: mu4e 1.3.3; emacs 25.3.1 From: Patrick Bellasi To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, cgroups@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Michal Koutny , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan , Alessio Balsini Subject: Re: [PATCH v14 5/6] sched/core: uclamp: Update CPU's refcount on TG's clamp changes In-reply-to: <20190830094834.GB2369@hirez.programming.kicks-ass.net> Date: Mon, 02 Sep 2019 07:44:40 +0100 Message-ID: <87woernqnb.fsf@arm.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 30, 2019 at 09:48:34 +0000, Peter Zijlstra wrote... > On Thu, Aug 22, 2019 at 02:28:10PM +0100, Patrick Bellasi wrote: > >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 04fc161e4dbe..fc2dc86a2abe 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -1043,6 +1043,57 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) >> uclamp_rq_dec_id(rq, p, clamp_id); >> } >> >> +static inline void >> +uclamp_update_active(struct task_struct *p, unsigned int clamp_id) >> +{ >> + struct rq_flags rf; >> + struct rq *rq; >> + >> + /* >> + * Lock the task and the rq where the task is (or was) queued. >> + * >> + * We might lock the (previous) rq of a !RUNNABLE task, but that's the >> + * price to pay to safely serialize util_{min,max} updates with >> + * enqueues, dequeues and migration operations. >> + * This is the same locking schema used by __set_cpus_allowed_ptr(). >> + */ >> + rq = task_rq_lock(p, &rf); > > Since modifying cgroup parameters is priv only, this should be OK I > suppose. Priv can already DoS the system anyway. Are you referring to the possibility to DoS the scheduler by keep writing cgroup attributes? Because, in that case I think cgroup attributes could be written also by non priv users. It all depends on how they are mounted and permissions are set. Isn't it? Anyway, I'm not sure we can fix that here... and in principle we could have that DoS by setting CPUs affinities, which is user exposed. Isn't it? >> + /* >> + * Setting the clamp bucket is serialized by task_rq_lock(). >> + * If the task is not yet RUNNABLE and its task_struct is not >> + * affecting a valid clamp bucket, the next time it's enqueued, >> + * it will already see the updated clamp bucket value. >> + */ >> + if (!p->uclamp[clamp_id].active) >> + goto done; >> + >> + uclamp_rq_dec_id(rq, p, clamp_id); >> + uclamp_rq_inc_id(rq, p, clamp_id); >> + >> +done: > > I'm thinking that: > > if (p->uclamp[clamp_id].active) { > uclamp_rq_dec_id(rq, p, clamp_id); > uclamp_rq_inc_id(rq, p, clamp_id); > } > > was too obvious? ;-) Yep, right... I think there was some more code in prev versions but I forgot to get rid of that "goto" pattern after some change. >> + >> + task_rq_unlock(rq, p, &rf); >> +} Cheers, Patrick