staging: lustre: two miscellaneous patches
cover staging: lustre: two miscellaneous patches
I thought I had mode one-off patches but this, but
it seems there are only two ready to go now.
The first removes another local interface in favour of a more general interface, the second removing a warning (which actually say "BUG:").
Thanks,
NeilBrown
---
NeilBrown (2):
staging: lustre: use strim instead of cfs_trimwhite.
staging: lustre: disable preempt while sampling processor id.
.../lustre/include/linux/libcfs/libcfs_string.h | 1 - drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 20 ------------------- .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 21 ++++++++++---------- drivers/staging/lustre/lnet/lnet/config.c | 10 +++++----- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- 5 files changed, 17 insertions(+), 37 deletions(-)
--
Signature
PATCH 1/2 staging: lustre: use strim instead of cfs_trimwhite.
Linux lib provides identical functionality to cfs_trimwhite, so discard that code and use the standard.
--- .../lustre/include/linux/libcfs/libcfs_string.h | 1 - drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 20 -------------------- .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 8 ++++---- drivers/staging/lustre/lnet/lnet/config.c | 10 +++++----- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- 5 files changed, 10 insertions(+), 31 deletions(-)
drivers/staging/lustre/include/linux/libcfs/libcfs_string.h +0 -1
@@ -73,7 +73,6 @@ struct cfs_expr_list {struct list_head el_exprs; }; -char *cfs_trimwhite (char *str);int cfs_gettok (struct cfs_lstr *next,char delim,struct cfs_lstr *res);int cfs_str2num_check (char *str,int nob,unsigned int *num,unsigned int min,unsigned int max);
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +0 -20
@@ -137,26 +137,6 @@ char *cfs_firststr(char *str, size_t size) }EXPORT_SYMBOL (cfs_firststr); -char * -cfs_trimwhite (char *str) -{ -char *end; - -while (isspace (*str)) - str++; - - end = str +strlen (str); -while (end > str) { -if (!isspace (end[-1 ])) -break ; - end--; - } - - *end =0 ; -return str; -} -EXPORT_SYMBOL (cfs_trimwhite); -/** * Extracts tokens from strings. *
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +4 -4
@@ -818,7 +818,7 @@ cfs_cpt_table_create_pattern(char *pattern)int c;int i; - str =cfs_trimwhite (pattern); + str =strim (pattern);if (*str =='n' || *str =='N' ) { pattern = str +1 ;if (*pattern !='\0' ) {
@@ -870,7 +870,7 @@ cfs_cpt_table_create_pattern(char *pattern) high = node ?MAX_NUMNODES -1 : nr_cpu_ids -1 ; -for (str =cfs_trimwhite (pattern), c =0 ;; c++) { +for (str =strim (pattern), c =0 ;; c++) {struct cfs_range_expr *range;struct cfs_expr_list *el;char *bracket =strchr (str,'[' );
@@ -905,7 +905,7 @@ cfs_cpt_table_create_pattern(char *pattern) goto failed; } - str =cfs_trimwhite (str + n); + str =strim (str + n);if (str != bracket) {CERROR ("Invalid pattern %s\n" , str); goto failed;
@@ -945,7 +945,7 @@ cfs_cpt_table_create_pattern(char *pattern) goto failed; } - str =cfs_trimwhite (bracket +1 ); + str =strim (bracket +1 ); }return cptab;
drivers/staging/lustre/lnet/lnet/config.c +5 -5
@@ -269,7 +269,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)if (comma) *comma++ =0 ; - net =libcfs_str2net (cfs_trimwhite (str)); + net =libcfs_str2net (strim (str));if (net ==LNET_NIDNET (LNET_NID_ANY )) { LCONSOLE_ERROR_MSG(0x113,
@@ -292,7 +292,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) } *bracket =0 ; - net =libcfs_str2net (cfs_trimwhite (str)); + net =libcfs_str2net (strim (str));if (net ==LNET_NIDNET (LNET_NID_ANY )) { tmp = str; goto failed_syntax;
@@ -322,7 +322,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)if (comma) *comma++ =0 ; - iface =cfs_trimwhite (iface); + iface =strim (iface);if (!*iface) { tmp = iface; goto failed_syntax;
@@ -356,7 +356,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) comma =strchr (bracket +1 ,',' );if (comma) { *comma =0 ; - str =cfs_trimwhite (str); + str =strim (str);if (*str) { tmp = str; goto failed_syntax;
@@ -365,7 +365,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)continue ; } - str =cfs_trimwhite (str); + str =strim (str);if (*str) { tmp = str; goto failed_syntax;
drivers/staging/lustre/lnet/lnet/router_proc.c +1 -1
@@ -829,7 +829,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,if (rc <0 ) goto out; - tmp =cfs_trimwhite (buf); + tmp =strim (buf); rc = -EINVAL ;lnet_res_lock (0 );
Re: [PATCH 1/2] staging: lustre: use strim instead of cfs_trimwhite.
Quoted 5 lines · NeilBrown
Linux lib provides identical functionality to
cfs_trimwhite, so discard that code and use the standard.Signed-off-by NeilBrown <[email protected]>
Quoted 147 lines
---
.../lustre/include/linux/libcfs/libcfs_string.h | 1 - drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 20 -------------------- .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 8 ++++---- drivers/staging/lustre/lnet/lnet/config.c | 10 +++++----- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- 5 files changed, 10 insertions(+), 31 deletions(-)drivers/staging/lustre/include/linux/libcfs/libcfs_string.h +0
-1@@ -73,7 +73,6 @@ struct cfs_expr_list {struct list_head el_exprs; }; -char *cfs_trimwhite (char *str);int cfs_gettok (struct cfs_lstr *next,char delim,struct cfs_lstr *res);int cfs_str2num_check (char *str,int nob,unsigned int *num,unsigned int min,unsigned int max);drivers/staging/lustre/lnet/libcfs/libcfs_string.c +0
-20@@ -137,26 +137,6 @@ char *cfs_firststr(char *str, size_t size) }EXPORT_SYMBOL (cfs_firststr); -char * -cfs_trimwhite (char *str) -{ -char *end; - -while (isspace (*str)) - str++; - - end = str +strlen (str); -while (end > str) { -if (!isspace (end[-1 ])) -break ; - end--; - } - - *end =0 ; -return str; -} -EXPORT_SYMBOL (cfs_trimwhite); -/** * Extracts tokens from strings. * drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +4
-4@@ -818,7 +818,7 @@ cfs_cpt_table_create_pattern(char *pattern)int c;int i; - str =cfs_trimwhite (pattern); + str =strim (pattern);if (*str =='n' || *str =='N' ) { pattern = str +1 ;if (*pattern !='\0' ) {@@ -870,7 +870,7 @@ cfs_cpt_table_create_pattern(char *pattern) high = node ?MAX_NUMNODES -1 : nr_cpu_ids -1 ; -for (str =cfs_trimwhite (pattern), c =0 ;; c++) { +for (str =strim (pattern), c =0 ;; c++) {struct cfs_range_expr *range;struct cfs_expr_list *el;char *bracket =strchr (str,'[' );@@ -905,7 +905,7 @@ cfs_cpt_table_create_pattern(char *pattern) goto failed; } - str =cfs_trimwhite (str + n); + str =strim (str + n);if (str != bracket) {CERROR ("Invalid pattern %s\n" , str); goto failed;@@ -945,7 +945,7 @@ cfs_cpt_table_create_pattern(char *pattern) goto failed; } - str =cfs_trimwhite (bracket +1 ); + str =strim (bracket +1 ); }return cptab;drivers/staging/lustre/lnet/lnet/config.c +5
-5@@ -269,7 +269,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)if (comma) *comma++ =0 ; - net =libcfs_str2net (cfs_trimwhite (str)); + net =libcfs_str2net (strim (str));if (net ==LNET_NIDNET (LNET_NID_ANY )) { LCONSOLE_ERROR_MSG(0x113,@@ -292,7 +292,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) } *bracket =0 ; - net =libcfs_str2net (cfs_trimwhite (str)); + net =libcfs_str2net (strim (str));if (net ==LNET_NIDNET (LNET_NID_ANY )) { tmp = str; goto failed_syntax;@@ -322,7 +322,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)if (comma) *comma++ =0 ; - iface =cfs_trimwhite (iface); + iface =strim (iface);if (!*iface) { tmp = iface; goto failed_syntax;@@ -356,7 +356,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks) comma =strchr (bracket +1 ,',' );if (comma) { *comma =0 ; - str =cfs_trimwhite (str); + str =strim (str);if (*str) { tmp = str; goto failed_syntax;@@ -365,7 +365,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)continue ; } - str =cfs_trimwhite (str); + str =strim (str);if (*str) { tmp = str; goto failed_syntax;drivers/staging/lustre/lnet/lnet/router_proc.c +0
-0
drivers/staging/lustre/lnet/lnet/router_proc.c static int __proc_lnet_portal_rotor(void *data, int write, · line 835
Quoted 8 lines
drivers/staging/lustre/lnet/lnet/router_proc.c +1
-1@@ -829,7 +829,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,if (rc <0 ) goto out; - tmp =cfs_trimwhite (buf); + tmp =strim (buf); rc = -EINVAL ;lnet_res_lock (0 );
Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation
PATCH 2/2 staging: lustre: disable preempt while sampling processor id.
In reply to NeilBrownCalling smp_processor_id() without disabling preemption triggers a warning (if CONFIG_DEBUG_PREEMPT).
I think the result of cfs_cpt_current() is only used as a hint for load balancing, rather than as a precise and stable indicator of the current CPU. So it doesn't need to be called with preemption disabled.
So disable preemption inside cfs_cpt_current() to silence the warning.
--- .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +7 -6
@@ -517,19 +517,20 @@ EXPORT_SYMBOL(cfs_cpt_spread_node);int cfs_cpt_current (struct cfs_cpt_table *cptab,int remap) { -int cpu =smp_processor_id (); -int cpt = cptab->ctb_cpu2cpt[cpu]; +int cpu; +int cpt; -if (cpt <0 ) { -if (!remap) -return cpt; +preempt_disable (); + cpu =smp_processor_id (); + cpt = cptab->ctb_cpu2cpt[cpu]; +if (cpt <0 && remap) {/* don't return negative value for safety of upper layer, * instead we shadow the unknown cpu to a valid partition ID */ cpt = cpu % cptab->ctb_nparts; } - +preempt_enable ();return cpt; }EXPORT_SYMBOL (cfs_cpt_current);
Re: [PATCH 2/2] staging: lustre: disable preempt while sampling processor id.
Quoted 11 lines · NeilBrown
Calling
smp_processor_id()without disabling preemption triggers a warning (ifCONFIG_DEBUG_PREEMPT).
I think the result ofcfs_cpt_current()is only used as a hint for load balancing, rather than as a precise and stable indicator of the current CPU. So it doesn't need to be called with preemption disabled.So disable preemption inside
cfs_cpt_current()to silence the warning.Signed-off-by NeilBrown <[email protected]>
Quoted 34 lines
---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c| 13 +++++++------1 file changed, 7 insertions(+), 6 deletions(-)drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +0
-0@@ -517,19 +517,20 @@ EXPORT_SYMBOL(cfs_cpt_spread_node);int
cfs_cpt_current(struct cfs_cpt_table *cptab, int remap){drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +6
-5-int cpu =smp_processor_id (); -int cpt = cptab->ctb_cpu2cpt[cpu]; +int cpu; +int cpt; -if (cpt <0 ) { -if (!remap) -return cpt; +preempt_disable (); + cpu =smp_processor_id (); + cpt = cptab->ctb_cpu2cpt[cpu]; +if (cpt <0 && remap) {/* don't return negative value for safety of upper layer, * instead we shadow the unknown cpu to a valid partition ID */ cpt = cpu % cptab->ctb_nparts; }drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +1
-1- +preempt_enable ();return cpt; }
Quoted 3 lines
EXPORT_SYMBOL(cfs_cpt_current);
Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation