All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 01/22] lnet: libcfs: fix CPT handling for UP systems
Date: Tue,  2 Jun 2020 20:59:40 -0400	[thread overview]
Message-ID: <1591146001-27171-2-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1591146001-27171-1-git-send-email-jsimmons@infradead.org>

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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/37881
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 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 <linux/sched.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/cache.h>
 
 #include <linux/libcfs/libcfs_cpu.h>
 #include <linux/libcfs/libcfs_string.h>
@@ -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;
-- 
1.8.3.1

  reply	other threads:[~2020-06-03  0:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03  0:59 [lustre-devel] [PATCH 00/22] lustre: OpenSFS backport patches for May 29 2020 James Simmons
2020-06-03  0:59 ` James Simmons [this message]
2020-06-03  0:59 ` [lustre-devel] [PATCH 02/22] lustre: use BIT() macro where appropriate in include James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 03/22] lustre: use BIT() macro where appropriate James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 04/22] lustre: ptlrpc: change LONG_UNLINK to PTLRPC_REQ_LONG_UNLINK James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 05/22] lustre: llite: use %pd to report dentry names James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 06/22] lnet: tidy lnet_discover and fix mem accounting bug James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 07/22] lustre: llite: prevent MAX_DIO_SIZE 32-bit truncation James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 08/22] lustre: llite: integrate statx() API with Lustre James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 09/22] lustre: ldlm: no current source if lu_ref_del not in same tsk James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 10/22] lnet: always pass struct lnet_md by reference James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 11/22] lustre: llite: fix read if readahead window smaller than rpc size James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 12/22] lustre: obdclass: bind zombie export cleanup workqueue James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 13/22] lnet: handle discovery off properly James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 14/22] lnet: Force full discovery cycle James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 15/22] lnet: set route aliveness properly James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 16/22] lnet: Correct the default LND timeout James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 17/22] lnet: Add lnet_lnd_timeout to sysfs James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 18/22] lnet: lnd: Allow independent ko2iblnd timeout James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 19/22] lnet: lnd: Allow independent socklnd timeout James Simmons
2020-06-03  0:59 ` [lustre-devel] [PATCH 20/22] lnet: lnd: gracefully handle unexpected events James Simmons
2020-06-03  1:00 ` [lustre-devel] [PATCH 21/22] lustre: update version to 2.13.54 James Simmons
2020-06-03  1:00 ` [lustre-devel] [PATCH 22/22] lnet: procs: print new line based on distro James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1591146001-27171-2-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.