Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp489051ybl; Fri, 30 Aug 2019 02:51:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyG/JTWVRj00EEGqujYKOOy4GJpS+NXBi4YS163Sa6/4PNu4NnBPtgpBCnxzoamBreOlYVr X-Received: by 2002:a17:902:3281:: with SMTP id z1mr14687149plb.302.1567158665074; Fri, 30 Aug 2019 02:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567158665; cv=none; d=google.com; s=arc-20160816; b=hyQ5RgyxaLO1JEVooBPzSbzkpnxG+pOaf1TBM8MT3/54FMz6kIpkgyn837O74ClxNI Whns637jHyWpmG/g7+ZTy7D79g+JNlY6w7xwVauOt8uv2ElljNGUIoyZ/rAIa239Q7qb 4rFLptHRjMpqjRSgXawq6hNo7eTb9vq9XlmBkdKBt1W1rrR0oUudWRcCVzUqEeW867ZS eWXq4Ee4PYP68d7c/GvDOi//ranvuRp3tnR5CJnZEOqeqJgael4aJjvlkZ/PjTv46Vyh f+jptIb5J0v8FqVMEVFwB2FJxRbO06uUi1uqtdCpTTAR+6/2xt+ogXvIa8Oro7HG/adV Ai+g== 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=PKLkBBrwktzoIAL7/V9IuDoU+f4BVjGqlqVhW17S6o4=; b=QASqiQIPeg2tVpthAYqiM9nzSeNR/zCVOZ+jcVGq3gC90dHFbEGRyOXs8vx0sLf0Yt 2uXxD2xjeI4TBNg5+I27HDvt1wpPcCq5vTJ6xL8227nTNrQfS6kHUFWWfgiKOM4Jgvzy sRCbfeviQmHC1wieqiP3j4JZiYrKeR40tcZpvDysnfGZbe5xxk0CpCsrV7z8Ssu/hUTA 9edaCQ9BDriPwpuvv1cFiCc2Xcr5DN2WJO7D1fFSOGOa4X3PgAGeyaD92klnNDIJlISe YWtUHSBQ/sstUYjKFLtWUpVbLnUv8T6GUiTDDSlaN+qR6aQCskfIbsEq0UoKs6oN+7Nw RSKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=As1pAFvi; 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 o33si4551276pld.32.2019.08.30.02.50.49; Fri, 30 Aug 2019 02:51:05 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=As1pAFvi; 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 S1727844AbfH3Jsp (ORCPT + 99 others); Fri, 30 Aug 2019 05:48:45 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49438 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbfH3Jsp (ORCPT ); Fri, 30 Aug 2019 05:48:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PKLkBBrwktzoIAL7/V9IuDoU+f4BVjGqlqVhW17S6o4=; b=As1pAFviZ2UU9B0+0SzNSBCYv 9+oue+ii5LBUF5/NUqfkAyYITd/SJz/5wQ2PYc5kOQtywSz1Q0SrjuAlUC0TlY60GmLqJWrXVoSY/ LRYhMgyEKpN2IP8uadwOqPYt6p0KIG6BNS2+DnjF0a0Y60VchqV0DXrWYMvpWyibEpAXcG5QrzM3g EA9J74XOel0mtM2fyTPtoOMwMoNrc/TfPnjMy+tu6ZRwy1wQuth2hdDmd5KYjje0uko0UybFJMgEa dCMIPX2o2AVt/F4b4HIwAam68PB09LKYH8l7L13plZRYYpSw2bEP7tKKT712sNnreNmk1/2Sl8lQr U6kwSbDpg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i3dWG-0000vT-3f; Fri, 30 Aug 2019 09:48:36 +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 D56F7300489; Fri, 30 Aug 2019 11:47:59 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3FB8529AD3511; Fri, 30 Aug 2019 11:48:34 +0200 (CEST) Date: Fri, 30 Aug 2019 11:48:34 +0200 From: Peter Zijlstra To: Patrick Bellasi 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 Message-ID: <20190830094834.GB2369@hirez.programming.kicks-ass.net> References: <20190822132811.31294-1-patrick.bellasi@arm.com> <20190822132811.31294-6-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190822132811.31294-6-patrick.bellasi@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + /* > + * 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? ;-) > + > + task_rq_unlock(rq, p, &rf); > +}