From patchwork Sat Mar 25 18:55:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 13187868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC258C77B62 for ; Sat, 25 Mar 2023 18:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjCYS4D (ORCPT ); Sat, 25 Mar 2023 14:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjCYSzq (ORCPT ); Sat, 25 Mar 2023 14:55:46 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B07DAF28; Sat, 25 Mar 2023 11:55:34 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-17ec8963db8so5181768fac.8; Sat, 25 Mar 2023 11:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679770533; 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=80EoVBEKXGhEC7DVbLvz7+NhEf3OhSH5JGMlSI/ra5A=; b=c8WsDxlz69yIcMrnWmunFeF8il5WqHtJorGM/XyYJMs70iYPpv46nPF3dBqd99BpdJ W0tVNf8ydUgVClyx+RzGKWpnA6plQ0v92jsxCYGYKtfurnBrzy5HIx8GTebIM5UvKc8K cPEj5R/aDqPk8/ipAO563cTqT+9eZa2AkYCykRNQ681RoYk+C+rB35p4Jo+fP5r3/gkk Yu8YNxArGyyOn5B92nmuhn4yeTOIWzghjpMJhbhxZudr9uE/XLR7rBrEWZ5zOdic6DEi OV6kMH1AZMifMfTcdPIObyunInhhcxBJrgGmzTkzlNB/LQ8CSTi+uLeLh89tAle6fdf7 n6rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679770533; 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=80EoVBEKXGhEC7DVbLvz7+NhEf3OhSH5JGMlSI/ra5A=; b=qkzIjblQ7V0ns/lACgQ9p19HeUQG8NDYdtxP1zqu37VRNvr922pzNQ3YOvyOx/t5eO 3ladYl2JVUCA4RQXsdZB0iK29bjg4qwVam9LbxG79kaoAkdDDM3imQaDbJak6HWwEmtw /yo8NNh3mQcmvNG1svQhEv43j5IR2bfOtsqpro8PYWuRgI9q/PQrHdhsyO0zRH/88cFU LMxnRQzvq64Lpm2LqTx+nR0d7vR0mD6Xr3vLfD2XlCEpPcly8tOVecjdPp3Q18SW8JLn /GD04BHMrTp0jv3MdK8wbxpXuwl49sAul2LtnlgRdLgiyylsVfhOIWchTFjyHqjGeota 1hnQ== X-Gm-Message-State: AAQBX9eN7BeMU5p/KpXaPfIxPI3au3GqqfGhFQHaowedlyT7Wyq4fhVk Nsq/LZGbyV3dfqMw3v5VOJ0= X-Google-Smtp-Source: AK7set+O8JFz+domrA0SIlDcc8yGfcVInje+7s5pfnwITfnb0uJTS8w6y359YhsEL4fO176jhWxetw== X-Received: by 2002:a05:6870:9a14:b0:17e:e1ac:2f09 with SMTP id fo20-20020a0568709a1400b0017ee1ac2f09mr3772222oab.47.1679770533215; Sat, 25 Mar 2023 11:55:33 -0700 (PDT) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id q132-20020acac08a000000b0037fa035f4f3sm9542212oif.53.2023.03.25.11.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 11:55:32 -0700 (PDT) From: Yury Norov To: Jakub Kicinski , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yury Norov , Saeed Mahameed , Pawel Chmielewski , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Tariq Toukan , Gal Pressman , Greg Kroah-Hartman , Heiko Carstens , Barry Song Subject: [PATCH 6/8] sched/topology: export sched_domains_numa_levels Date: Sat, 25 Mar 2023 11:55:12 -0700 Message-Id: <20230325185514.425745-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230325185514.425745-1-yury.norov@gmail.com> References: <20230325185514.425745-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The following patch adds a test for NUMA-aware CPU enumerators, and it requires an access to sched_domains_numa_levels. Signed-off-by: Yury Norov --- include/linux/topology.h | 7 +++++++ kernel/sched/topology.c | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/topology.h b/include/linux/topology.h index 62a9dd8edd77..3d8d486c817d 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -43,6 +43,13 @@ for_each_online_node(node) \ if (nr_cpus_node(node)) +#ifdef CONFIG_NUMA +extern int __sched_domains_numa_levels; +#define sched_domains_numa_levels ((const int)__sched_domains_numa_levels) +#else +#define sched_domains_numa_levels (1) +#endif + int arch_update_cpu_topology(void); /* Conform to ACPI 2.0 SLIT distance definitions */ diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 1860d9487fe1..5f5f994a56da 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1508,7 +1508,9 @@ static void claim_allocations(int cpu, struct sched_domain *sd) #ifdef CONFIG_NUMA enum numa_topology_type sched_numa_topology_type; -static int sched_domains_numa_levels; +int __sched_domains_numa_levels; +EXPORT_SYMBOL_GPL(__sched_domains_numa_levels); + static int sched_domains_curr_level; int sched_max_numa_distance; @@ -1872,7 +1874,7 @@ void sched_init_numa(int offline_node) * * We reset it to 'nr_levels' at the end of this function. */ - sched_domains_numa_levels = 0; + __sched_domains_numa_levels = 0; masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL); if (!masks) @@ -1948,7 +1950,7 @@ void sched_init_numa(int offline_node) sched_domain_topology_saved = sched_domain_topology; sched_domain_topology = tl; - sched_domains_numa_levels = nr_levels; + __sched_domains_numa_levels = nr_levels; WRITE_ONCE(sched_max_numa_distance, sched_domains_numa_distance[nr_levels - 1]); init_numa_topology_type(offline_node); @@ -1961,7 +1963,7 @@ static void sched_reset_numa(void) struct cpumask ***masks; nr_levels = sched_domains_numa_levels; - sched_domains_numa_levels = 0; + __sched_domains_numa_levels = 0; sched_max_numa_distance = 0; sched_numa_topology_type = NUMA_DIRECT; distances = sched_domains_numa_distance;