From nobody Sat Feb 7 11:38:47 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41FC538DFC; Thu, 6 Mar 2025 05:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741240448; cv=none; b=FJ9eBSd8aQRiX1wx5PPmzEUM92SPiBuDeqVhv3ej5uW+DUbnXbit+54h59Y37JyGDxP7Eef4lO7k72DPuyZARuAye+VTM5EvZT9otxWjYXd5Ci3thCYVVogjwHaNnixvw9lTRiRZmngYtLj4lSsYM6ymVx4gSKiTXqK8VJt6wPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741240448; c=relaxed/simple; bh=RtNMk6CkpnYVHyGLgMRy2qu0U5YISKGT4Rp6VgakTZU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TO77oSJMeXcQPHv9ivVrWK5r3PzE205Gy71eWWhxc412TEas4Ry5Z7Nclwdlypi2lyBTlm+Hz9N/0ogjhXwaOhMeKAQmbYxCwn7/oVExxBpXL9uZ6GMFLALLrJ7EuzbC/C5PT6p9l585E4axLhQdNE+APR/S3HFVDwqJU9+8ce0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=p5RYhwuJ; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="p5RYhwuJ" Received: from namjain-Virtual-Machine.mshome.net (unknown [167.220.238.203]) by linux.microsoft.com (Postfix) with ESMTPSA id 5638721104B2; Wed, 5 Mar 2025 21:54:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5638721104B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1741240446; bh=c9/w+F2JSYsBy5jmq+6LSxe4kArENwUiG/f1/vGprkM=; h=From:To:Cc:Subject:Date:From; b=p5RYhwuJChFPYPCnQZF/yhcB3lk2e9E9+wmdObF7RQjpYQkxdlYJ2Coe9YAN1bqc9 hV31S+cwIiG1W9Z7LWljOosQeR6FpH0zxxtpiVtPYhyeSXXhz76Qf6vnFyLsjdqhw+ ohwCiWM/4dNyNO4mxoFfTupnSdPuCg3Sbvhrdu94= From: Naman Jain To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, Steve Wahl , Saurabh Singh Sengar , srivatsa@csail.mit.edu, K Prateek Nayak , Michael Kelley , Naman Jain , Shrikanth Hegde Subject: [PATCH v4] sched/topology: Enable topology_span_sane check only for debug builds Date: Thu, 6 Mar 2025 11:23:54 +0530 Message-Id: <20250306055354.52915-1-namjain@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Saurabh Sengar On a x86 system under test with 1780 CPUs, topology_span_sane() takes around 8 seconds cumulatively for all the iterations. It is an expensive operation which does the sanity of non-NUMA topology masks. CPU topology is not something which changes very frequently hence make this check optional for the systems where the topology is trusted and need faster bootup. Restrict this to sched_verbose kernel cmdline option so that this penalty can be avoided for the systems who want to avoid it. Cc: stable@vger.kernel.org Fixes: ccf74128d66c ("sched/topology: Assert non-NUMA topology masks don't = (partially) overlap") Signed-off-by: Saurabh Sengar Co-developed-by: Naman Jain Signed-off-by: Naman Jain Tested-by: K Prateek Nayak --- Changes since v3: https://lore.kernel.org/all/20250203114738.3109-1-namjain@linux.microsoft.c= om/ - Minor typo correction in comment - Added Tested-by tag from Prateek for x86=09 Changes since v2: https://lore.kernel.org/all/1731922777-7121-1-git-send-email-ssengar@linux.= microsoft.com/ - Use sched_debug() instead of using sched_debug_verbose variable directly (addressing Prateek's comment) Changes since v1: https://lore.kernel.org/all/1729619853-2597-1-git-send-email-ssengar@linux.= microsoft.com/ - Use kernel cmdline param instead of compile time flag. Adding a link to the other patch which is under review. https://lore.kernel.org/lkml/20241031200431.182443-1-steve.wahl@hpe.com/ Above patch tries to optimize the topology sanity check, whereas this patch makes it optional. We believe both patches can coexist, as even with optimization, there will still be some performance overhead for this check. --- kernel/sched/topology.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index c49aea8c1025..666f0a18cc6c 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2359,6 +2359,13 @@ static bool topology_span_sane(struct sched_domain_t= opology_level *tl, { int i =3D cpu + 1; =20 + /* Skip the topology sanity check for non-debug, as it is a time-consumin= g operation */ + if (!sched_debug()) { + pr_info_once("%s: Skipping topology span sanity check. Use `sched_verbos= e` boot parameter to enable it.\n", + __func__); + return true; + } + /* NUMA levels are allowed to overlap */ if (tl->flags & SDTL_OVERLAP) return true; --=20 2.34.1