Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1455095iol; Fri, 10 Jun 2022 07:53:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBWVNvZhNUFbdRx2Nhfaspm3dxsRRx2tOwkjSMe65EYtHc9tiDWsVv/WoE9sNt6vLOyvKZ X-Received: by 2002:a17:90b:3a8b:b0:1e8:3056:10fc with SMTP id om11-20020a17090b3a8b00b001e8305610fcmr127056pjb.145.1654872811284; Fri, 10 Jun 2022 07:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654872811; cv=none; d=google.com; s=arc-20160816; b=KjoVC0CVJgRKkJ+7cAcwDsuqbX9VpDhAB4p+7CltSiX0fZMVpk2VHcdE2JK6kitq+D rbpdUNu80/oVQ1H6dI7+X8PjODjM+G5jWBkPvZH/C7mlsAOrXY9bxSo5trs4zX7Q2Cm1 gNEeMfEsOxQkHe8LKviZ01F0QNoVk3QE5kWM3RsBo9VIniC9duGPggUvMUUdBon/jqZv XG4eHTGb0GL9mAI4pNWnoKJLKvUqRz2v89sBGjT8CGXQEBY55LnTZ7dHzD37XMqeuRIO Uwwd5QbqEB+22bwQNf3ZUZqDaNCpuInzbn8/RTNvtni1rMcSt71/T7J7P0ll6fFE0SNN 541Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=E2+18wsRQKBqACgyEiy7YR4UKEf+NL8qKOG7yjXEJbs=; b=EcD2Xy3kodL2ymXkGV3MCHDMdiGaSP/JJnr+lCUUJYuGwOmq6Zi4hGI8t3PUgSRsJd TbpCIvQGgQ9XDmY5O/wT/DpyY557AS0X1hSfyBQl9gaRU7l63cTSRFpWHDvXVaqRp4P5 19R8VkR+0+e/UlLpwuIigjTa/Xli9Zira48GxaY0HsBw45oHbFE74kMW2bpK93sfUUfl LbduSdBdlK1a26mlMBbkA/gUaEWhR815j3rcvmemIa8i6E7B7A10dsZDyJ4Rn+JwnJ97 Pg4s5AjK3/2cvmEx5cni1uk7CkxokPr6kNlpoBC2EqsK4t6wQfSgij+L2gjyIZhCceXR ue8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o1aHQ+Sx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a639d06000000b003fb8f6e341fsi38811544pgd.290.2022.06.10.07.53.18; Fri, 10 Jun 2022 07:53:31 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=o1aHQ+Sx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344002AbiFJOmV (ORCPT + 99 others); Fri, 10 Jun 2022 10:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiFJOmT (ORCPT ); Fri, 10 Jun 2022 10:42:19 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313FE3B4EF6 for ; Fri, 10 Jun 2022 07:42:18 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id w2so47338169ybi.7 for ; Fri, 10 Jun 2022 07:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E2+18wsRQKBqACgyEiy7YR4UKEf+NL8qKOG7yjXEJbs=; b=o1aHQ+SxzEci93Bf30u5GX3LcHCOHczIl6or1LgYx3BikufnMalpsCAITxudivmoYR 3LaC0fVsq7pifzUMSsnQ2ItcO/DhG+cZN3l4w0re5GeEg7foTgL+DqoJ/x+z7jfb/QAN MMXPegeit2b53KYAltBDD4G9k987aFUnmeQnniXMcneKSqHOSuZDX4zgYxkp1Sw9E0bp soYw+txPFWEgyto75uPA8pfR5YGAGCRE84F0+nCzcgGgYTKCSR6wdV8+vbwiuHx6pS11 uyZzLgWO3TIlL3c2WhtmlPvSu5z8qQTjtDOFO5O8t/EZ/5KL1DAGTi0PtC9n2jh+H3N3 uvsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E2+18wsRQKBqACgyEiy7YR4UKEf+NL8qKOG7yjXEJbs=; b=l+UWiS8A5cHB7G/YasCmc1Yjq3qWqWKE/81ODh+9SPJPxnJIwc2pRPXbaLUo+Gkkx2 +FYiutSKvhAWiz+zUYIPkQ2iCOzfzxiv83OFKRwzVbKn6OArhM4fdGWJ0xApQ+ouI7wm ziSg23DhKozGWoPykA9snDL7cY7qxr6RRfKIsOyhoA/UTZ2BYuLZfs0MeGLr3Aopx9NI WX04H+Mfe3ihFI560JtC7+v60MscLZdKECj9lOZXv3sL5IqB7FnL4o8Es43P0XHwZQl+ ZSeNQpk9IZ/QMCS5LkRLoKx4XA7vAyrqjJcoLUGOUgIWmNbbBqIyZ6jdkapXvvRJhVlE r3bw== X-Gm-Message-State: AOAM531jqrYtX1U4wOdpHk7i84dPubkpa+4rjo/bWXU/tDps2RE40p/V vEXauDW1es8WReY7M1IG66Pg/xp1qSsyzr588IvJ4Q== X-Received: by 2002:a25:6041:0:b0:663:6f4c:b3b8 with SMTP id u62-20020a256041000000b006636f4cb3b8mr28799842ybb.236.1654872137379; Fri, 10 Jun 2022 07:42:17 -0700 (PDT) MIME-Version: 1.0 References: <20220407111222.22649-1-kprateek.nayak@amd.com> In-Reply-To: From: Vincent Guittot Date: Fri, 10 Jun 2022 16:42:05 +0200 Message-ID: Subject: Re: [PATCH v7] sched/fair: Consider cpu affinity when allowing NUMA imbalance in find_idlest_group To: Peter Zijlstra Cc: Valentin Schneider , K Prateek Nayak , aubrey.li@linux.intel.com, efault@gmx.de, gautham.shenoy@amd.com, linux-kernel@vger.kernel.org, mgorman@techsingularity.net, mingo@kernel.org, song.bao.hua@hisilicon.com, srikar@linux.vnet.ibm.com, valentin.schneider@arm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 10 Jun 2022 at 16:15, Peter Zijlstra wrote: > > On Fri, Jun 10, 2022 at 11:55:37AM +0100, Valentin Schneider wrote: > > On 09/06/22 13:54, Peter Zijlstra wrote: > > > Now, I can (and have) fixed up the conflict, but it did make me look at > > > this in a little more detail; and the thing I noticed is that your: > > > > > > 'p->nr_cpus_allowed != num_online_cpus()' > > > > > > test makes no sense. That's basically 'true'. The thing is, > > > nr_cpus_allowed is initialized to NR_CPUS, and unless someone somewhere > > > did set_cpus_allowed() on it, it'll still be NR_CPUS. > > > > > > Also, CPU hotplug doesn't change nr_cpus_allowed, so num_online_cpus() > > > is just plain wrong. > > > > > > Now, something that might work is: > > > > > > 'p->nr_cpus_allowed < num_online_cpus()' > > > > > > And even that is no guarantee. You can construct a situation where this > > > is still false even though you actually have a constrained set. > > > Consider a machine with 8 CPUs. Then set the mask to: 0x55, which has 4 > > > CPUs set. Then offline the last 4 so that the online mask becomes 0x0f. > > > > > > Then the effective mask is 0x05, and the number we're looking for above > > > is 2, but the suggested test would still be false, because > > > nr_cpus_allowed would be 4, as would num_online_cpus(). > > > > > > > IIUC we want to pay special attention when the task isn't allowed to run on > > all online CPUs, wouldn't the below do that? > > > > !cpumask_subset(cpu_online_mask, p->cpus_ptr) > > At that point we might just as well do the whole cpumask_and() thing, > no? There's not much cost difference between these two operations. The test was there to not do the computation with cpumask_and() if the task's affinity has not been modified so maybe it would be enough to test (p->nr_cpus_allowed != NR_CPUS) to check if the task's affinity has been modified and we have we do the cpumask_and() and cpumask_weight() > > > The task affinity can be a superset of the online mask, obvious case is > > init_task's CPU_MASK_ALL, and the above test is still false if both masks > > are equal. > > > > (Additionnaly we could add a step in sched_init() to "properly" initialize > > the init_task mask and remove the NR_CPUS faff). > > I'm confused, NR_CPUS is the right value for CPU_MASK_ALL.