Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp254348ybe; Mon, 2 Sep 2019 00:41:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxAlMYYPjWRiyhJ401FaLwHz1MnAgzhdReeKB/hjix2mMafBewQOszivGy5eYtalsgSeZn X-Received: by 2002:a17:90a:bd10:: with SMTP id y16mr12039556pjr.132.1567410095310; Mon, 02 Sep 2019 00:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567410095; cv=none; d=google.com; s=arc-20160816; b=UbqlLpeElNE/dZBUttwSZEdl0V4fASBOUisUKWWC4zquBdMxNFtmXVYDhX07224BJH GJi6pyA3QDT+STz3YpbIPPEE+LnRCO+Wr7GMkcACgT11H33acpJWv3/y7ke8/I2nIlUw ZPiZ+yntJPAi1zNsSLayUM7OY9cO/X2QhzXAyGcXu/vFw9rVcPUJs5M1cKZzstwYoeWd lPyYoRoR1X2fkuCSK1GhPgvxw+Z0mFrIC0ZO7xw/WMCHRkR27NNjgWd/KL6Hj6cVTmBX KmM1p/9RecBtmIUOhvMbR3l9PTUSWvarlVQkpKS72deqV3/bJcoEb20o+c1YtennhAYO 9EWQ== 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=czLm9+6XeObljoXUlErx8mAKQvTAxkpX8YXKtxnvR4g=; b=AY3J4OAFGnikwUhHXzZJFer3H+ZviMjsfr+9UZ/EV/TNkgYCuvJ3Z/K5RR/aEhhEwY 4sVB/lOlXfWsgVVbncgROZt0YwC9FOMaaroUTP/B9TLfaQQlC2vepoCL9W3N6VlueEWq zZpVGAX0f7EWOUDMIwBKoVUgtxq6zVHcZsmplbeCr6lZ+E9HFHXHlCchcZxtZOJhOM6X twCZs6p93y3868jeS9y9mqMvAEUtpAKK7PGFc/avc6EJ4DHcHT/+E3VXNZ1vVTCL7XmC ZHtnHQWXqHFNTheHFrorBTm6dz1YAKR+NJElEnM8exRtNFP7PuDI5TcxpzWh1lgpFAeG wp8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=UQykYbAy; 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 n26si7842670pgv.192.2019.09.02.00.41.20; Mon, 02 Sep 2019 00:41:35 -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=UQykYbAy; 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 S1729817AbfIBHiy (ORCPT + 99 others); Mon, 2 Sep 2019 03:38:54 -0400 Received: from merlin.infradead.org ([205.233.59.134]:42268 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfIBHiy (ORCPT ); Mon, 2 Sep 2019 03:38:54 -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=czLm9+6XeObljoXUlErx8mAKQvTAxkpX8YXKtxnvR4g=; b=UQykYbAyrrel/FfPuS6bPE+5w MBmQ3B4whQzp+6X6/IjDTCyaNfY6g6oYXjxje/EICxmgJrmUETodNdZ2yhi00ffprnn6MrVDdL8LV RyddXIHAQU4AMu1E/qJjB/BwhEyX+sOJc7N+88IML2MdGM/QvT7weXDugntF0SFaDiv7C5YTe2mEc Hl+edJpyJU+brRrkfIDEkoF9Kg2BL7YZdExZOmbQPDE5FCoHtNhMC9EzhScErMWcR2oWTkj2wB0KJ uLKTD2rl5Pi4jV5/ulydOP1bJ480eK7uy1k6r9ABehMfydGQj2iJmIlZIY+/XSYkWOf9XzIoMeLMi jC8lQl3yw==; 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 1i4gv8-0004iF-Mo; Mon, 02 Sep 2019 07:38:38 +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 070F330116F; Mon, 2 Sep 2019 09:38:00 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9574829B7E7A5; Mon, 2 Sep 2019 09:38:36 +0200 (CEST) Date: Mon, 2 Sep 2019 09:38:36 +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: <20190902073836.GO2369@hirez.programming.kicks-ass.net> References: <20190822132811.31294-1-patrick.bellasi@arm.com> <20190822132811.31294-6-patrick.bellasi@arm.com> <20190830094834.GB2369@hirez.programming.kicks-ass.net> <87woernqnb.fsf@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87woernqnb.fsf@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 Mon, Sep 02, 2019 at 07:44:40AM +0100, Patrick Bellasi wrote: > 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: > >> + 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? Yep. > 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? Only for a single task; by using the cgroup thing we have that in-kernel iteration of tasks. The thing I worry about is bouncing rq->lock around the system; but yeah, I suppose a normal user could achieve something similar with enough tasks. > >> + /* > >> + * 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. OK, already fixed that.