Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3985515pxb; Sat, 5 Feb 2022 00:18:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzz5DJws1Dr4SCzCoj6qhPQ5Yvkr/DMNc7Mz06Vm3EhPIbpzg8HEB73R6PzvGhkIkF21123 X-Received: by 2002:a50:ef16:: with SMTP id m22mr3197319eds.340.1644049090611; Sat, 05 Feb 2022 00:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644049090; cv=none; d=google.com; s=arc-20160816; b=eDkPvGprvMkNwYNiIUo6cn8+FoTOpdYdFt/JGdByGDpnMRtYpqcKyGyZ//E9B6nZD8 1h9AYIfPXSkNF2MDIrSRcFySVVitAYatoPSb6zIkC4I12ku/0etD0H+N4adpNSn+KZ9p EuR/IMpIlww2lzdnyIQyadpBc92OokOYT5u5PwVyafGpiC1wyBEWajQ+r+pblNXUnoL2 DYBLBXcgAf/W27OlkojKT0Sda6NMzQpT9NaKhw/u0V6gvG7PIm+L2p8MRxE5ObeL2igm nAJujtlWoEPmUB7dy2BEnxHjHk53ezj2Fvxev2kUWY5HPgfxTd0FHE2Nyk4hHZVst+Pp 17Pw== 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=Em1lNg0sJ8vJvq2opSoaAOOUSySJeU1TnefpRBzZ/rg=; b=Az8zJ+DNndRhgU5hCDicEcT0qwAElN8HpxXVJMI4fe6+q6PSBiSdOgFX5KJUF15xqE STG+YlIuk6+DQ9HA61Wcgvwo1Xd6vPcg1ZpX5n5iL7cbTo6mD3irssTmT9c3aY8eKMAs UsOUAcanlgsfYE+Wbe6C4ZebTX5Z/XCP1q5yiCbvGW+LoVZMjTmEwqh5sGdZ7y79NljK jduw82zPr8jHFFQ+HdxKNHwr9DAtFMOtDq8U3l+KWWUqu+Jr849bPMD4Aam6pympAE+q RSDoBfgP8jf0e7LaUfw06QFj8H9OpzTYjM0TovVEGyjcV5roUSlNmd/VgIvk5m6fGd1/ /ceQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji2si3094203ejc.480.2022.02.05.00.17.46; Sat, 05 Feb 2022 00:18:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376629AbiBDQqA (ORCPT + 99 others); Fri, 4 Feb 2022 11:46:00 -0500 Received: from outbound-smtp35.blacknight.com ([46.22.139.218]:43195 "EHLO outbound-smtp35.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbiBDQp7 (ORCPT ); Fri, 4 Feb 2022 11:45:59 -0500 Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp35.blacknight.com (Postfix) with ESMTPS id C9AD52036 for ; Fri, 4 Feb 2022 16:45:58 +0000 (GMT) Received: (qmail 20019 invoked from network); 4 Feb 2022 16:45:58 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.223]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 4 Feb 2022 16:45:58 -0000 Date: Fri, 4 Feb 2022 16:45:57 +0000 From: Mel Gorman To: "Nayak, KPrateek (K Prateek)" Cc: Peter Zijlstra , Ingo Molnar , Vincent Guittot , Valentin Schneider , Aubrey Li , Barry Song , Mike Galbraith , Srikar Dronamraju , Gautham Shenoy , LKML Subject: Re: [PATCH 2/2] sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs Message-ID: <20220204164556.GN3366@techsingularity.net> References: <20220203144652.12540-1-mgorman@techsingularity.net> <20220203144652.12540-3-mgorman@techsingularity.net> <9d7e8fe1-d9d7-90df-0f30-cf82b82e7f1f@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <9d7e8fe1-d9d7-90df-0f30-cf82b82e7f1f@amd.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 04, 2022 at 08:37:53PM +0530, Nayak, KPrateek (K Prateek) wrote: > On 2/3/2022 8:16 PM, Mel Gorman wrote: > > @@ -9003,10 +9006,9 @@ static bool update_pick_idlest(struct sched_group *idlest, > > * This is an approximation as the number of running tasks may not be > > * related to the number of busy CPUs due to sched_setaffinity. > > */ > > -static inline bool > > -allow_numa_imbalance(unsigned int running, unsigned int weight) > > +static inline bool allow_numa_imbalance(int running, int imb_numa_nr) > > { > > - return (running < (weight >> 2)); > > + return running < imb_numa_nr; > > } > > > > /* > > @@ -9146,7 +9148,7 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu) > > * allowed. If there is a real need of migration, > > * periodic load balance will take care of it. > > */ > > - if (allow_numa_imbalance(local_sgs.sum_nr_running + 1, local_sgs.group_weight)) > > + if (allow_numa_imbalance(local_sgs.sum_nr_running + 1, sd->imb_numa_nr)) > > Could you please clarify why are we adding 1 to local_sgs.sum_nr_running while allowing imbalance? To account for the new task similar to what task_numa_find_cpu before calling adjust_numa_imbalance. > allow_numa_imbalance allows the imbalance based on the following inequality: > > running < imb_numa_nr > > Consider on a Zen3 CPU with 8 LLCs in the sched group of the NUMA domain. > Assume the group is running 7 task and we are finding the idlest group for the 8th task: > > sd->imb_numa_nr = 8 > local_sgs.sum_nr_running = 7 > > In this case, local_sgs.sum_nr_running + 1 is equal to sd->imb_numa_nr and if we allow NUMA imbalance > and place the task in the same group, each task can be given one LLC. > However, allow_numa_imbalance returns 0 for the above case and can lead to task being placed on a different > NUMA group. > > In case of Gautham's suggested fix (https://lore.kernel.org/lkml/YcHs37STv71n4erJ@BLR-5CG11610CF.amd.com/), > the v4 patch in question (https://lore.kernel.org/lkml/20211210093307.31701-3-mgorman@techsingularity.net/) > used the inequality "<=" to allow NUMA imbalance where we needed to consider the additional load CPU had > to bear. However that doesn't seem to be the case here. > I failed to change < to <= in allow_numa_imbalance, I'll fix and retest. -- Mel Gorman SUSE Labs