From: Dmitry Eremin Date: Fri, 21 Oct 2016 12:10:39 +0000 (+0300) Subject: LU-8703 libcfs: use int type for CPT identification. X-Git-Tag: 2.9.56~21 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bcb737a19433e3e32df6a826f29d15a3666f54d8 LU-8703 libcfs: use int type for CPT identification. This patch bring the lustre CPT code into alignment with the Linux kernel. * use int type for CPT identification like CPU identification. * fix coding style. Change-Id: I5df33f37757eb6d47ab4e824ec1b800a40730f61 Signed-off-by: Dmitry Eremin Reviewed-on: https://review.whamcloud.com/23304 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Doug Oucharek Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/libcfs_cpu.h b/libcfs/include/libcfs/libcfs_cpu.h index 07d53d0..9fd28ce 100644 --- a/libcfs/include/libcfs/libcfs_cpu.h +++ b/libcfs/include/libcfs/libcfs_cpu.h @@ -103,7 +103,7 @@ 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); +struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt); /** * print string information of cpt-table */ @@ -115,8 +115,7 @@ int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len); /** * return total number of CPU partitions in \a cptab */ -int -cfs_cpt_number(struct cfs_cpt_table *cptab); +int cfs_cpt_number(struct cfs_cpt_table *cptab); /** * return number of HW cores or hypter-threadings in a CPU partition \a cpt */ @@ -166,13 +165,14 @@ void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu); * add all cpus in \a mask to CPU partition \a cpt * return 1 if successfully set all CPUs, otherwise return 0 */ -int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, - int cpt, const cpumask_t *mask); + +int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, + const cpumask_t *mask); /** * remove all cpus in \a mask from CPU partition \a cpt */ -void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, - int cpt, const cpumask_t *mask); +void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, + const cpumask_t *mask); /** * add all cpus in NUMA node \a node to CPU partition \a cpt * return 1 if successfully set all CPUs, otherwise return 0 @@ -187,13 +187,13 @@ void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node); * add all cpus in node mask \a mask to CPU partition \a cpt * return 1 if successfully set all CPUs, otherwise return 0 */ -int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, - int cpt, nodemask_t *mask); +int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, + const nodemask_t *mask); /** * remove all cpus in node mask \a mask from CPU partition \a cpt */ -void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, - int cpt, nodemask_t *mask); +void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, + const nodemask_t *mask); /** * convert partition id \a cpt to numa node id, if there are more than one * nodes in this partition, it might return a different node id each time. diff --git a/libcfs/include/libcfs/linux/linux-cpu.h b/libcfs/include/libcfs/linux/linux-cpu.h index 12cde1f..de5e97d 100644 --- a/libcfs/include/libcfs/linux/linux-cpu.h +++ b/libcfs/include/libcfs/linux/linux-cpu.h @@ -65,17 +65,17 @@ struct cfs_cpu_partition { /* NUMA distance between CPTs */ unsigned *cpt_distance; /* spread rotor for NUMA allocator */ - unsigned cpt_spread_rotor; + int cpt_spread_rotor; }; /** descriptor for CPU partitions */ struct cfs_cpt_table { /* spread rotor for NUMA allocator */ - unsigned ctb_spread_rotor; + int ctb_spread_rotor; /* maximum NUMA distance between all nodes in table */ unsigned ctb_distance; /* # of CPU partitions */ - unsigned ctb_nparts; + int ctb_nparts; /* partitions tables */ struct cfs_cpu_partition *ctb_parts; /* shadow HW CPU to CPU partition ID */ diff --git a/libcfs/libcfs/libcfs_cpu.c b/libcfs/libcfs/libcfs_cpu.c index b646875..209333e 100644 --- a/libcfs/libcfs/libcfs_cpu.c +++ b/libcfs/libcfs/libcfs_cpu.c @@ -38,7 +38,7 @@ #include /** Global CPU partition table */ -struct cfs_cpt_table *cfs_cpt_table __read_mostly = NULL; +struct cfs_cpt_table *cfs_cpt_table __read_mostly = NULL; EXPORT_SYMBOL(cfs_cpt_table); #ifndef HAVE_LIBCFS_CPT @@ -47,8 +47,7 @@ EXPORT_SYMBOL(cfs_cpt_table); #define CFS_CPT_DISTANCE 1 /* Arbitrary positive value */ -struct cfs_cpt_table * -cfs_cpt_table_alloc(unsigned int ncpt) +struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt) { struct cfs_cpt_table *cptab; @@ -69,8 +68,7 @@ cfs_cpt_table_alloc(unsigned int ncpt) } EXPORT_SYMBOL(cfs_cpt_table_alloc); -void -cfs_cpt_table_free(struct cfs_cpt_table *cptab) +void cfs_cpt_table_free(struct cfs_cpt_table *cptab) { LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC); @@ -78,10 +76,9 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) } EXPORT_SYMBOL(cfs_cpt_table_free); -int -cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) +int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) { - int rc = 0; + int rc = 0; rc = snprintf(buf, len, "%d\t: %d\n", 0, 0); len -= rc; @@ -92,8 +89,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) } EXPORT_SYMBOL(cfs_cpt_table_print); -int -cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) +int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) { int rc = 0; @@ -106,138 +102,121 @@ cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) } EXPORT_SYMBOL(cfs_cpt_distance_print); -int -cfs_cpt_number(struct cfs_cpt_table *cptab) +int cfs_cpt_number(struct cfs_cpt_table *cptab) { return 1; } EXPORT_SYMBOL(cfs_cpt_number); -int -cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) { return 1; } EXPORT_SYMBOL(cfs_cpt_weight); -int -cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) { return 1; } EXPORT_SYMBOL(cfs_cpt_online); -cpumask_t * -cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) +cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) { return &cptab->ctb_mask; } EXPORT_SYMBOL(cfs_cpt_cpumask); -nodemask_t * -cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt) +nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt) { return &cptab->ctb_nodemask; } EXPORT_SYMBOL(cfs_cpt_nodemask); -unsigned -cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2) +unsigned cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2) { return CFS_CPT_DISTANCE; } EXPORT_SYMBOL(cfs_cpt_distance); -int -cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) +int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) { return 1; } EXPORT_SYMBOL(cfs_cpt_set_cpu); -void -cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) +void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) { } EXPORT_SYMBOL(cfs_cpt_unset_cpu); -int -cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, const cpumask_t *mask) +int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, + const cpumask_t *mask) { return 1; } EXPORT_SYMBOL(cfs_cpt_set_cpumask); -void -cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, - const cpumask_t *mask) +void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, + const cpumask_t *mask) { } EXPORT_SYMBOL(cfs_cpt_unset_cpumask); -int -cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) +int cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) { return 1; } EXPORT_SYMBOL(cfs_cpt_set_node); -void -cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node) +void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node) { } EXPORT_SYMBOL(cfs_cpt_unset_node); -int -cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask) +int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, + const nodemask_t *mask) { return 1; } EXPORT_SYMBOL(cfs_cpt_set_nodemask); -void -cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask) +void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, + const nodemask_t *mask) { } EXPORT_SYMBOL(cfs_cpt_unset_nodemask); -int -cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) { return 0; } EXPORT_SYMBOL(cfs_cpt_spread_node); -int -cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) +int cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) { return 0; } EXPORT_SYMBOL(cfs_cpt_current); -int -cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) +int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) { return 0; } EXPORT_SYMBOL(cfs_cpt_of_cpu); -int -cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node) +int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node) { return 0; } EXPORT_SYMBOL(cfs_cpt_of_node); -int -cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) { return 0; } EXPORT_SYMBOL(cfs_cpt_bind); -void -cfs_cpu_fini(void) +void cfs_cpu_fini(void) { if (cfs_cpt_table != NULL) { cfs_cpt_table_free(cfs_cpt_table); @@ -245,8 +224,7 @@ cfs_cpu_fini(void) } } -int -cfs_cpu_init(void) +int cfs_cpu_init(void) { cfs_cpt_table = cfs_cpt_table_alloc(1); diff --git a/libcfs/libcfs/linux/linux-cpu.c b/libcfs/libcfs/linux/linux-cpu.c index 63bec8c..3f4f8e7 100644 --- a/libcfs/libcfs/linux/linux-cpu.c +++ b/libcfs/libcfs/linux/linux-cpu.c @@ -47,7 +47,7 @@ * 1 : disable multiple partitions * >1 : specify number of partitions */ -static int cpu_npartitions; +static int cpu_npartitions; module_param(cpu_npartitions, int, 0444); MODULE_PARM_DESC(cpu_npartitions, "# of CPU partitions"); @@ -64,12 +64,11 @@ MODULE_PARM_DESC(cpu_npartitions, "# of CPU partitions"); * * NB: If user specified cpu_pattern, cpu_npartitions will be ignored */ -static char *cpu_pattern = "N"; +static char *cpu_pattern = "N"; module_param(cpu_pattern, charp, 0444); MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern"); -void -cfs_cpt_table_free(struct cfs_cpt_table *cptab) +void cfs_cpt_table_free(struct cfs_cpt_table *cptab) { int i; @@ -115,11 +114,10 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) } EXPORT_SYMBOL(cfs_cpt_table_free); -struct cfs_cpt_table * -cfs_cpt_table_alloc(unsigned int ncpt) +struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt) { struct cfs_cpt_table *cptab; - int i; + int i; LIBCFS_ALLOC(cptab, sizeof(*cptab)); if (cptab == NULL) @@ -178,8 +176,7 @@ failed: } EXPORT_SYMBOL(cfs_cpt_table_alloc); -int -cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) +int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) { char *tmp = buf; int rc = -EFBIG; @@ -218,8 +215,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) } EXPORT_SYMBOL(cfs_cpt_table_print); -int -cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) +int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) { char *tmp = buf; int rc = -EFBIG; @@ -259,15 +255,13 @@ cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) } EXPORT_SYMBOL(cfs_cpt_distance_print); -int -cfs_cpt_number(struct cfs_cpt_table *cptab) +int cfs_cpt_number(struct cfs_cpt_table *cptab) { return cptab->ctb_nparts; } EXPORT_SYMBOL(cfs_cpt_number); -int -cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) { LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); @@ -277,8 +271,7 @@ cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) } EXPORT_SYMBOL(cfs_cpt_weight); -int -cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) { LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); @@ -290,8 +283,7 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) } EXPORT_SYMBOL(cfs_cpt_online); -cpumask_t * -cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) +cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) { LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); @@ -300,8 +292,7 @@ cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) } EXPORT_SYMBOL(cfs_cpt_cpumask); -nodemask_t * -cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt) +nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt) { LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); @@ -310,8 +301,7 @@ cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt) } EXPORT_SYMBOL(cfs_cpt_nodemask); -unsigned -cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2) +unsigned cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2) { LASSERT(cpt1 == CFS_CPT_ANY || (cpt1 >= 0 && cpt1 < cptab->ctb_nparts)); LASSERT(cpt2 == CFS_CPT_ANY || (cpt2 >= 0 && cpt2 < cptab->ctb_nparts)); @@ -327,8 +317,8 @@ EXPORT_SYMBOL(cfs_cpt_distance); * Calculate the maximum NUMA distance between all nodes in the * from_mask and all nodes in the to_mask. */ -static unsigned -cfs_cpt_distance_calculate(nodemask_t *from_mask, nodemask_t *to_mask) +static unsigned cfs_cpt_distance_calculate(nodemask_t *from_mask, + nodemask_t *to_mask) { unsigned maximum; unsigned distance; @@ -440,8 +430,7 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node) } } -int -cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) +int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) { LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts); @@ -466,8 +455,7 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) } EXPORT_SYMBOL(cfs_cpt_set_cpu); -void -cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) +void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) { LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); @@ -499,8 +487,8 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) } EXPORT_SYMBOL(cfs_cpt_unset_cpu); -int -cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, const cpumask_t *mask) +int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, + const cpumask_t *mask) { int cpu; @@ -520,9 +508,8 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, const cpumask_t *mask) } EXPORT_SYMBOL(cfs_cpt_set_cpumask); -void -cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, - const cpumask_t *mask) +void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, + const cpumask_t *mask) { int cpu; @@ -531,8 +518,7 @@ cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, } EXPORT_SYMBOL(cfs_cpt_unset_cpumask); -int -cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) +int cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) { const cpumask_t *mask; int cpu; @@ -554,8 +540,7 @@ cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) } EXPORT_SYMBOL(cfs_cpt_set_node); -void -cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node) +void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node) { const cpumask_t *mask; int cpu; @@ -575,8 +560,8 @@ cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node) } EXPORT_SYMBOL(cfs_cpt_unset_node); -int -cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask) +int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, + const nodemask_t *mask) { int i; @@ -589,8 +574,8 @@ cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask) } EXPORT_SYMBOL(cfs_cpt_set_nodemask); -void -cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask) +void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, + const nodemask_t *mask) { int i; @@ -631,11 +616,10 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) } EXPORT_SYMBOL(cfs_cpt_spread_node); -int -cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) +int cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) { - int cpu = smp_processor_id(); - int cpt = cptab->ctb_cpu2cpt[cpu]; + int cpu = smp_processor_id(); + int cpt = cptab->ctb_cpu2cpt[cpu]; if (cpt < 0) { if (!remap) @@ -650,8 +634,7 @@ cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) } EXPORT_SYMBOL(cfs_cpt_current); -int -cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) +int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) { LASSERT(cpu >= 0 && cpu < nr_cpu_ids); @@ -659,8 +642,7 @@ cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) } EXPORT_SYMBOL(cfs_cpt_of_cpu); -int -cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node) +int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node) { if (node < 0 || node > nr_node_ids) return CFS_CPT_ANY; @@ -669,8 +651,7 @@ cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node) } EXPORT_SYMBOL(cfs_cpt_of_node); -int -cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) +int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) { cpumask_t *cpumask; nodemask_t *nodemask; @@ -715,14 +696,14 @@ EXPORT_SYMBOL(cfs_cpt_bind); * Choose max to \a number CPUs from \a node and set them in \a cpt. * We always prefer to choose CPU in the same core/socket. */ -static int -cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, - cpumask_t *node, int number) +static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, + cpumask_t *node, int number) { - cpumask_t *socket = NULL; - cpumask_t *core = NULL; - int rc = 0; - int cpu; + cpumask_t *socket = NULL; + cpumask_t *core = NULL; + int rc = 0; + int cpu; + int i; LASSERT(number > 0); @@ -756,8 +737,6 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, LASSERT(!cpumask_empty(socket)); while (!cpumask_empty(socket)) { - int i; - /* get cpumask for hts in the same core */ cpumask_copy(core, topology_sibling_cpumask(cpu)); cpumask_and(core, core, node); @@ -789,14 +768,13 @@ out: return rc; } -#define CPT_WEIGHT_MIN 4u +#define CPT_WEIGHT_MIN 4 -static unsigned int -cfs_cpt_num_estimate(void) +static int cfs_cpt_num_estimate(void) { - unsigned nnode = num_online_nodes(); - unsigned ncpu = num_online_cpus(); - unsigned ncpt; + int nnode = num_online_nodes(); + int ncpu = num_online_cpus(); + int ncpt; if (ncpu <= CPT_WEIGHT_MIN) { ncpt = 1; @@ -823,7 +801,7 @@ out: #if (BITS_PER_LONG == 32) /* config many CPU partitions on 32-bit system could consume * too much memory */ - ncpt = min(2U, ncpt); + ncpt = min(2, ncpt); #endif while (ncpu % ncpt != 0) ncpt--; /* worst case is 1 */ @@ -831,15 +809,14 @@ out: return ncpt; } -static struct cfs_cpt_table * -cfs_cpt_table_create(int ncpt) +static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt) { struct cfs_cpt_table *cptab = NULL; - cpumask_t *mask = NULL; - int cpt = 0; - int num; - int rc; - int i; + cpumask_t *mask = NULL; + int cpt = 0; + int num; + int rc; + int i; rc = cfs_cpt_num_estimate(); if (ncpt <= 0) @@ -883,7 +860,7 @@ cfs_cpt_table_create(int ncpt) while (!cpumask_empty(mask)) { struct cfs_cpu_partition *part; - int n; + int n; /* Each emulated NUMA node has all allowed CPUs in * the mask. @@ -1084,11 +1061,11 @@ cfs_cpt_table_create_pattern(char *pattern) } #ifdef CONFIG_HOTPLUG_CPU -static int -cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) +static int cfs_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { - unsigned int cpu = (unsigned long)hcpu; - bool warn; + int cpu = (unsigned long)hcpu; + bool warn; switch (action) { case CPU_DEAD: @@ -1121,8 +1098,7 @@ static struct notifier_block cfs_cpu_notifier = { #endif -void -cfs_cpu_fini(void) +void cfs_cpu_fini(void) { if (cfs_cpt_table != NULL) cfs_cpt_table_free(cfs_cpt_table); @@ -1132,8 +1108,7 @@ cfs_cpu_fini(void) #endif } -int -cfs_cpu_init(void) +int cfs_cpu_init(void) { LASSERT(cfs_cpt_table == NULL);