Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6400534pxb; Mon, 8 Nov 2021 08:02:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+OsL3LmsEcx7Z2g7VZY825eGJcV8sPCsRCzQnMagzXV5GQVm2/68FDl5A+8vP9T1f9ztx X-Received: by 2002:a17:906:4bcf:: with SMTP id x15mr391400ejv.273.1636387360942; Mon, 08 Nov 2021 08:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636387360; cv=none; d=google.com; s=arc-20160816; b=rSIzdJGSVm8CSgIb+1fQvEJvYEqL7NZ3cWd2c9HZjVoeA2c1946rO4KJz24UutRM66 CR68tgcP2KoEdg5YW//WOT8RIbyWbXaWVDuhtExqyc5ISAta4lDcC09LC8vIsoImMHk9 u01hRW/P8bjpAXUYs+EIROfy0v4l2aayFaDLoQTDDbPKXy9bCQ18ffQnoLkEKC7mTWq3 PS/KpuRrZgrOi3ixrQNaWxtcPpl/RiCR/AQtQRBQgn5Tl/X9Nnxi7pEKh+QK8yqeYW1x HfW1JkW+BiNS/uQWWGh53uvCA4Yu022915/6c7S0WVsecYvymiMbut2kbH7sIfA9zsSW OB7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=4t5y1olmpZV0xxn6AAmcWq7/I8bWdI3W4buBx2NUq6s=; b=gfArUr/XzgkaHw52CQzhc271UW09+0f0Ii0tzSqzqI4oE5rEYv3N+DTviA6886SobG RNaRlaqaxsAVzSH8bK3J1vpWqkSFVU1nHKHVmfwRcwVMYcZehdcSLk/1IiW1ybpLsNcm yEUH+O9RSfVDLfjadD9v9UTB0+MKsicnfxljhSFp7FlKgiMfbZpJbH+syeQLEx/GZAWq rLhvUPrMJQXXmSoBw7TBpfzstEjEZnTC2bqH2d/xQAT08SehaRnbr9CLwmXqm9gcSUNP Fn5Wr4pPD5wI4aBGPm+mrb6+3/if2tFkoxVgg63rwrD6bk5EwWGfq8o7+xbkTamPYvJv piSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz13si26183140ejb.619.2021.11.08.08.02.05; Mon, 08 Nov 2021 08:02:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239355AbhKHMCf (ORCPT + 99 others); Mon, 8 Nov 2021 07:02:35 -0500 Received: from outbound-smtp50.blacknight.com ([46.22.136.234]:33745 "EHLO outbound-smtp50.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbhKHMCf (ORCPT ); Mon, 8 Nov 2021 07:02:35 -0500 Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp50.blacknight.com (Postfix) with ESMTPS id 548EEFBDFB for ; Mon, 8 Nov 2021 11:59:50 +0000 (GMT) Received: (qmail 14838 invoked from network); 8 Nov 2021 11:59:50 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.29]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 8 Nov 2021 11:59:50 -0000 Date: Mon, 8 Nov 2021 11:59:48 +0000 From: Mel Gorman To: Peter Zijlstra Cc: Ingo Molnar , Vincent Guittot , Valentin Schneider , Aubrey Li , "Srinivasan, Sadagopan" , LKML Subject: Re: [PATCH] sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs Message-ID: <20211108115948.GH3959@techsingularity.net> References: <20211028130305.GS3959@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 08, 2021 at 12:14:27PM +0100, Peter Zijlstra wrote: > On Thu, Oct 28, 2021 at 02:03:05PM +0100, Mel Gorman wrote: > > > @@ -1926,8 +1926,8 @@ static void task_numa_find_cpu(struct task_numa_env *env, > > src_running = env->src_stats.nr_running - 1; > > dst_running = env->dst_stats.nr_running + 1; > > imbalance = max(0, dst_running - src_running); > > - imbalance = adjust_numa_imbalance(imbalance, dst_running, > > - env->dst_stats.weight); > > + imbalance = adjust_numa_imbalance(imbalance, env->dst_cpu, > > + dst_running, env->dst_stats.weight); > > Can we please align at (0 ? > i.e. imbalance = adjust_numa_imbalance(imbalance, env->dst_cpu, dst_running, env->dst_stats.weight); ? > > > > /* Use idle CPU if there is no imbalance */ > > if (!imbalance) { > > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > > index 4e8698e62f07..08fb02510967 100644 > > --- a/kernel/sched/topology.c > > +++ b/kernel/sched/topology.c > > @@ -644,6 +644,7 @@ static void destroy_sched_domains(struct sched_domain *sd) > > DEFINE_PER_CPU(struct sched_domain __rcu *, sd_llc); > > DEFINE_PER_CPU(int, sd_llc_size); > > DEFINE_PER_CPU(int, sd_llc_id); > > +DEFINE_PER_CPU(int, sd_numaimb_shift); > > Why does it make sense for this to be a per-cpu variable? Yes, I suppose > people can get creative with cpusets, but what you're trying to capture > seems like a global system propery, no? > I thought things might get weird around CPU hotplug and as llc_size was tracked per-cpu, I thought it made sense to also do it for sd_numaimb_shift. > At most this seems to want to be a sched_domain value. > > > DEFINE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared); > > DEFINE_PER_CPU(struct sched_domain __rcu *, sd_numa); > > DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_packing); > > @@ -672,6 +673,20 @@ static void update_top_cache_domain(int cpu) > > sd = lowest_flag_domain(cpu, SD_NUMA); > > rcu_assign_pointer(per_cpu(sd_numa, cpu), sd); > > > > + /* > > + * Save the threshold where an imbalance is allowed between SD_NUMA > > + * domains. If LLC spans the entire node, then imbalances are allowed > > + * until 25% of the domain is active. Otherwise, allow an imbalance > > + * up to the point where LLCs between NUMA nodes should be balanced > > + * to maximise cache and memory bandwidth utilisation. > > + */ > > + if (sd) { > > + if (sd->span_weight == size) > > + per_cpu(sd_numaimb_shift, cpu) = 2; > > + else > > + per_cpu(sd_numaimb_shift, cpu) = max(2, ilog2(sd->span_weight / size * num_online_nodes())); > > + } > > + > > sd = highest_flag_domain(cpu, SD_ASYM_PACKING); > > rcu_assign_pointer(per_cpu(sd_asym_packing, cpu), sd); > > I think I'm with Valentin here, this seems like something that wants to > use the sd/sd->child relation. > > That also makes this the wrong place to do things since this is after > the degenerate code. > > Perhaps this can be done in sd_init(), after all, we build the thing > bottom-up, so by the time we initialize the NODE, the MC level should > already be present. > > I'm thinking you can perhaps use something like: > > if (!(sd->flags & SD_SHARE_PKG_RESROUCES) && > (child->flags & SD_SHARE_PKG_RESOURCES)) { > > /* this is the first domain not sharing LLC */ > sd->new_magic_imb = /* magic incantation goes here */ > } Thanks, I'll give it a shot and see what I come up with, it'll probably take me a few days to clear my table of other crud to focus on it. -- Mel Gorman SUSE Labs