From patchwork Mon Apr 9 09:53:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 10330933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A053E6020F for ; Mon, 9 Apr 2018 09:53:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A00F28858 for ; Mon, 9 Apr 2018 09:53:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EBDD28ADA; Mon, 9 Apr 2018 09:53:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2425328858 for ; Mon, 9 Apr 2018 09:53:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751844AbeDIJxG (ORCPT ); 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-Language: en-US Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); - }