From patchwork Wed Nov 15 11:33:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cruzzhao X-Patchwork-Id: 165282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2474076vqg; Wed, 15 Nov 2023 03:34:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgnn/pArDIUBRWmBvfV+k11cKr1jmi56nhMVDzdMFnXtM+rRwexdxNrK/CSO94H5aanwrB X-Received: by 2002:a05:6a00:1d12:b0:690:c306:151a with SMTP id a18-20020a056a001d1200b00690c306151amr11959536pfx.0.1700048073942; Wed, 15 Nov 2023 03:34:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700048073; cv=none; d=google.com; s=arc-20160816; b=P48vXxtJx8XFGMilMjb4VFTiDNSrwADr/5LgUQLrW0S3VwyeBcCCjUatUhkiZcuNOS yKbIl+l1gXXY+3rjh6T7pM+GQ7xS4MO/xJbrwzbXi17B5GTj0gSLMEu7PFmDIgu3XpvQ 09q16k3KDBojzRctoATNBC3m0SVhuCC3pPxIKvDwNzi6lTl1FECG+y5eEvR0oFDEhTYY UE2ecDRNIb05jwTPB6koloC75nrUZAd21EroMlSjJ7roD4HbHldPYyg4EFF2gK1+90Tk gKgfn6N5nBEU++sm4Wwqd+H8MSzAtPNmVY4nEMH8BgpYnNX3M6XOPlol+axmJrOoLW+9 en6Q== 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; bh=NUnhdCG+7KbFoQU9OYQBLYrhUcdPEju09Aw8MVxFNsk=; fh=QlmRtWuTYJDhaxF0GCu0nvK7RUqeTMNKD6hMg0kv7eo=; b=lK6FY/+MInfgO2EbVaMV+rTGq8jrLcTob5ZOzp/+EMxCFJcvj65p9q0gQZw9r4z+sw bZLogEmj8Oex+3jcXw8a5O80UwzcM9XrluT2OCgI8t8IxdmvcxkfmT/8B2FtMwQ/iKUD T2P/TpkmWj9jiEycYaecPvA0t+dgQ0jTZBsHjf6ICq61KxAn/1u9Ek3rk6nyvP+iWYSi 8epYgEIXENo/mFaHBGePrwlSImshmUo0PzJHxJW6Ybatj3kGMLr9goQqTd87y3tGGCnv IxCxTvBslmI7++Ra7VLXMcmyu98vbVbd159igeayjet2Cn22Wj+XUd5NvAmI4r+PxlDT uoLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id fc5-20020a056a002e0500b006be1dd2313asi10216457pfb.210.2023.11.15.03.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 03:34:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 663CC802644A; Wed, 15 Nov 2023 03:34:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234939AbjKOLeA (ORCPT + 28 others); Wed, 15 Nov 2023 06:34:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbjKOLd5 (ORCPT ); Wed, 15 Nov 2023 06:33:57 -0500 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC8ACC for ; Wed, 15 Nov 2023 03:33:54 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=cruzzhao@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VwSxxN2_1700048031; Received: from localhost.localdomain(mailfrom:CruzZhao@linux.alibaba.com fp:SMTPD_---0VwSxxN2_1700048031) by smtp.aliyun-inc.com; Wed, 15 Nov 2023 19:33:51 +0800 From: Cruz Zhao To: mingo@redhat.com, peterz@infradead.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, joel@joelfernandes.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/4] sched/core: introduce core_id to struct rq Date: Wed, 15 Nov 2023 19:33:38 +0800 Message-Id: <20231115113341.13261-2-CruzZhao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231115113341.13261-1-CruzZhao@linux.alibaba.com> References: <20231115113341.13261-1-CruzZhao@linux.alibaba.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 03:34:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782629609198699763 X-GMAIL-MSGID: 1782629609198699763 Introduce core_id to struct rq, indates the cpu id of the core, which is used for getting cpu id of rq->core quickly. Signed-off-by: Cruz Zhao --- kernel/sched/core.c | 16 ++++++++++++---- kernel/sched/sched.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a708d225c28e..7a685fae73c4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6400,7 +6400,7 @@ static void sched_core_cpu_starting(unsigned int cpu) { const struct cpumask *smt_mask = cpu_smt_mask(cpu); struct rq *rq = cpu_rq(cpu), *core_rq = NULL; - int t; + int t, core_id; guard(core_lock)(&cpu); @@ -6417,6 +6417,7 @@ static void sched_core_cpu_starting(unsigned int cpu) rq = cpu_rq(t); if (rq->core == rq) { core_rq = rq; + core_id = t; break; } } @@ -6428,8 +6429,10 @@ static void sched_core_cpu_starting(unsigned int cpu) for_each_cpu(t, smt_mask) { rq = cpu_rq(t); - if (t == cpu) + if (t == cpu) { rq->core = core_rq; + rq->core_id = core_id; + } WARN_ON_ONCE(rq->core != core_rq); } @@ -6439,7 +6442,7 @@ static void sched_core_cpu_deactivate(unsigned int cpu) { const struct cpumask *smt_mask = cpu_smt_mask(cpu); struct rq *rq = cpu_rq(cpu), *core_rq = NULL; - int t; + int t, core_id; guard(core_lock)(&cpu); @@ -6458,6 +6461,7 @@ static void sched_core_cpu_deactivate(unsigned int cpu) if (t == cpu) continue; core_rq = cpu_rq(t); + core_id = t; break; } @@ -6483,6 +6487,7 @@ static void sched_core_cpu_deactivate(unsigned int cpu) for_each_cpu(t, smt_mask) { rq = cpu_rq(t); rq->core = core_rq; + rq->core_id = core_id; } } @@ -6490,8 +6495,10 @@ static inline void sched_core_cpu_dying(unsigned int cpu) { struct rq *rq = cpu_rq(cpu); - if (rq->core != rq) + if (rq->core != rq) { rq->core = rq; + rq->core_id = cpu; + } } #else /* !CONFIG_SCHED_CORE */ @@ -10008,6 +10015,7 @@ void __init sched_init(void) #ifdef CONFIG_SCHED_CORE rq->core = rq; + rq->core_id = i; rq->core_pick = NULL; rq->core_enabled = 0; rq->core_tree = RB_ROOT; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 2e5a95486a42..1b62165fc840 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1121,6 +1121,7 @@ struct rq { #ifdef CONFIG_SCHED_CORE /* per rq */ struct rq *core; + unsigned int core_id; struct task_struct *core_pick; unsigned int core_enabled; unsigned int core_sched_seq;