Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6322946imu; Mon, 21 Jan 2019 07:01:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RLpXvpH9czTQmfjxnKWib6SAsmYiGjc/bpYhz7mws9B4mlhJkzLNi+zMvJcL9ofhG1p7C X-Received: by 2002:a17:902:4523:: with SMTP id m32mr30389796pld.53.1548082901139; Mon, 21 Jan 2019 07:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548082901; cv=none; d=google.com; s=arc-20160816; b=EuR8lEy9W2+3mCEhFOepLHxGL85Z0zwp4PE0w9Xxynti/eSO5cvvDkSt/DLlvdxT+f D0JagiGPpgyxvhm3bQvMF7jDSldGyCyEckl11vKZLE7x++ntKZ6g0l+j2te0xsJ9k+AD kzi2JdL4tyqfG/reC+xDxJF3WGuHW5zy4709B3RXLlMuHs2mmcpD9UQA42QpWWa7cxMO +JE/GHdsd+KKc3DIpuSqB9yDrFmZ95Ios4b4Q1+DqjSmJ9wR+GSUHpOBUlfrLCrtm34/ KUYpUYhumu5fv19envfEtG8bMQb8GkQjbaeumC8NUTlAVuKmLUqSG9cdcRDpLeHAX2hX fxvg== 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=+XkP6BjBOoguOx02ypGLg2Qbad4YbXufumxqfvbyOgo=; b=CpCnXYgoQsMy//k1xYG1ziHyep646xm0zSKAVTMhoaem7CK8GuSjAqxuF6fKTYwzYb MI1uXff0nd5UE89KWznS8K4tRuPUpKZ9eXIBpiNAmWSDHopn0Ake1jWAcR3tBH4ZvBJz Vpz+F+6RlCX2Wd2SBY3+I8o9hjotFwYzW59loOZGw7YUg1kHyv+SaXsuyZL0hE19Ny4W QGbqpmc/jIBekbvJpAoe44F7QNl/uXT6EqpCMSGsGNMzWLT6iwI3uf8OnjMJ74sQSt8I 411yaNW4/VHz/oXSz6k8kDODtdh9TIsDEXPtg5HVO2zrJ0PAK2OKXT0MLnnwOrwSRZXc P2yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lfMXZm5h; 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 bg7si12448248plb.149.2019.01.21.07.01.23; Mon, 21 Jan 2019 07:01:41 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lfMXZm5h; 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 S1729883AbfAUO7k (ORCPT + 99 others); Mon, 21 Jan 2019 09:59:40 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48940 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729474AbfAUO7j (ORCPT ); Mon, 21 Jan 2019 09:59:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=+XkP6BjBOoguOx02ypGLg2Qbad4YbXufumxqfvbyOgo=; b=lfMXZm5hjEwlCw+4TqCeYF5mM kvenuIAuRzFYsU/vhChWqDhCjjEpHQZ7xOPkUtsYKMtnughlRpUAogubV+1uSmTEbZg0Hi5jR4lmg u2wO7Sx15bYX2/qw3Izqapybq0LC4o9QPoVidVURmrBP8qb9OPcO3ynW9h5wZDiBxj/vhko0AlskK vHq1CE9Pzb8PSI4ZAF1Lo8O1MeTKE6zz0VgT/F98qZup3ZfeuDTqbbGAIH4sJLM0GQUJ+tL83eZuv R1S3UD9J8AQZ+U2U3q/CONzYTaTfp8M93v4lGzJrO23Fht72zoMKUNMqWZhbu6YwV8asnBm9Oi9Zq 5WiFWnLIQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1glb2y-00063P-6z; Mon, 21 Jan 2019 14:59:32 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 91FF8284706C0; Mon, 21 Jan 2019 15:59:29 +0100 (CET) Date: Mon, 21 Jan 2019 15:59:29 +0100 From: Peter Zijlstra To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , 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 04/16] sched/core: uclamp: Add CPU's clamp buckets refcounting Message-ID: <20190121145929.GI27931@hirez.programming.kicks-ass.net> References: <20190115101513.2822-1-patrick.bellasi@arm.com> <20190115101513.2822-5-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115101513.2822-5-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 Tue, Jan 15, 2019 at 10:15:01AM +0000, Patrick Bellasi wrote: > @@ -835,6 +954,28 @@ static void uclamp_bucket_inc(struct uclamp_se *uc_se, unsigned int clamp_id, > } while (!atomic_long_try_cmpxchg(&uc_maps[bucket_id].adata, > &uc_map_old.data, uc_map_new.data)); > > + /* > + * Ensure each CPU tracks the correct value for this clamp bucket. > + * This initialization of per-CPU variables is required only when a > + * clamp value is requested for the first time from a slow-path. > + */ I'm confused; why is this needed? > + if (unlikely(!uc_map_old.se_count)) { > + for_each_possible_cpu(cpu) { > + struct uclamp_cpu *uc_cpu = > + &cpu_rq(cpu)->uclamp[clamp_id]; > + > + /* CPU's tasks count must be 0 for free buckets */ > + SCHED_WARN_ON(uc_cpu->bucket[bucket_id].tasks); > + if (unlikely(uc_cpu->bucket[bucket_id].tasks)) > + uc_cpu->bucket[bucket_id].tasks = 0; > + > + /* Minimize cache lines invalidation */ > + if (uc_cpu->bucket[bucket_id].value == bucket_value) > + continue; > + uc_cpu->bucket[bucket_id].value = bucket_value; > + } > + } > + > uc_se->value = clamp_value; > uc_se->bucket_id = bucket_id; >