Re: [PATCH 4/6] staging: lustre: rearrange placement of CPU partition management code.
> Currently the code for cpu-partition tables lives in various places. > The non-SMP code is partly in libcfs/libcfs_cpu.h as static inlines, > and partly in lnet/libcfs/libcfs_cpu.c - some of the functions are > tiny and could well be inlines. > > The SMP code is all in lnet/libcfs/linux/linux-cpu.c. > > This patch moves all the trivial non-SMP functions into > libcfs_cpu.h as inlines, and all the SMP functions into libcfs_cpu.c > with the non-trival !SMP code. > > Now when you go looking for some function, it is easier to find both > versions together when neither is trivial. > > There is no code change here - just code movement. > > Signed-off-by: NeilBrownNak. SMP will be reworked. > --- > .../lustre/include/linux/libcfs/libcfs_cpu.h | 173 +++ > drivers/staging/lustre/lnet/libcfs/Makefile|1 > drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 959 +- > .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 1079 > > 4 files changed, 1076 insertions(+), 1136 deletions(-) > delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > index 829c35e68db8..813ba4564bb9 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > @@ -117,41 +117,6 @@ cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table > *cptab, int cpt); > * print string information of cpt-table > */ > int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); > -#else /* !CONFIG_SMP */ > -struct cfs_cpt_table { > - /* # of CPU partitions */ > - int ctb_nparts; > - /* cpu mask */ > - cpumask_t ctb_mask; > - /* node mask */ > - nodemask_t ctb_nodemask; > - /* version */ > - u64 ctb_version; > -}; > - > -static inline cpumask_var_t * > -cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) > -{ > - return NULL; > -} > - > -static inline int > -cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) > -{ > - return 0; > -} > -#endif /* CONFIG_SMP */ > - > -extern struct cfs_cpt_table *cfs_cpt_table; > - > -/** > - * destroy a CPU partition table > - */ > -void cfs_cpt_table_free(struct cfs_cpt_table *cptab); > -/** > - * create a cfs_cpt_table with \a ncpt number of partitions > - */ > -struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); > /** > * return total number of CPU partitions in \a cptab > */ > @@ -237,6 +202,144 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, > int cpt); > */ > int cfs_cpu_ht_nsiblings(int cpu); > > +#else /* !CONFIG_SMP */ > +struct cfs_cpt_table { > + /* # of CPU partitions */ > + int ctb_nparts; > + /* cpu mask */ > + cpumask_t ctb_mask; > + /* node mask */ > + nodemask_t ctb_nodemask; > + /* version */ > + u64 ctb_version; > +}; > + > +static inline cpumask_var_t * > +cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) > +{ > + return NULL; > +} > + > +static inline int > +cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) > +{ > + return 0; > +} > +static inline int > +cfs_cpt_number(struct cfs_cpt_table *cptab) > +{ > + return 1; > +} > + > +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 >ctb_nodemask; > +} > + > +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, cpumask_t *mask) > +{ > + return 1; > +} > + > +static inline void > +cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, 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, nodemask_t *mask) > +{ > + return 1; > +} > + > +static inline void > +cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t > *mask) > +{ > +} > + > +static inline void > +cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt) > +{ > +} > + > +static inline int > +cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) > +{ > + return
Re: [PATCH 4/6] staging: lustre: rearrange placement of CPU partition management code.
> Currently the code for cpu-partition tables lives in various places. > The non-SMP code is partly in libcfs/libcfs_cpu.h as static inlines, > and partly in lnet/libcfs/libcfs_cpu.c - some of the functions are > tiny and could well be inlines. > > The SMP code is all in lnet/libcfs/linux/linux-cpu.c. > > This patch moves all the trivial non-SMP functions into > libcfs_cpu.h as inlines, and all the SMP functions into libcfs_cpu.c > with the non-trival !SMP code. > > Now when you go looking for some function, it is easier to find both > versions together when neither is trivial. > > There is no code change here - just code movement. > > Signed-off-by: NeilBrown Nak. SMP will be reworked. > --- > .../lustre/include/linux/libcfs/libcfs_cpu.h | 173 +++ > drivers/staging/lustre/lnet/libcfs/Makefile|1 > drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 959 +- > .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 1079 > > 4 files changed, 1076 insertions(+), 1136 deletions(-) > delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > index 829c35e68db8..813ba4564bb9 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > @@ -117,41 +117,6 @@ cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table > *cptab, int cpt); > * print string information of cpt-table > */ > int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); > -#else /* !CONFIG_SMP */ > -struct cfs_cpt_table { > - /* # of CPU partitions */ > - int ctb_nparts; > - /* cpu mask */ > - cpumask_t ctb_mask; > - /* node mask */ > - nodemask_t ctb_nodemask; > - /* version */ > - u64 ctb_version; > -}; > - > -static inline cpumask_var_t * > -cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) > -{ > - return NULL; > -} > - > -static inline int > -cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) > -{ > - return 0; > -} > -#endif /* CONFIG_SMP */ > - > -extern struct cfs_cpt_table *cfs_cpt_table; > - > -/** > - * destroy a CPU partition table > - */ > -void cfs_cpt_table_free(struct cfs_cpt_table *cptab); > -/** > - * create a cfs_cpt_table with \a ncpt number of partitions > - */ > -struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); > /** > * return total number of CPU partitions in \a cptab > */ > @@ -237,6 +202,144 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, > int cpt); > */ > int cfs_cpu_ht_nsiblings(int cpu); > > +#else /* !CONFIG_SMP */ > +struct cfs_cpt_table { > + /* # of CPU partitions */ > + int ctb_nparts; > + /* cpu mask */ > + cpumask_t ctb_mask; > + /* node mask */ > + nodemask_t ctb_nodemask; > + /* version */ > + u64 ctb_version; > +}; > + > +static inline cpumask_var_t * > +cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) > +{ > + return NULL; > +} > + > +static inline int > +cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) > +{ > + return 0; > +} > +static inline int > +cfs_cpt_number(struct cfs_cpt_table *cptab) > +{ > + return 1; > +} > + > +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 >ctb_nodemask; > +} > + > +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, cpumask_t *mask) > +{ > + return 1; > +} > + > +static inline void > +cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, 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, nodemask_t *mask) > +{ > + return 1; > +} > + > +static inline void > +cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t > *mask) > +{ > +} > + > +static inline void > +cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt) > +{ > +} > + > +static inline int > +cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) > +{ > + return 0; > +} > + >