From patchwork Wed Jun 3 00:59:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11584731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D88881392 for ; Wed, 3 Jun 2020 01:00:15 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C112A2072F for ; Wed, 3 Jun 2020 01:00:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C112A2072F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 651B121F6F8; Tue, 2 Jun 2020 18:00:10 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 38EBE21F2E0 for ; Tue, 2 Jun 2020 18:00:05 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 5B98A5E2; Tue, 2 Jun 2020 21:00:02 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 559642C5; Tue, 2 Jun 2020 21:00:02 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Tue, 2 Jun 2020 20:59:40 -0400 Message-Id: <1591146001-27171-2-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591146001-27171-1-git-send-email-jsimmons@infradead.org> References: <1591146001-27171-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 01/22] lnet: libcfs: fix CPT handling for UP systems X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" If a NULL nodemask or NULL a cpumask are passed to certain Linux kernel functions can result in a crash. So for the UP case return the default cpu_online_mask, which should only have one entry, and the system nodemask defined by node_online_map. We can also remove some unused inline functions for the UP case. Fixes: 7b8e2026fb18 ("staging: lustre: remove conditional compilation from libcfs_cpu.c") WC-bug-id: https://jira.whamcloud.com/browse/LU-9859 Lustre-commit: 83a2dbe9e50d3 ("83a2dbe9e50d3a60312fa40f41052b23a3edb3ca") Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/37881 Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- include/linux/libcfs/libcfs_cpu.h | 82 ++++++++++----------------------------- net/lnet/libcfs/libcfs_cpu.c | 5 +-- 2 files changed, 23 insertions(+), 64 deletions(-) diff --git a/include/linux/libcfs/libcfs_cpu.h b/include/linux/libcfs/libcfs_cpu.h index c354dbd..4b0604a 100644 --- a/include/linux/libcfs/libcfs_cpu.h +++ b/include/linux/libcfs/libcfs_cpu.h @@ -85,9 +85,13 @@ extern struct cfs_cpt_table *cfs_cpt_tab; /** - * return cpumask of CPU partition @cpt + * destroy a CPU partition table */ -cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt); +void cfs_cpt_table_free(struct cfs_cpt_table *cptab); +/** + * create a cfs_cpt_table with @ncpt number of partitions + */ +struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); /** * print string information of cpt-table */ @@ -109,6 +113,10 @@ */ int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt); /** + * return cpumask of CPU partition @cpt + */ +cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt); +/** * return nodemask of CPU partition @cpt */ nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt); @@ -185,6 +193,15 @@ void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, #define cfs_cpt_tab ((struct cfs_cpt_table *)NULL) +static inline void cfs_cpt_table_free(struct cfs_cpt_table *cptab) +{ +} + +static inline struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt) +{ + return NULL; +} + static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) { @@ -214,7 +231,7 @@ static inline int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, static inline cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) { - return NULL; + return (cpumask_var_t *) cpu_online_mask; } static inline int cfs_cpt_number(struct cfs_cpt_table *cptab) @@ -227,15 +244,10 @@ static inline int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) return 1; } -static inline int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) -{ - return 1; -} - static inline nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt) { - return NULL; + return &node_online_map; } static inline unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, @@ -244,50 +256,12 @@ static inline unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, return 1; } -static inline int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, - int cpu) -{ - return 1; -} - -static inline void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, - int cpu) -{ -} - -static inline int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, - const cpumask_t *mask) -{ - return 1; -} - -static inline void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, - const cpumask_t *mask) -{ -} - static inline int cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) { return 1; } -static inline void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, - int node) -{ -} - -static inline int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, - const nodemask_t *mask) -{ - return 1; -} - -static inline void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, - int cpt, const nodemask_t *mask) -{ -} - static inline int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) { return 0; @@ -298,11 +272,6 @@ static inline int cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) return 0; } -static inline int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) -{ - return 0; -} - static inline int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node) { return 0; @@ -324,15 +293,6 @@ static inline void cfs_cpu_fini(void) #endif /* CONFIG_SMP */ -/** - * destroy a CPU partition table - */ -void cfs_cpt_table_free(struct cfs_cpt_table *cptab); -/** - * create a cfs_cpt_table with @ncpt number of partitions - */ -struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); - /* * allocate per-cpu-partition data, returned value is an array of pointers, * variable can be indexed by CPU ID. diff --git a/net/lnet/libcfs/libcfs_cpu.c b/net/lnet/libcfs/libcfs_cpu.c index 6363fd7..8969e1f 100644 --- a/net/lnet/libcfs/libcfs_cpu.c +++ b/net/lnet/libcfs/libcfs_cpu.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -1162,13 +1161,13 @@ int cfs_cpu_init(void) #ifdef CONFIG_HOTPLUG_CPU ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, - "staging/lustre/cfe:dead", NULL, + "fs/lustre/cfe:dead", NULL, cfs_cpu_dead); if (ret < 0) goto failed_cpu_dead; ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, - "staging/lustre/cfe:online", + "fs/lustre/cfe:online", cfs_cpu_online, NULL); if (ret < 0) goto failed_cpu_online;