From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailgw1.hygon.cn (unknown [101.204.27.37]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F73930F540 for ; Mon, 12 Jan 2026 08:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.204.27.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768206271; cv=none; b=qgkdGMJAkcPMEniQtWvvhOGdNCpv5zHC3VWkY60S2n59xzw2iSZ5cMKFcv5xsNpAvMQ6bC5WFubT48rsR0hhsaF2xM+YD5pEr+te9rVGVBoM4YM9EseOsSLaH59IOnHMbqvmjfAmLDRv3qx39Jx1LNNGcwDNaB4QspzDQ8wCzOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768206271; c=relaxed/simple; bh=+KktZYbR+TjLVf7Xc4so1KTBvJLCBDO5qZSODA9khzE=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=d9YOxAjnhuL2zKY/B8QLIfXF8OQAoxnvJMYuS/c8R0A1FZzCokb8GZ14Zb1T/kJvWwFR/TEYhiQPkUQ3e8LSQYYDEiCxUAYqaSKwKDv+7epttxRoM43DMVFCWU64PEY/sH4htZIWyCRRR6YTTSiMqf91CkZcVxqPArG40qjYthQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn; spf=pass smtp.mailfrom=hygon.cn; arc=none smtp.client-ip=101.204.27.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hygon.cn Received: from maildlp1.hygon.cn (unknown [127.0.0.1]) by mailgw1.hygon.cn (Postfix) with ESMTP id 4dqPys6bKtzrTVx; Mon, 12 Jan 2026 16:03:49 +0800 (CST) Received: from maildlp1.hygon.cn (unknown [172.23.18.60]) by mailgw1.hygon.cn (Postfix) with ESMTP id 4dqPyr0RMjzrTVx; Mon, 12 Jan 2026 16:03:48 +0800 (CST) Received: from cncheex03.Hygon.cn (unknown [172.23.18.113]) by maildlp1.hygon.cn (Postfix) with ESMTPS id A18F01E5; Mon, 12 Jan 2026 16:03:44 +0800 (CST) Received: from cncheex04.Hygon.cn (172.23.18.114) by cncheex03.Hygon.cn (172.23.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Mon, 12 Jan 2026 16:03:47 +0800 Received: from cncheex04.Hygon.cn ([fe80::1b6f:6c58:58a4:430d]) by cncheex04.Hygon.cn ([fe80::1b6f:6c58:58a4:430d%10]) with mapi id 15.02.1544.036; Mon, 12 Jan 2026 16:03:47 +0800 From: Jianyong Wu To: "peterz@infradead.org" , "mingo@redhat.com" , "juri.lelli@redhat.com" , "vincent.guittot@linaro.org" CC: "dietmar.eggemann@arm.com" , "rostedt@goodmis.org" , "bsegall@google.com" , "mgorman@suse.de" , "vschneid@redhat.com" , "linux-kernel@vger.kernel.org" , "jianyong.wu@outlook.com" , Yibin Liu Subject: RE: [PATCH v2] sched/core: avoid calling select_task_rq cb if bound to one CPU for exec Thread-Topic: [PATCH v2] sched/core: avoid calling select_task_rq cb if bound to one CPU for exec Thread-Index: AQHcYrE9EXsygKCAhki1pVM3DAqoSLVObmDA Date: Mon, 12 Jan 2026 08:03:47 +0000 Message-ID: References: <20251201105545.778087-1-wujianyong@hygon.cn> In-Reply-To: <20251201105545.778087-1-wujianyong@hygon.cn> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Gentle ping. :) > -----Original Message----- > From: Jianyong Wu > Sent: Monday, December 1, 2025 6:56 PM > To: peterz@infradead.org; mingo@redhat.com; juri.lelli@redhat.com; > vincent.guittot@linaro.org > Cc: dietmar.eggemann@arm.com; rostedt@goodmis.org; > bsegall@google.com; mgorman@suse.de; vschneid@redhat.com; > linux-kernel@vger.kernel.org; jianyong.wu@outlook.com; Jianyong Wu > ; Yibin Liu > Subject: [PATCH v2] sched/core: avoid calling select_task_rq cb if bound = to > one CPU for exec >=20 > In the current implementation, even if the task calling execl is bound to= a > single CPU (or not allowed to be migrated), it still invokes the > select_task_rq callback to select a CPU. This is unnecessary and wastes > cycles. >=20 > Since select_task_rq() already includes checks for the above scenarios (e= .g., > tasks bound to a single CPU or forbidden to migrate) and skips the > select_task_rq callback in such cases, we can directly use > select_task_rq() instead of invoking the callback here. >=20 > Test environment: 256-CPU X86 server > Test method: Run unixbench's execl test with task bound to a single CPU: >=20 > $ numactl -C 10 ./Run execl -c 1 >=20 > Test results: Average of 5 runs >=20 > baseline patched improvement > 383.82 436.78 +13.8% >=20 > Change Log: >=20 > v1->v2 > As suggested by Peter, replace manual corner-case checks with > select_task_rq() to align with existing logic. >=20 > Additional testing on a 256-CPU server which all sched domains have > SD_BALANCE_EXEC flag, shows that sched_exec now searches all CPUs in > the system (previously, some SD_NUMA sched domains lacked > SD_BALANCE_EXEC). > This increased the performance improvement to 13.8%. >=20 > Suggested-by: Peter Zijlstra > Co-developed-by: Yibin Liu > Signed-off-by: Yibin Liu > Signed-off-by: Jianyong Wu > --- > kernel/sched/core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) >=20 > diff --git a/kernel/sched/core.c b/kernel/sched/core.c index > f754a60de848..6e4ba3c27e5c 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -5439,10 +5439,11 @@ void sched_exec(void) { > struct task_struct *p =3D current; > struct migration_arg arg; > - int dest_cpu; > + int dest_cpu, wake_flag =3D WF_EXEC; >=20 > scoped_guard (raw_spinlock_irqsave, &p->pi_lock) { > - dest_cpu =3D p->sched_class->select_task_rq(p, task_cpu(p), > WF_EXEC); > + dest_cpu =3D select_task_rq(p, task_cpu(p), &wake_flag); > + > if (dest_cpu =3D=3D smp_processor_id()) > return; >=20 > -- > 2.43.0