Received: by 10.213.65.68 with SMTP id h4csp2398540imn; Mon, 9 Apr 2018 02:56:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx482pwkZxNvrAKFMM/Mt0rycAjuwWkHnBjRzopw6C/NSJ7ENMzJjo62rFwcjuA56C74OTZOq X-Received: by 10.101.71.136 with SMTP id e8mr13038583pgs.12.1523267785487; Mon, 09 Apr 2018 02:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523267785; cv=none; d=google.com; s=arc-20160816; b=ChjzKmhBSci1wMmWzbmi8iFBBC78NesHmfbrCP941xeDsE44b/alfxjxLmYVTbtwcl NisRhNAo0xe1BH0QyiOQmt1RwW7+xqO2oPKjurEjW2smMNJeDDl1iN3Lme6Du0481Gsf 5LXubOl3q5A7FfuIPgodsvGlLBZ7k7c60Pw6nfHVd5n26m+ZTwA0DiyBxXw+Fin99ApD O+IiZ0gVhHsvkv0Nq2RmLzKb12NQ2OP0dlCxMkNiKEy6Uw273QVbF7aGI6MNRAiSxl9f oQRUFR1vSBqe+0BknZIvZVjRQl+ctvGTcyUfFIEJ7dWKQak5XE4p2hai28Snv9XM4SRH OoUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=4D+RgcpfZhKSmvhObqOJE3FBxhHjFtqoiffkI7QWk2k=; b=QYDxyxx8/NyDLZcE2WHoW5NkVdeGT4yM4EZVraRHIlJIZjbESu1JBTK+lOP18kub51 TG8RGv6/IGxn4lwGx56tyo9tjkqEmxmXzWO7vw9eYeyyE0+hZ000e+Ypr4bR2J7BMakp VALr6DRcTztKcjraWNB87xvtP7LZ4c2q+NY4LYNO0No/OBVlsNW37tv/bhbTEU646nvy C7dysSJnOT9qyDWN74z51HqdEJGjCYxksYtPjZIL3d1gtVfvUiFXSIc0rMGH77AaFSrh DV4AgyLofn4U8BBWWJ5hZ7A5YRI1vOofCOOwJsoHzHLldtSdasOG0FT/YlcDArVYJz+h 8DIg== 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 z3si11784163pfe.255.2018.04.09.02.55.48; Mon, 09 Apr 2018 02:56:25 -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 S1752212AbeDIJxG (ORCPT + 99 others); Mon, 9 Apr 2018 05:53:06 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53820 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628AbeDIJxF (ORCPT ); Mon, 9 Apr 2018 05:53:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20C521529; Mon, 9 Apr 2018 02:53:05 -0700 (PDT) Received: from [0.0.0.0] (e107985-lin.cambridge.arm.com [10.1.210.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 142163F592; Mon, 9 Apr 2018 02:53:01 -0700 (PDT) Subject: Re: [RFC PATCH 3/6] sched: Add over-utilization/tipping point indicator To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Quentin Perret , Thara Gopinath , linux-pm@vger.kernel.org, Morten Rasmussen , Chris Redpath , Patrick Bellasi , Valentin Schneider , "Rafael J . Wysocki" , Greg Kroah-Hartman , Vincent Guittot , Viresh Kumar , Todd Kjos , Joel Fernandes References: <20180320094312.24081-1-dietmar.eggemann@arm.com> <20180320094312.24081-4-dietmar.eggemann@arm.com> <20180409094001.GZ4043@hirez.programming.kicks-ass.net> From: Dietmar Eggemann Message-ID: <093ba425-4f81-9f86-78a6-1cd1fd4651f9@arm.com> Date: Mon, 9 Apr 2018 11:53:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180409094001.GZ4043@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/09/2018 11:40 AM, Peter Zijlstra wrote: > > (I know there is a new version out; but I was reading through this to > catch up with the discussion) > > On Tue, Mar 20, 2018 at 09:43:09AM +0000, Dietmar Eggemann wrote: >> +static inline int sd_overutilized(struct sched_domain *sd) >> +{ >> + return READ_ONCE(sd->shared->overutilized); >> +} >> + >> +static inline void update_overutilized_status(struct rq *rq) >> +{ >> + struct sched_domain *sd; >> + >> + rcu_read_lock(); >> + sd = rcu_dereference(rq->sd); >> + if (sd && !sd_overutilized(sd) && cpu_overutilized(rq->cpu)) >> + WRITE_ONCE(sd->shared->overutilized, 1); >> + rcu_read_unlock(); >> +} >> +#else > > I think you ought to go have a look at the end of > kernel/sched/topology.c:sd_init(), where it says: > > /* > * For all levels sharing cache; connect a sched_domain_shared > * instance. > */ > if (sd->flags & SD_SHARE_PKG_RESOURCES) { > sd->shared = *per_cpu_ptr(sdd->sds, sd_id); > atomic_inc(&sd->shared->ref); > atomic_set(&sd->shared->nr_busy_cpus, sd_weight); > } > > Because if I read all this correctly, your code assumes sd->shared > exists unconditionally, while the quoted bit only ensures it does so <= > LLC. > But the patch changes this part further down. diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 64cc564f5255..c8b7c7665ab2 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1184,15 +1184,11 @@ sd_init(struct sched_domain_topology_level *tl, sd->idle_idx = 1; } - /* - * For all levels sharing cache; connect a sched_domain_shared - * instance. - */ - if (sd->flags & SD_SHARE_PKG_RESOURCES) { - sd->shared = *per_cpu_ptr(sdd->sds, sd_id); - atomic_inc(&sd->shared->ref); + sd->shared = *per_cpu_ptr(sdd->sds, sd_id); + atomic_inc(&sd->shared->ref); + + if (sd->flags & SD_SHARE_PKG_RESOURCES) atomic_set(&sd->shared->nr_busy_cpus, sd_weight); - }