Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp261341rwi; Wed, 26 Oct 2022 00:04:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7BX4nl5zygnnG7rxq3/SoJHrwarAbircJqOUZLuMA3TQGj1rUTdz528KVcwp1fd3iLMWNm X-Received: by 2002:a17:906:9c83:b0:779:c14c:55e4 with SMTP id fj3-20020a1709069c8300b00779c14c55e4mr35246742ejc.619.1666767862609; Wed, 26 Oct 2022 00:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666767862; cv=none; d=google.com; s=arc-20160816; b=i/XSTdNBUmkm2iLA5pwMbX2WnpPugul5Oqtmdeob2ixSZrMjmQcVDsvFVa7A3O5LNz uQJmfJ53YbdMdbZz7bwRzSn9dbzsbg284D4zaoUY62FXHqUqncEAJ4zZQrjCzR2lYOyi IWvKsw5E05Og47cbcuN16qAfj5cTOYXraFnoIgyfi1fnUK67lzFMtBcyzGhp2LZQXS1b jMvickmbTU+unLD5q2OUedUk6jt+Pie0C3et4D6530QVHcaTYhWqJ/qOtMf3F5is+GsJ oK4csq0LxaSqsEqUf2ru9099662dxjiH29MsYWRMwz1kOCLv6UZyAryYye490av4cibd RwOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2fjwpVVv8NNDnWDvTOJej+inL4k7BmCXyJpK0M4DMs4=; b=x6fxm+cOphEGmNcnR0ycnK9oiXZ/njCwhUXbZZNGvjHxmEK5/nwBAjYnowLf/QvXLy SaYTbsssYTwbk+HUPDdtScMi4exLDBJTb/MmGNDHSkIIid5qJf/sBNRD+Gxjw6C/ma3l f8kW07CqslU5jOEy82JQJCrR450QJdDQCZTwXLAAXC2UG7ET2Sv0E7dU7w2R6ds6a+xJ RP6QwHD+Snsun7zTgyafLQFir1fb2iZBCRzGsNGa5Th/G8eEW8kP06rqAlBs9cPEM35f D0ucT3eLAXhQciGKllX3k5CbaLHCrQtFMs6Ov9JcY7ES2AwX7rDYfYuBpBGA2o3Zwk9B pCAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=k7ku7Elr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg12-20020a170907a40c00b0078e27f2ef52si5321865ejc.603.2022.10.26.00.03.47; Wed, 26 Oct 2022 00:04:22 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=k7ku7Elr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232698AbiJZGng (ORCPT + 99 others); Wed, 26 Oct 2022 02:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233027AbiJZGna (ORCPT ); Wed, 26 Oct 2022 02:43:30 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AE5AD99C for ; Tue, 25 Oct 2022 23:43:24 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id y13so9841496pfp.7 for ; Tue, 25 Oct 2022 23:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2fjwpVVv8NNDnWDvTOJej+inL4k7BmCXyJpK0M4DMs4=; b=k7ku7Elr6sQpsfdbeabwVWXePRIEmsJH2g8MvGOJVv9XSTu83/tFBtHYnmFjlwovxG lomJjjQJtTvCcozuz907T/VmwAhTYpQxwvKLIaS9xFP8li3tBVTTMCq+EMZ2OuEEKa3c aoPmgWkPbGH1FcCYlYbFlEsvBLqEmvJ3PfDcvfc/rTEpe0yCU2IF7Ogolz99HHYmr2U/ SyNvCtGCp0rwdKhXA8AsaryifFskUXcAiSqgcFhZTgvDAmlTZOsCoze9tRR9tmBn2D5q YSRBHIvEF6MZkXmZg8RytyDGfD1WOyqfFJZYdkqHpJurWvvb29jv3vj5nZfEUa/mLggG 9tNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2fjwpVVv8NNDnWDvTOJej+inL4k7BmCXyJpK0M4DMs4=; b=l0VJwg34JkoKDVMjWVxLR/7lwlM2K4kzdOVf4YKTQN33+q5YU6Y7ns9pX/lhRkSsld /PiHYUQ72MERwn4Gcp7eA90yhw6qUvlwJGa/JFlk9VegIUb2BOFR87Zn0n1ZqxecA+fa 3gBJD6pxArWe83HCc06PFS5gRYCzLaWqD4vcrPh2X9ISD4hEUVmBamkPrtVdNK0qH3OJ cJZOvfHd8XOEA1vlasz1X+Axtoa52OejE03lYCxzpfY89vBzgeHfoUUGZu6tFSVchtGe 7eB/te7SALNFHoVbrGi7BNzcMFMJqDxKy7KLvLjpXsiYLHOaberp7Ipy+yNrR14s4/YW d7Nw== X-Gm-Message-State: ACrzQf0XZp2loBfZJKDCgz5s8SYW8Ah6XLCZPCug6EtRWAEZ8DmRcdmV DcSCZUZ9b6c27GaG4Aqb55dF5g== X-Received: by 2002:a65:6bc7:0:b0:44a:dcee:18a5 with SMTP id e7-20020a656bc7000000b0044adcee18a5mr35855576pgw.413.1666766604344; Tue, 25 Oct 2022 23:43:24 -0700 (PDT) Received: from C02G87K0MD6R.bytedance.net ([139.177.225.228]) by smtp.gmail.com with ESMTPSA id b62-20020a621b41000000b0056b932f3280sm2363187pfb.103.2022.10.25.23.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 23:43:23 -0700 (PDT) From: Hao Jia To: mingo@redhat.com, peterz@infradead.org, mingo@kernel.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mgorman@techsingularity.net Cc: linux-kernel@vger.kernel.org, Hao Jia Subject: [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU Date: Wed, 26 Oct 2022 14:43:00 +0800 Message-Id: <20221026064300.78869-3-jiahao.os@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20221026064300.78869-1-jiahao.os@bytedance.com> References: <20221026064300.78869-1-jiahao.os@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 When select_idle_capacity() starts scanning for an idle CPU, it starts with target CPU that has already been checked in select_idle_sibling(). So we start checking from the next CPU and try the target CPU at the end. Similarly for task_numa_assign(), we have just checked numa_migrate_on of dst_cpu, so start from the next CPU. This also works for steal_cookie_task(), the first scan must fail and start directly from the next one. Signed-off-by: Hao Jia --- kernel/sched/core.c | 2 +- kernel/sched/fair.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cb2aa2b54c7a..5c3c539e1712 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6154,7 +6154,7 @@ static bool steal_cookie_task(int cpu, struct sched_domain *sd) { int i; - for_each_cpu_wrap(i, sched_domain_span(sd), cpu) { + for_each_cpu_wrap(i, sched_domain_span(sd), cpu + 1) { if (i == cpu) continue; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index dfcb620bfe50..ba91d4478260 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1824,7 +1824,7 @@ static void task_numa_assign(struct task_numa_env *env, int start = env->dst_cpu; /* Find alternative idle CPU. */ - for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start) { + for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start + 1) { if (cpu == env->best_cpu || !idle_cpu(cpu) || !cpumask_test_cpu(cpu, env->p->cpus_ptr)) { continue; @@ -6663,7 +6663,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) task_util = uclamp_task_util(p); - for_each_cpu_wrap(cpu, cpus, target) { + for_each_cpu_wrap(cpu, cpus, target + 1) { unsigned long cpu_cap = capacity_of(cpu); if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu)) -- 2.37.0