2018-04-16 04:18:06

by James Simmons

[permalink] [raw]
Subject: [PATCH 00/25] staging: lustre: libcfs: SMP rework

Recently lustre support has been expanded to extreme machines with as
many as a 1000+ cores. On the other end lustre also has been ported
to platforms like ARM and KNL which have uniquie NUMA and core setup.
For example some devices exist that have NUMA nodes with no cores.
With these new platforms the limitations of the Lustre's SMP code
came to light so a lot of work was needed. This resulted in this
patch set which has been tested on these platforms.

Amir Shehata (9):
staging: lustre: libcfs: implement cfs_cpt_cpumask for UMP case
staging: lustre: libcfs: replace MAX_NUMNODES with nr_node_ids
staging: lustre: libcfs: remove excess space
staging: lustre: libcfs: replace num_possible_cpus() with nr_cpu_ids
staging: lustre: libcfs: NUMA support
staging: lustre: libcfs: add cpu distance handling
staging: lustre: libcfs: use distance in cpu and node handling
staging: lustre: libcfs: provide debugfs files for distance handling
staging: lustre: libcfs: invert error handling for cfs_cpt_table_print

Dmitry Eremin (15):
staging: lustre: libcfs: remove useless CPU partition code
staging: lustre: libcfs: rename variable i to cpu
staging: lustre: libcfs: fix libcfs_cpu coding style
staging: lustre: libcfs: use int type for CPT identification.
staging: lustre: libcfs: rename i to node for cfs_cpt_set_nodemask
staging: lustre: libcfs: rename i to cpu for cfs_cpt_bind
staging: lustre: libcfs: rename cpumask_var_t variables to *_mask
staging: lustre: libcfs: rename goto label in cfs_cpt_table_print
staging: lustre: libcfs: clear up failure patch in cfs_cpt_*_print
staging: lustre: libcfs: update debug messages
staging: lustre: libcfs: make tolerant to offline CPUs and empty NUMA nodes
staging: lustre: libcfs: report NUMA node instead of just node
staging: lustre: libcfs: update debug messages in CPT creation code
staging: lustre: libcfs: rework CPU pattern parsing code
staging: lustre: libcfs: change CPT estimate algorithm

James Simmons (1):
staging: lustre: libcfs: merge UMP and SMP libcfs cpu header code

.../lustre/include/linux/libcfs/libcfs_cpu.h | 135 +--
.../lustre/include/linux/libcfs/linux/libcfs.h | 1 -
.../lustre/include/linux/libcfs/linux/linux-cpu.h | 78 --
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 126 ++-
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 912 +++++++++++----------
drivers/staging/lustre/lnet/libcfs/module.c | 53 ++
drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 +
7 files changed, 676 insertions(+), 631 deletions(-)
delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h

--
1.8.3.1



2018-04-16 04:12:10

by James Simmons

[permalink] [raw]
Subject: [PATCH 25/25] staging: lustre: libcfs: merge UMP and SMP libcfs cpu header code

Currently we have two headers, linux-cpu.h that contains the SMP
version and libcfs_cpu.h contains the UMP version. We can simplify
the headers into a single header which handles both cases.

Signed-off-by: James Simmons <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9859
Reviewed-on: https://review.whamcloud.com/30873
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Dmitry Eremin <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../lustre/include/linux/libcfs/libcfs_cpu.h | 67 +++++++++++------
.../lustre/include/linux/libcfs/linux/libcfs.h | 1 -
.../lustre/include/linux/libcfs/linux/linux-cpu.h | 84 ----------------------
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 18 ++---
4 files changed, 52 insertions(+), 118 deletions(-)
delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 19a3489..0611fcd 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -72,32 +72,55 @@
#ifndef __LIBCFS_CPU_H__
#define __LIBCFS_CPU_H__

-/* any CPU partition */
-#define CFS_CPT_ANY (-1)
+#include <linux/cpu.h>
+#include <linux/cpuset.h>
+#include <linux/slab.h>
+#include <linux/topology.h>
+#include <linux/version.h>

#ifdef CONFIG_SMP
-/**
- * print string information of cpt-table
- */
-int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
-#else /* !CONFIG_SMP */
+
+/** virtual processing unit */
+struct cfs_cpu_partition {
+ /* CPUs mask for this partition */
+ cpumask_var_t cpt_cpumask;
+ /* nodes mask for this partition */
+ nodemask_t *cpt_nodemask;
+ /* NUMA distance between CPTs */
+ unsigned int *cpt_distance;
+ /* spread rotor for NUMA allocator */
+ int cpt_spread_rotor;
+ /* NUMA node if cpt_nodemask is empty */
+ int cpt_node;
+};
+#endif /* CONFIG_SMP */
+
+/** descriptor for CPU partitions */
struct cfs_cpt_table {
+#ifdef CONFIG_SMP
+ /* spread rotor for NUMA allocator */
+ int ctb_spread_rotor;
+ /* maximum NUMA distance between all nodes in table */
+ unsigned int ctb_distance;
+ /* partitions tables */
+ struct cfs_cpu_partition *ctb_parts;
+ /* shadow HW CPU to CPU partition ID */
+ int *ctb_cpu2cpt;
+ /* shadow HW node to CPU partition ID */
+ int *ctb_node2cpt;
/* # of CPU partitions */
- int ctb_nparts;
- /* cpu mask */
- cpumask_var_t ctb_mask;
- /* node mask */
- nodemask_t ctb_nodemask;
- /* version */
- u64 ctb_version;
+ int ctb_nparts;
+ /* all nodes in this partition table */
+ nodemask_t *ctb_nodemask;
+#else
+ nodemask_t ctb_nodemask;
+#endif /* CONFIG_SMP */
+ /* all cpus in this partition table */
+ cpumask_var_t ctb_cpumask;
};

-static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf,
- int len)
-{
- return 0;
-}
-#endif /* CONFIG_SMP */
+/* any CPU partition */
+#define CFS_CPT_ANY (-1)

extern struct cfs_cpt_table *cfs_cpt_table;

@@ -110,6 +133,10 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf,
*/
struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt);
/**
+ * print string information of cpt-table
+ */
+int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
+/**
* print distance information of cpt-table
*/
int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len);
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 07d3cb2..07610be 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -78,7 +78,6 @@
#include <linux/timex.h>
#include <linux/uaccess.h>
#include <stdarg.h>
-#include "linux-cpu.h"

#if !defined(__x86_64__)
# ifdef __ia64__
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
deleted file mode 100644
index ed4351b..0000000
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-cpu.h
- *
- * Basic library routines.
- *
- * Author: [email protected]
- */
-
-#ifndef __LIBCFS_LINUX_CPU_H__
-#define __LIBCFS_LINUX_CPU_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
-#endif
-
-#include <linux/cpu.h>
-#include <linux/cpuset.h>
-#include <linux/topology.h>
-
-#ifdef CONFIG_SMP
-
-#define HAVE_LIBCFS_CPT
-
-/** virtual processing unit */
-struct cfs_cpu_partition {
- /* CPUs mask for this partition */
- cpumask_var_t cpt_cpumask;
- /* nodes mask for this partition */
- nodemask_t *cpt_nodemask;
- /* NUMA distance between CPTs */
- unsigned int *cpt_distance;
- /* spread rotor for NUMA allocator */
- int cpt_spread_rotor;
- /* NUMA node if cpt_nodemask is empty */
- int cpt_node;
-};
-
-/** descriptor for CPU partitions */
-struct cfs_cpt_table {
- /* spread rotor for NUMA allocator */
- int ctb_spread_rotor;
- /* maximum NUMA distance between all nodes in table */
- unsigned int ctb_distance;
- /* # of CPU partitions */
- int ctb_nparts;
- /* partitions tables */
- struct cfs_cpu_partition *ctb_parts;
- /* shadow HW CPU to CPU partition ID */
- int *ctb_cpu2cpt;
- /* all cpus in this partition table */
- cpumask_var_t ctb_cpumask;
- /* shadow HW node to CPU partition ID */
- int *ctb_node2cpt;
- /* all nodes in this partition table */
- nodemask_t *ctb_nodemask;
-};
-
-#endif /* CONFIG_SMP */
-#endif /* __LIBCFS_LINUX_CPU_H__ */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 5d7d44d..1df7a1b 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -37,9 +37,7 @@
struct cfs_cpt_table *cfs_cpt_table __read_mostly;
EXPORT_SYMBOL(cfs_cpt_table);

-#ifndef HAVE_LIBCFS_CPT
-
-#define CFS_CPU_VERSION_MAGIC 0xbabecafe
+#ifndef CONFIG_SMP

#define CFS_CPT_DISTANCE 1 /* Arbitrary positive value */

@@ -54,12 +52,10 @@ struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)

cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
if (cptab) {
- cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
- if (!zalloc_cpumask_var(&cptab->ctb_mask, GFP_NOFS))
+ if (!zalloc_cpumask_var(&cptab->ctb_cpumask, GFP_NOFS))
return NULL;
- cpumask_set_cpu(0, cptab->ctb_mask);
+ cpumask_set_cpu(0, cptab->ctb_cpumask);
node_set(0, cptab->ctb_nodemask);
- cptab->ctb_nparts = ncpt;
}

return cptab;
@@ -68,13 +64,10 @@ struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)

void cfs_cpt_table_free(struct cfs_cpt_table *cptab)
{
- LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
-
kfree(cptab);
}
EXPORT_SYMBOL(cfs_cpt_table_free);

-#ifdef CONFIG_SMP
int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
int rc;
@@ -87,7 +80,6 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
return rc;
}
EXPORT_SYMBOL(cfs_cpt_table_print);
-#endif /* CONFIG_SMP */

int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
@@ -122,7 +114,7 @@ int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)

cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
{
- return &cptab->ctb_mask;
+ return &cptab->ctb_cpumask;
}
EXPORT_SYMBOL(cfs_cpt_cpumask);

@@ -231,4 +223,4 @@ int cfs_cpu_init(void)
return cfs_cpt_table ? 0 : -1;
}

-#endif /* HAVE_LIBCFS_CPT */
+#endif /* !CONFIG_SMP */
--
1.8.3.1


2018-04-16 04:12:27

by James Simmons

[permalink] [raw]
Subject: [PATCH 22/25] staging: lustre: libcfs: update debug messages in CPT code

From: Dmitry Eremin <[email protected]>

Update the debug messages for the CPT table creation code. Place
the passed in string in quotes to make it clear what it is.
Captialize cpu in the debug strings.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23306
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Patrick Farrell <[email protected]>
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 28b2acb..a08816a 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -466,7 +466,7 @@ void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)

} else if (cpt != cptab->ctb_cpu2cpt[cpu]) {
CDEBUG(D_INFO,
- "CPU %d is not in cpu-partition %d\n", cpu, cpt);
+ "CPU %d is not in CPU partition %d\n", cpu, cpt);
return;
}

@@ -910,14 +910,14 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
if (!ncpt ||
(node && ncpt > num_online_nodes()) ||
(!node && ncpt > num_online_cpus())) {
- CERROR("Invalid pattern %s, or too many partitions %d\n",
+ CERROR("Invalid pattern '%s', or too many partitions %d\n",
pattern, ncpt);
return NULL;
}

cptab = cfs_cpt_table_alloc(ncpt);
if (!cptab) {
- CERROR("Failed to allocate cpu partition table\n");
+ CERROR("Failed to allocate CPU partition table\n");
return NULL;
}

@@ -948,11 +948,11 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)

if (!bracket) {
if (*str) {
- CERROR("Invalid pattern %s\n", str);
+ CERROR("Invalid pattern '%s'\n", str);
goto failed;
}
if (c != ncpt) {
- CERROR("expect %d partitions but found %d\n",
+ CERROR("Expect %d partitions but found %d\n",
ncpt, c);
goto failed;
}
@@ -960,7 +960,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
}

if (sscanf(str, "%d%n", &cpt, &n) < 1) {
- CERROR("Invalid cpu pattern %s\n", str);
+ CERROR("Invalid CPU pattern '%s'\n", str);
goto failed;
}

@@ -977,20 +977,20 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)

str = strim(str + n);
if (str != bracket) {
- CERROR("Invalid pattern %s\n", str);
+ CERROR("Invalid pattern '%s'\n", str);
goto failed;
}

bracket = strchr(str, ']');
if (!bracket) {
- CERROR("Missing right bracket for partition %d, %s\n",
+ CERROR("Missing right bracket for partition %d in '%s'\n",
cpt, str);
goto failed;
}

if (cfs_expr_list_parse(str, (bracket - str) + 1,
0, high, &el)) {
- CERROR("Can't parse number range: %s\n", str);
+ CERROR("Can't parse number range in '%s'\n", str);
goto failed;
}

--
1.8.3.1


2018-04-16 04:12:42

by James Simmons

[permalink] [raw]
Subject: [PATCH 24/25] staging: lustre: libcfs: change CPT estimate algorithm

From: Dmitry Eremin <[email protected]>

The main idea to have more CPU partitions is based on KNL experience.
When a thread submit IO for network communication one of threads from
current CPT is used for network stack. Whith high parallelization many
threads become involved in network submission but having less CPU
partitions they will wait until single thread process them from network
queue. So, the bottleneck just moves into network layer in case of
small amount of CPU partitions. My experiments showed that the best
performance was when for each IO thread we have one network thread.
This condition can be provided having 2 real HW cores (without hyper
threads) per CPT. This is exactly what implemented in this patch.

Change CPT estimate algorithm from 2 * (N - 1)^2 < NCPUS <= 2 * N^2
to 2 HW cores per CPT. This is critical for machines with number of
cores different from 2^N.

Current algorithm splits CPTs in KNL:
LNet: HW CPU cores: 272, npartitions: 16
cpu_partition_table=
0 : 0-4,68-71,136-139,204-207
1 : 5-9,73-76,141-144,209-212
2 : 10-14,78-81,146-149,214-217
3 : 15-17,72,77,83-85,140,145,151-153,208,219-221
4 : 18-21,82,86-88,150,154-156,213,218,222-224
5 : 22-26,90-93,158-161,226-229
6 : 27-31,95-98,163-166,231-234
7 : 32-35,89,100-103,168-171,236-239
8 : 36-38,94,99,104-105,157,162,167,172-173,225,230,235,240-241
9 : 39-43,107-110,175-178,243-246
10 : 44-48,112-115,180-183,248-251
11 : 49-51,106,111,117-119,174,179,185-187,242,253-255
12 : 52-55,116,120-122,184,188-190,247,252,256-258
13 : 56-60,124-127,192-195,260-263
14 : 61-65,129-132,197-200,265-268
15 : 66-67,123,128,133-135,191,196,201-203,259,264,269-271

New algorithm will split CPTs in KNL:
LNet: HW CPU cores: 272, npartitions: 34
cpu_partition_table=
0 : 0-1,68-69,136-137,204-205
1 : 2-3,70-71,138-139,206-207
2 : 4-5,72-73,140-141,208-209
3 : 6-7,74-75,142-143,210-211
4 : 8-9,76-77,144-145,212-213
5 : 10-11,78-79,146-147,214-215
6 : 12-13,80-81,148-149,216-217
7 : 14-15,82-83,150-151,218-219
8 : 16-17,84-85,152-153,220-221
9 : 18-19,86-87,154-155,222-223
10 : 20-21,88-89,156-157,224-225
11 : 22-23,90-91,158-159,226-227
12 : 24-25,92-93,160-161,228-229
13 : 26-27,94-95,162-163,230-231
14 : 28-29,96-97,164-165,232-233
15 : 30-31,98-99,166-167,234-235
16 : 32-33,100-101,168-169,236-237
17 : 34-35,102-103,170-171,238-239
18 : 36-37,104-105,172-173,240-241
19 : 38-39,106-107,174-175,242-243
20 : 40-41,108-109,176-177,244-245
21 : 42-43,110-111,178-179,246-247
22 : 44-45,112-113,180-181,248-249
23 : 46-47,114-115,182-183,250-251
24 : 48-49,116-117,184-185,252-253
25 : 50-51,118-119,186-187,254-255
26 : 52-53,120-121,188-189,256-257
27 : 54-55,122-123,190-191,258-259
28 : 56-57,124-125,192-193,260-261
29 : 58-59,126-127,194-195,262-263
30 : 60-61,128-129,196-197,264-265
31 : 62-63,130-131,198-199,266-267
32 : 64-65,132-133,200-201,268-269
33 : 66-67,134-135,202-203,270-271

'N' pattern in KNL works is not always good.
in flat mode it will be one CPT with all CPUs inside.

in SNC-4 mode:
cpu_partition_table=
0 : 0-17,68-85,136-153,204-221
1 : 18-35,86-103,154-171,222-239
2 : 36-51,104-119,172-187,240-255
3 : 52-67,120-135,188-203,256-271

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/24304
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 30 ++++------------------
1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 915cfca..ae5fd16 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -768,34 +768,14 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,

static int cfs_cpt_num_estimate(void)
{
- int nnode = num_online_nodes();
+ int nthr = cpumask_weight(topology_sibling_cpumask(smp_processor_id()));
int ncpu = num_online_cpus();
- int ncpt;
+ int ncpt = 1;

- if (ncpu <= CPT_WEIGHT_MIN) {
- ncpt = 1;
- goto out;
- }
-
- /* generate reasonable number of CPU partitions based on total number
- * of CPUs, Preferred N should be power2 and match this condition:
- * 2 * (N - 1)^2 < NCPUS <= 2 * N^2
- */
- for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1)
- ;
-
- if (ncpt <= nnode) { /* fat numa system */
- while (nnode > ncpt)
- nnode >>= 1;
+ if (ncpu > CPT_WEIGHT_MIN)
+ for (ncpt = 2; ncpu > 2 * nthr * ncpt; ncpt++)
+ ; /* nothing */

- } else { /* ncpt > nnode */
- while ((nnode << 1) <= ncpt)
- nnode <<= 1;
- }
-
- ncpt = nnode;
-
-out:
#if (BITS_PER_LONG == 32)
/* config many CPU partitions on 32-bit system could consume
* too much memory
--
1.8.3.1


2018-04-16 04:12:56

by James Simmons

[permalink] [raw]
Subject: [PATCH 23/25] staging: lustre: libcfs: rework CPU pattern parsing code

From: Dmitry Eremin <[email protected]>

Currently the module param string for CPU pattern can be
modified which is wrong. Rewrite CPU pattern parsing code
to avoid the passed buffer from being changed. This change
also enables us to add real errors propogation to the caller
functions.

Signed-off-by: Dmitry Eremin <[email protected]>
Signed-off-by: Amir Shehata <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23306
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9715
Reviewed-on: https://review.whamcloud.com/27872
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Patrick Farrell <[email protected]>
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 151 ++++++++++++---------
1 file changed, 88 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index a08816a..915cfca 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -662,11 +662,11 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
}

- if (cpumask_any_and(*cpumask, cpu_online_mask) >= nr_cpu_ids) {
+ if (!cpumask_intersects(*cpumask, cpu_online_mask)) {
CDEBUG(D_INFO,
"No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
cpt);
- return -EINVAL;
+ return -ENODEV;
}

for_each_online_cpu(cpu) {
@@ -830,11 +830,13 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
cptab = cfs_cpt_table_alloc(ncpt);
if (!cptab) {
CERROR("Failed to allocate CPU map(%d)\n", ncpt);
+ rc = -ENOMEM;
goto failed;
}

if (!zalloc_cpumask_var(&node_mask, GFP_NOFS)) {
CERROR("Failed to allocate scratch cpumask\n");
+ rc = -ENOMEM;
goto failed;
}

@@ -849,8 +851,10 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)

rc = cfs_cpt_choose_ncpus(cptab, cpt, node_mask,
num - ncpu);
- if (rc < 0)
+ if (rc < 0) {
+ rc = -EINVAL;
goto failed_mask;
+ }

ncpu = cpumask_weight(part->cpt_cpumask);
if (ncpu == num + !!(rem > 0)) {
@@ -873,37 +877,51 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
if (cptab)
cfs_cpt_table_free(cptab);

- return NULL;
+ return ERR_PTR(rc);
}

-static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
+static struct cfs_cpt_table *cfs_cpt_table_create_pattern(const char *pattern)
{
struct cfs_cpt_table *cptab;
+ char *pattern_dup;
+ char *bracket;
char *str;
int node = 0;
- int high;
int ncpt = 0;
- int cpt;
+ int cpt = 0;
+ int high;
int rc;
int c;
int i;

- str = strim(pattern);
+ pattern_dup = kstrdup(pattern, GFP_KERNEL);
+ if (!pattern_dup) {
+ CERROR("Failed to duplicate pattern '%s'\n", pattern);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ str = strim(pattern_dup);
if (*str == 'n' || *str == 'N') {
- pattern = str + 1;
- if (*pattern != '\0') {
- node = 1;
- } else { /* shortcut to create CPT from NUMA & CPU topology */
+ str++; /* skip 'N' char */
+ node = 1; /* NUMA pattern */
+ if (*str == '\0') {
node = -1;
- ncpt = num_online_nodes();
+ for_each_online_node(i) {
+ if (!cpumask_empty(cpumask_of_node(i)))
+ ncpt++;
+ }
+ if (ncpt == 1) { /* single NUMA node */
+ kfree(pattern_dup);
+ return cfs_cpt_table_create(cpu_npartitions);
+ }
}
}

if (!ncpt) { /* scanning bracket which is mark of partition */
- for (str = pattern;; str++, ncpt++) {
- str = strchr(str, '[');
- if (!str)
- break;
+ bracket = str;
+ while ((bracket = strchr(bracket, '['))) {
+ bracket++;
+ ncpt++;
}
}

@@ -911,87 +929,95 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
(node && ncpt > num_online_nodes()) ||
(!node && ncpt > num_online_cpus())) {
CERROR("Invalid pattern '%s', or too many partitions %d\n",
- pattern, ncpt);
- return NULL;
+ pattern_dup, ncpt);
+ rc = -EINVAL;
+ goto err_free_str;
}

cptab = cfs_cpt_table_alloc(ncpt);
if (!cptab) {
CERROR("Failed to allocate CPU partition table\n");
- return NULL;
+ rc = -ENOMEM;
+ goto err_free_str;
}

if (node < 0) { /* shortcut to create CPT from NUMA & CPU topology */
- cpt = 0;
-
for_each_online_node(i) {
- if (cpt >= ncpt) {
- CERROR("CPU changed while setting CPU partition table, %d/%d\n",
- cpt, ncpt);
- goto failed;
- }
+ if (cpumask_empty(cpumask_of_node(i)))
+ continue;

rc = cfs_cpt_set_node(cptab, cpt++, i);
- if (!rc)
- goto failed;
+ if (!rc) {
+ rc = -EINVAL;
+ goto err_free_table;
+ }
}
+ kfree(pattern_dup);
return cptab;
}

high = node ? nr_node_ids - 1 : nr_cpu_ids - 1;

- for (str = strim(pattern), c = 0;; c++) {
+ for (str = strim(str), c = 0; /* until break */; c++) {
struct cfs_range_expr *range;
struct cfs_expr_list *el;
- char *bracket = strchr(str, '[');
int n;

+ bracket = strchr(str, '[');
if (!bracket) {
if (*str) {
CERROR("Invalid pattern '%s'\n", str);
- goto failed;
- }
- if (c != ncpt) {
+ rc = -EINVAL;
+ goto err_free_table;
+ } else if (c != ncpt) {
CERROR("Expect %d partitions but found %d\n",
ncpt, c);
- goto failed;
+ rc = -EINVAL;
+ goto err_free_table;
}
break;
}

if (sscanf(str, "%d%n", &cpt, &n) < 1) {
CERROR("Invalid CPU pattern '%s'\n", str);
- goto failed;
+ rc = -EINVAL;
+ goto err_free_table;
}

if (cpt < 0 || cpt >= ncpt) {
CERROR("Invalid partition id %d, total partitions %d\n",
cpt, ncpt);
- goto failed;
+ rc = -EINVAL;
+ goto err_free_table;
}

if (cfs_cpt_weight(cptab, cpt)) {
CERROR("Partition %d has already been set.\n", cpt);
- goto failed;
+ rc = -EPERM;
+ goto err_free_table;
}

str = strim(str + n);
if (str != bracket) {
CERROR("Invalid pattern '%s'\n", str);
- goto failed;
+ rc = -EINVAL;
+ goto err_free_table;
}

bracket = strchr(str, ']');
if (!bracket) {
CERROR("Missing right bracket for partition %d in '%s'\n",
cpt, str);
- goto failed;
+ rc = -EINVAL;
+ goto err_free_table;
}

- if (cfs_expr_list_parse(str, (bracket - str) + 1,
- 0, high, &el)) {
+ rc = cfs_expr_list_parse(str, (bracket - str) + 1, 0, high,
+ &el);
+ if (rc) {
CERROR("Can't parse number range in '%s'\n", str);
- goto failed;
+ rc = -ERANGE;
+ goto err_free_table;
}

list_for_each_entry(range, &el->el_exprs, re_link) {
@@ -999,11 +1025,12 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
if ((i - range->re_lo) % range->re_stride)
continue;

- rc = node ? cfs_cpt_set_node(cptab, cpt, i) :
- cfs_cpt_set_cpu(cptab, cpt, i);
+ rc = node ? cfs_cpt_set_node(cptab, cpt, i)
+ : cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) {
cfs_expr_list_free(el);
- goto failed;
+ rc = -EINVAL;
+ goto err_free_table;
}
}
}
@@ -1012,17 +1039,21 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)

if (!cfs_cpt_online(cptab, cpt)) {
CERROR("No online CPU is found on partition %d\n", cpt);
- goto failed;
+ rc = -ENODEV;
+ goto err_free_table;
}

str = strim(bracket + 1);
}

+ kfree(pattern_dup);
return cptab;

-failed:
+err_free_table:
cfs_cpt_table_free(cptab);
- return NULL;
+err_free_str:
+ kfree(pattern_dup);
+ return ERR_PTR(rc);
}

#ifdef CONFIG_HOTPLUG_CPU
@@ -1049,7 +1080,7 @@ static int cfs_cpu_dead(unsigned int cpu)

void cfs_cpu_fini(void)
{
- if (cfs_cpt_table)
+ if (!IS_ERR_OR_NULL(cfs_cpt_table))
cfs_cpt_table_free(cfs_cpt_table);

#ifdef CONFIG_HOTPLUG_CPU
@@ -1082,26 +1113,20 @@ int cfs_cpu_init(void)

get_online_cpus();
if (*cpu_pattern) {
- char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);
-
- if (!cpu_pattern_dup) {
- CERROR("Failed to duplicate cpu_pattern\n");
- goto failed;
- }
-
- cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern_dup);
- kfree(cpu_pattern_dup);
- if (!cfs_cpt_table) {
- CERROR("Failed to create cptab from pattern %s\n",
+ cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern);
+ if (IS_ERR(cfs_cpt_table)) {
+ CERROR("Failed to create cptab from pattern '%s'\n",
cpu_pattern);
+ ret = PTR_ERR(cfs_cpt_table);
goto failed;
}

} else {
cfs_cpt_table = cfs_cpt_table_create(cpu_npartitions);
- if (!cfs_cpt_table) {
- CERROR("Failed to create ptable with npartitions %d\n",
+ if (IS_ERR(cfs_cpt_table)) {
+ CERROR("Failed to create cptab with npartitions %d\n",
cpu_npartitions);
+ ret = PTR_ERR(cfs_cpt_table);
goto failed;
}
}
--
1.8.3.1


2018-04-16 04:13:11

by James Simmons

[permalink] [raw]
Subject: [PATCH 20/25] staging: lustre: libcfs: make tolerant to offline CPUs and empty NUMA nodes

From: Dmitry Eremin <[email protected]>

Rework CPU partition code in the way of make it more tolerant to
offline CPUs and empty nodes.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../lustre/include/linux/libcfs/linux/linux-cpu.h | 2 +
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 132 +++++++++------------
drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 +
3 files changed, 60 insertions(+), 76 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
index b3bc4e7..ed4351b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
@@ -56,6 +56,8 @@ struct cfs_cpu_partition {
unsigned int *cpt_distance;
/* spread rotor for NUMA allocator */
int cpt_spread_rotor;
+ /* NUMA node if cpt_nodemask is empty */
+ int cpt_node;
};

/** descriptor for CPU partitions */
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 32ebd0f..80db008 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -427,8 +427,16 @@ int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
return 0;
}

- LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
- LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
+ if (cpumask_test_cpu(cpu, cptab->ctb_cpumask)) {
+ CDEBUG(D_INFO, "CPU %d is already in cpumask\n", cpu);
+ return 0;
+ }
+
+ if (cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask)) {
+ CDEBUG(D_INFO, "CPU %d is already in partition %d cpumask\n",
+ cpu, cptab->ctb_cpu2cpt[cpu]);
+ return 0;
+ }

cfs_cpt_add_cpu(cptab, cpt, cpu);
cfs_cpt_add_node(cptab, cpt, cpu_to_node(cpu));
@@ -497,8 +505,10 @@ void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
{
int cpu;

- for_each_cpu(cpu, mask)
- cfs_cpt_unset_cpu(cptab, cpt, cpu);
+ for_each_cpu(cpu, mask) {
+ cfs_cpt_del_cpu(cptab, cpt, cpu);
+ cfs_cpt_del_node(cptab, cpt, cpu_to_node(cpu));
+ }
}
EXPORT_SYMBOL(cfs_cpt_unset_cpumask);

@@ -549,10 +559,8 @@ int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt,
{
int node;

- for_each_node_mask(node, *mask) {
- if (!cfs_cpt_set_node(cptab, cpt, node))
- return 0;
- }
+ for_each_node_mask(node, *mask)
+ cfs_cpt_set_node(cptab, cpt, node);

return 1;
}
@@ -573,7 +581,7 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
nodemask_t *mask;
int weight;
int rotor;
- int node;
+ int node = 0;

/* convert CPU partition ID to HW node id */

@@ -583,20 +591,20 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
} else {
mask = cptab->ctb_parts[cpt].cpt_nodemask;
rotor = cptab->ctb_parts[cpt].cpt_spread_rotor++;
+ node = cptab->ctb_parts[cpt].cpt_node;
}

weight = nodes_weight(*mask);
- LASSERT(weight > 0);
-
- rotor %= weight;
+ if (weight > 0) {
+ rotor %= weight;

- for_each_node_mask(node, *mask) {
- if (!rotor--)
- return node;
+ for_each_node_mask(node, *mask) {
+ if (!rotor--)
+ return node;
+ }
}

- LBUG();
- return 0;
+ return node;
}
EXPORT_SYMBOL(cfs_cpt_spread_node);

@@ -689,17 +697,21 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
cpumask_var_t core_mask;
int rc = 0;
int cpu;
+ int i;

LASSERT(number > 0);

if (number >= cpumask_weight(node_mask)) {
while (!cpumask_empty(node_mask)) {
cpu = cpumask_first(node_mask);
+ cpumask_clear_cpu(cpu, node_mask);
+
+ if (!cpu_online(cpu))
+ continue;

rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc)
return -EINVAL;
- cpumask_clear_cpu(cpu, node_mask);
}
return 0;
}
@@ -720,24 +732,19 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
cpu = cpumask_first(node_mask);

/* get cpumask for cores in the same socket */
- cpumask_copy(socket_mask, topology_core_cpumask(cpu));
- cpumask_and(socket_mask, socket_mask, node_mask);
-
- LASSERT(!cpumask_empty(socket_mask));
-
+ cpumask_and(socket_mask, topology_core_cpumask(cpu), node_mask);
while (!cpumask_empty(socket_mask)) {
- int i;
-
/* get cpumask for hts in the same core */
- cpumask_copy(core_mask, topology_sibling_cpumask(cpu));
- cpumask_and(core_mask, core_mask, node_mask);
-
- LASSERT(!cpumask_empty(core_mask));
+ cpumask_and(core_mask, topology_sibling_cpumask(cpu),
+ node_mask);

for_each_cpu(i, core_mask) {
cpumask_clear_cpu(i, socket_mask);
cpumask_clear_cpu(i, node_mask);

+ if (!cpu_online(i))
+ continue;
+
rc = cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) {
rc = -EINVAL;
@@ -806,23 +813,18 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
struct cfs_cpt_table *cptab = NULL;
cpumask_var_t node_mask;
int cpt = 0;
+ int node;
int num;
- int rc;
- int i;
+ int rem;
+ int rc = 0;

- rc = cfs_cpt_num_estimate();
+ num = cfs_cpt_num_estimate();
if (ncpt <= 0)
- ncpt = rc;
+ ncpt = num;

- if (ncpt > num_online_cpus() || ncpt > 4 * rc) {
+ if (ncpt > num_online_cpus() || ncpt > 4 * num) {
CWARN("CPU partition number %d is larger than suggested value (%d), your system may have performance issue or run out of memory while under pressure\n",
- ncpt, rc);
- }
-
- if (num_online_cpus() % ncpt) {
- CERROR("CPU number %d is not multiple of cpu_npartition %d, please try different cpu_npartitions value or set pattern string by cpu_pattern=STRING\n",
- (int)num_online_cpus(), ncpt);
- goto failed;
+ ncpt, num);
}

cptab = cfs_cpt_table_alloc(ncpt);
@@ -831,55 +833,33 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
goto failed;
}

- num = num_online_cpus() / ncpt;
- if (!num) {
- CERROR("CPU changed while setting CPU partition\n");
- goto failed;
- }
-
if (!zalloc_cpumask_var(&node_mask, GFP_NOFS)) {
CERROR("Failed to allocate scratch cpumask\n");
goto failed;
}

- for_each_online_node(i) {
- cpumask_copy(node_mask, cpumask_of_node(i));
-
- while (!cpumask_empty(node_mask)) {
- struct cfs_cpu_partition *part;
- int n;
-
- /*
- * Each emulated NUMA node has all allowed CPUs in
- * the mask.
- * End loop when all partitions have assigned CPUs.
- */
- if (cpt == ncpt)
- break;
-
- part = &cptab->ctb_parts[cpt];
+ num = num_online_cpus() / ncpt;
+ rem = num_online_cpus() % ncpt;
+ for_each_online_node(node) {
+ cpumask_copy(node_mask, cpumask_of_node(node));

- n = num - cpumask_weight(part->cpt_cpumask);
- LASSERT(n > 0);
+ while (cpt < ncpt && !cpumask_empty(node_mask)) {
+ struct cfs_cpu_partition *part = &cptab->ctb_parts[cpt];
+ int ncpu = cpumask_weight(part->cpt_cpumask);

- rc = cfs_cpt_choose_ncpus(cptab, cpt, node_mask, n);
+ rc = cfs_cpt_choose_ncpus(cptab, cpt, node_mask,
+ num - ncpu);
if (rc < 0)
goto failed_mask;

- LASSERT(num >= cpumask_weight(part->cpt_cpumask));
- if (num == cpumask_weight(part->cpt_cpumask))
+ ncpu = cpumask_weight(part->cpt_cpumask);
+ if (ncpu == num + !!(rem > 0)) {
cpt++;
+ rem--;
+ }
}
}

- if (cpt != ncpt ||
- num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
- CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n",
- cptab->ctb_nparts, num, cpt,
- cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask));
- goto failed_mask;
- }
-
free_cpumask_var(node_mask);

return cptab;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c
index 0091273..27bdefa 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-msg.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c
@@ -568,6 +568,8 @@

/* number of CPUs */
container->msc_nfinalizers = cfs_cpt_weight(lnet_cpt_table(), cpt);
+ if (container->msc_nfinalizers == 0)
+ container->msc_nfinalizers = 1;

container->msc_finalizers = kvzalloc_cpt(container->msc_nfinalizers *
sizeof(*container->msc_finalizers),
--
1.8.3.1


2018-04-16 04:13:22

by James Simmons

[permalink] [raw]
Subject: [PATCH 21/25] staging: lustre: libcfs: report NUMA node instead of just node

From: Dmitry Eremin <[email protected]>

Reporting "HW nodes" is too generic. It really is reporting
"HW NUMA nodes". Update the debug message.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23306
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Patrick Farrell <[email protected]>
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 80db008..28b2acb 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -1108,7 +1108,7 @@ int cfs_cpu_init(void)

put_online_cpus();

- LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
+ LCONSOLE(0, "HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n",
num_online_nodes(), num_online_cpus(),
cfs_cpt_number(cfs_cpt_table));
return 0;
--
1.8.3.1


2018-04-16 04:13:23

by James Simmons

[permalink] [raw]
Subject: [PATCH 13/25] staging: lustre: libcfs: use int type for CPT identification.

From: Dmitry Eremin <[email protected]>

Use int type for CPT identification to match the linux kernel
CPU identification.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23304
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h | 2 +-
.../staging/lustre/include/linux/libcfs/linux/linux-cpu.h | 6 +++---
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 2 +-
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 14 +++++++-------
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index bda81ab..19a3489 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -108,7 +108,7 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf,
/**
* 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 distance information of cpt-table
*/
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
index 4ac1670..b3bc4e7 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
@@ -55,17 +55,17 @@ struct cfs_cpu_partition {
/* NUMA distance between CPTs */
unsigned int *cpt_distance;
/* spread rotor for NUMA allocator */
- unsigned int cpt_spread_rotor;
+ int cpt_spread_rotor;
};

/** descriptor for CPU partitions */
struct cfs_cpt_table {
/* spread rotor for NUMA allocator */
- unsigned int ctb_spread_rotor;
+ int ctb_spread_rotor;
/* maximum NUMA distance between all nodes in table */
unsigned int ctb_distance;
/* # of CPU partitions */
- unsigned int ctb_nparts;
+ int ctb_nparts;
/* partitions tables */
struct cfs_cpu_partition *ctb_parts;
/* shadow HW CPU to CPU partition ID */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index f9fcbb1..5d7d44d 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -43,7 +43,7 @@

#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;

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 5c9cdf4..1669669 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -88,7 +88,7 @@ void 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;
@@ -759,13 +759,13 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
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 int nnode = num_online_nodes();
- unsigned int ncpu = num_online_cpus();
- unsigned int ncpt;
+ int nnode = num_online_nodes();
+ int ncpu = num_online_cpus();
+ int ncpt;

if (ncpu <= CPT_WEIGHT_MIN) {
ncpt = 1;
@@ -795,7 +795,7 @@ static unsigned int cfs_cpt_num_estimate(void)
/* 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)
ncpt--; /* worst case is 1 */
--
1.8.3.1


2018-04-16 04:13:29

by James Simmons

[permalink] [raw]
Subject: [PATCH 19/25] staging: lustre: libcfs: update debug messages

From: Dmitry Eremin <[email protected]>

For cfs_cpt_bind() change the CERROR to CDEBUG. Make the debug
message in cfs_cpt_table_create_pattern() more understandable.
Report rc value for when cfs_cpt_create_table() fails.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index c4f53ab..32ebd0f 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -655,7 +655,8 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
}

if (cpumask_any_and(*cpumask, cpu_online_mask) >= nr_cpu_ids) {
- CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
+ CDEBUG(D_INFO,
+ "No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
cpt);
return -EINVAL;
}
@@ -886,8 +887,8 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
failed_mask:
free_cpumask_var(node_mask);
failed:
- CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n",
- ncpt, num_online_nodes(), num_online_cpus());
+ CERROR("Failed (rc = %d) to setup CPU partition table with %d partitions, online HW NUMA nodes: %d, HW CPU cores: %d.\n",
+ rc, ncpt, num_online_nodes(), num_online_cpus());

if (cptab)
cfs_cpt_table_free(cptab);
@@ -1002,7 +1003,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)

bracket = strchr(str, ']');
if (!bracket) {
- CERROR("missing right bracket for cpt %d, %s\n",
+ CERROR("Missing right bracket for partition %d, %s\n",
cpt, str);
goto failed;
}
--
1.8.3.1


2018-04-16 04:13:43

by James Simmons

[permalink] [raw]
Subject: [PATCH 18/25] staging: lustre: libcfs: clear up failure patch in cfs_cpt_*_print

From: Dmitry Eremin <[email protected]>

Currently both cfs_cpt_table_print() and cfs_cpt_distance_print()
handle the error path in a confusing way. Simplify it so it just
returns E2BIG on failure instead of testing rc value before
exiting.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 435ee8e..c4f53ab 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -155,7 +155,7 @@ struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)
int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
char *tmp = buf;
- int rc = -EFBIG;
+ int rc;
int i;
int j;

@@ -183,19 +183,17 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
len--;
}

- rc = 0;
-err:
- if (rc < 0)
- return rc;
-
return tmp - buf;
+
+err:
+ return -E2BIG;
}
EXPORT_SYMBOL(cfs_cpt_table_print);

int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
char *tmp = buf;
- int rc = -EFBIG;
+ int rc;
int i;
int j;

@@ -223,12 +221,11 @@ int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
tmp++;
len--;
}
- rc = 0;
-err:
- if (rc < 0)
- return rc;

return tmp - buf;
+
+err:
+ return -E2BIG;
}
EXPORT_SYMBOL(cfs_cpt_distance_print);

--
1.8.3.1


2018-04-16 04:14:04

by James Simmons

[permalink] [raw]
Subject: [PATCH 17/25] staging: lustre: libcfs: rename goto label in cfs_cpt_table_print

From: Dmitry Eremin <[email protected]>

Change goto label out to err.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index ae5ff58..435ee8e 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -161,20 +161,20 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)

for (i = 0; i < cptab->ctb_nparts; i++) {
if (len <= 0)
- goto out;
+ goto err;

rc = snprintf(tmp, len, "%d\t:", i);
len -= rc;

if (len <= 0)
- goto out;
+ goto err;

tmp += rc;
for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
rc = snprintf(tmp, len, " %d", j);
len -= rc;
if (len <= 0)
- goto out;
+ goto err;
tmp += rc;
}

@@ -184,7 +184,7 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
}

rc = 0;
-out:
+err:
if (rc < 0)
return rc;

--
1.8.3.1


2018-04-16 04:14:15

by James Simmons

[permalink] [raw]
Subject: [PATCH 12/25] staging: lustre: libcfs: fix libcfs_cpu coding style

From: Dmitry Eremin <[email protected]>

This patch bring the lustre CPT code into alignment with the
Linux kernel coding style.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23304
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../lustre/include/linux/libcfs/libcfs_cpu.h | 35 ++++---
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 70 +++++---------
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 107 +++++++++------------
3 files changed, 86 insertions(+), 126 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index c0922fc..bda81ab 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -43,16 +43,16 @@
*
* Example: if there are 8 cores on the system, while creating a CPT
* with cpu_npartitions=4:
- * core[0, 1] = partition[0], core[2, 3] = partition[1]
- * core[4, 5] = partition[2], core[6, 7] = partition[3]
+ * core[0, 1] = partition[0], core[2, 3] = partition[1]
+ * core[4, 5] = partition[2], core[6, 7] = partition[3]
*
- * cpu_npartitions=1:
- * core[0, 1, ... 7] = partition[0]
+ * cpu_npartitions=1:
+ * core[0, 1, ... 7] = partition[0]
*
* . User can also specify CPU partitions by string pattern
*
* Examples: cpu_partitions="0[0,1], 1[2,3]"
- * cpu_partitions="N 0[0-3], 1[4-8]"
+ * cpu_partitions="N 0[0-3], 1[4-8]"
*
* The first character "N" means following numbers are numa ID
*
@@ -92,8 +92,8 @@ struct cfs_cpt_table {
u64 ctb_version;
};

-static inline int
-cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
+static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf,
+ int len)
{
return 0;
}
@@ -116,8 +116,7 @@ struct cfs_cpt_table {
/**
* 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 hyper-threadings in a CPU partition \a cpt
*/
@@ -167,13 +166,13 @@ struct cfs_cpt_table {
* 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
@@ -188,13 +187,13 @@ void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab,
* 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.
@@ -240,7 +239,7 @@ enum {

struct cfs_percpt_lock {
/* cpu-partition-table for this lock */
- struct cfs_cpt_table *pcl_cptab;
+ struct cfs_cpt_table *pcl_cptab;
/* exclusively locked */
unsigned int pcl_locked;
/* private lock table */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 7ac2796..f9fcbb1 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -34,7 +34,7 @@
#include <linux/libcfs/libcfs.h>

/** Global CPU partition table */
-struct cfs_cpt_table *cfs_cpt_table __read_mostly;
+struct cfs_cpt_table *cfs_cpt_table __read_mostly;
EXPORT_SYMBOL(cfs_cpt_table);

#ifndef HAVE_LIBCFS_CPT
@@ -43,8 +43,7 @@

#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(unsigned int ncpt)
{
struct cfs_cpt_table *cptab;

@@ -67,8 +66,7 @@ struct cfs_cpt_table *
}
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);

@@ -77,8 +75,7 @@ struct cfs_cpt_table *
EXPORT_SYMBOL(cfs_cpt_table_free);

#ifdef CONFIG_SMP
-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;

@@ -105,22 +102,19 @@ int 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;
}
@@ -132,8 +126,7 @@ cpumask_var_t *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)
{
return &cptab->ctb_nodemask;
}
@@ -145,75 +138,67 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
}
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;
}
@@ -225,15 +210,13 @@ int 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)
{
return 0;
}
EXPORT_SYMBOL(cfs_cpt_bind);

-void
-cfs_cpu_fini(void)
+void cfs_cpu_fini(void)
{
if (cfs_cpt_table) {
cfs_cpt_table_free(cfs_cpt_table);
@@ -241,8 +224,7 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
}
}

-int
-cfs_cpu_init(void)
+int cfs_cpu_init(void)
{
cfs_cpt_table = cfs_cpt_table_alloc(1);

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 6d8dcd3..5c9cdf4 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -43,7 +43,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");

@@ -60,12 +60,11 @@
*
* 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;

@@ -89,8 +88,7 @@
}
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(unsigned int ncpt)
{
struct cfs_cpt_table *cptab;
int i;
@@ -148,14 +146,13 @@ struct cfs_cpt_table *

return cptab;

- failed:
+failed:
cfs_cpt_table_free(cptab);
return NULL;
}
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;
@@ -187,7 +184,7 @@ struct cfs_cpt_table *
}

rc = 0;
- out:
+out:
if (rc < 0)
return rc;

@@ -235,15 +232,13 @@ int 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));

@@ -253,8 +248,7 @@ int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
}
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));

@@ -266,8 +260,7 @@ int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
}
EXPORT_SYMBOL(cfs_cpt_online);

-cpumask_var_t *
-cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
+cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
{
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));

@@ -276,8 +269,7 @@ int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
}
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));

@@ -423,8 +415,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);

@@ -449,8 +440,7 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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));

@@ -463,7 +453,8 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
/* caller doesn't know the partition ID */
cpt = cptab->ctb_cpu2cpt[cpu];
if (cpt < 0) { /* not set in this CPT-table */
- CDEBUG(D_INFO, "Try to unset cpu %d which is not in CPT-table %p\n",
+ CDEBUG(D_INFO,
+ "Try to unset cpu %d which is not in CPT-table %p\n",
cpt, cptab);
return;
}
@@ -482,14 +473,15 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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;

if (!cpumask_weight(mask) ||
cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
- CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n",
+ CDEBUG(D_INFO,
+ "No online CPU is found in the CPU mask for CPU partition %d\n",
cpt);
return 0;
}
@@ -503,9 +495,8 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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;

@@ -514,8 +505,7 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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;
@@ -537,8 +527,7 @@ static void cfs_cpt_del_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;
@@ -558,8 +547,8 @@ static void cfs_cpt_del_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;

@@ -572,8 +561,8 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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;

@@ -582,8 +571,7 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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)
{
nodemask_t *mask;
int weight;
@@ -615,8 +603,7 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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;
int cpt;
@@ -636,8 +623,7 @@ static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
}
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);

@@ -654,8 +640,7 @@ int 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_var_t *cpumask;
nodemask_t *nodemask;
@@ -699,9 +684,8 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
* 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_var_t socket;
cpumask_var_t core;
@@ -777,8 +761,7 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)

#define CPT_WEIGHT_MIN 4u

-static unsigned int
-cfs_cpt_num_estimate(void)
+static unsigned int cfs_cpt_num_estimate(void)
{
unsigned int nnode = num_online_nodes();
unsigned int ncpu = num_online_cpus();
@@ -820,8 +803,7 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
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_var_t mask;
@@ -904,9 +886,9 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)

return cptab;

- failed_mask:
+failed_mask:
free_cpumask_var(mask);
- failed:
+failed:
CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n",
ncpt, num_online_nodes(), num_online_cpus());

@@ -916,8 +898,7 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
return NULL;
}

-static struct cfs_cpt_table *
-cfs_cpt_table_create_pattern(char *pattern)
+static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
{
struct cfs_cpt_table *cptab;
char *str;
@@ -1061,7 +1042,7 @@ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)

return cptab;

- failed:
+failed:
cfs_cpt_table_free(cptab);
return NULL;
}
@@ -1088,8 +1069,7 @@ static int cfs_cpu_dead(unsigned int cpu)
}
#endif

-void
-cfs_cpu_fini(void)
+void cfs_cpu_fini(void)
{
if (cfs_cpt_table)
cfs_cpt_table_free(cfs_cpt_table);
@@ -1101,8 +1081,7 @@ static int cfs_cpu_dead(unsigned int cpu)
#endif
}

-int
-cfs_cpu_init(void)
+int cfs_cpu_init(void)
{
int ret = 0;

@@ -1156,7 +1135,7 @@ static int cfs_cpu_dead(unsigned int cpu)
cfs_cpt_number(cfs_cpt_table));
return 0;

- failed:
+failed:
put_online_cpus();
cfs_cpu_fini();
return ret;
--
1.8.3.1


2018-04-16 04:14:54

by James Simmons

[permalink] [raw]
Subject: [PATCH 15/25] staging: lustre: libcfs: rename i to cpu for cfs_cpt_bind

From: Dmitry Eremin <[email protected]>

Rename variable i to cpu to make code easier to understand.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 5f2ab30..b985b3d 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -644,8 +644,8 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
{
cpumask_var_t *cpumask;
nodemask_t *nodemask;
+ int cpu;
int rc;
- int i;

LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));

@@ -663,8 +663,8 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
return -EINVAL;
}

- for_each_online_cpu(i) {
- if (cpumask_test_cpu(i, *cpumask))
+ for_each_online_cpu(cpu) {
+ if (cpumask_test_cpu(cpu, *cpumask))
continue;

rc = set_cpus_allowed_ptr(current, *cpumask);
--
1.8.3.1


2018-04-16 04:15:30

by James Simmons

[permalink] [raw]
Subject: [PATCH 11/25] staging: lustre: libcfs: invert error handling for cfs_cpt_table_print

From: Amir Shehata <[email protected]>

Instead of setting rc to -EFBIG for several cases in the loop lets
initialize rc to -EFBIG and just break out of the loop in case of
failure. Just set rc to zero once we successfully finish the loop.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index bbf89b8..6d8dcd3 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -158,29 +158,26 @@ struct cfs_cpt_table *
cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
char *tmp = buf;
- int rc = 0;
+ int rc = -EFBIG;
int i;
int j;

for (i = 0; i < cptab->ctb_nparts; i++) {
- if (len > 0) {
- rc = snprintf(tmp, len, "%d\t:", i);
- len -= rc;
- }
+ if (len <= 0)
+ goto out;
+
+ rc = snprintf(tmp, len, "%d\t:", i);
+ len -= rc;

- if (len <= 0) {
- rc = -EFBIG;
+ if (len <= 0)
goto out;
- }

tmp += rc;
for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
- rc = snprintf(tmp, len, "%d ", j);
+ rc = snprintf(tmp, len, " %d", j);
len -= rc;
- if (len <= 0) {
- rc = -EFBIG;
+ if (len <= 0)
goto out;
- }
tmp += rc;
}

@@ -189,6 +186,7 @@ struct cfs_cpt_table *
len--;
}

+ rc = 0;
out:
if (rc < 0)
return rc;
--
1.8.3.1


2018-04-16 04:15:43

by James Simmons

[permalink] [raw]
Subject: [PATCH 16/25] staging: lustre: libcfs: rename cpumask_var_t variables to *_mask

From: Dmitry Eremin <[email protected]>

Because we handle both cpu mask as well as core identifiers it can
easily be confused. To avoid this rename various cpumask_var_t to
have appended *_mask to their names.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 62 +++++++++++-----------
1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index b985b3d..ae5ff58 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -685,23 +685,23 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int 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)
+ cpumask_t *node_mask, int number)
{
- cpumask_var_t socket;
- cpumask_var_t core;
+ cpumask_var_t socket_mask;
+ cpumask_var_t core_mask;
int rc = 0;
int cpu;

LASSERT(number > 0);

- if (number >= cpumask_weight(node)) {
- while (!cpumask_empty(node)) {
- cpu = cpumask_first(node);
+ if (number >= cpumask_weight(node_mask)) {
+ while (!cpumask_empty(node_mask)) {
+ cpu = cpumask_first(node_mask);

rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc)
return -EINVAL;
- cpumask_clear_cpu(cpu, node);
+ cpumask_clear_cpu(cpu, node_mask);
}
return 0;
}
@@ -711,34 +711,34 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
* As we cannot initialize a cpumask_var_t, we need
* to alloc both before we can risk trying to free either
*/
- if (!zalloc_cpumask_var(&socket, GFP_NOFS))
+ if (!zalloc_cpumask_var(&socket_mask, GFP_NOFS))
rc = -ENOMEM;
- if (!zalloc_cpumask_var(&core, GFP_NOFS))
+ if (!zalloc_cpumask_var(&core_mask, GFP_NOFS))
rc = -ENOMEM;
if (rc)
goto out;

- while (!cpumask_empty(node)) {
- cpu = cpumask_first(node);
+ while (!cpumask_empty(node_mask)) {
+ cpu = cpumask_first(node_mask);

/* get cpumask for cores in the same socket */
- cpumask_copy(socket, topology_core_cpumask(cpu));
- cpumask_and(socket, socket, node);
+ cpumask_copy(socket_mask, topology_core_cpumask(cpu));
+ cpumask_and(socket_mask, socket_mask, node_mask);

- LASSERT(!cpumask_empty(socket));
+ LASSERT(!cpumask_empty(socket_mask));

- while (!cpumask_empty(socket)) {
+ while (!cpumask_empty(socket_mask)) {
int i;

/* get cpumask for hts in the same core */
- cpumask_copy(core, topology_sibling_cpumask(cpu));
- cpumask_and(core, core, node);
+ cpumask_copy(core_mask, topology_sibling_cpumask(cpu));
+ cpumask_and(core_mask, core_mask, node_mask);

- LASSERT(!cpumask_empty(core));
+ LASSERT(!cpumask_empty(core_mask));

- for_each_cpu(i, core) {
- cpumask_clear_cpu(i, socket);
- cpumask_clear_cpu(i, node);
+ for_each_cpu(i, core_mask) {
+ cpumask_clear_cpu(i, socket_mask);
+ cpumask_clear_cpu(i, node_mask);

rc = cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) {
@@ -749,13 +749,13 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
if (!--number)
goto out;
}
- cpu = cpumask_first(socket);
+ cpu = cpumask_first(socket_mask);
}
}

out:
- free_cpumask_var(socket);
- free_cpumask_var(core);
+ free_cpumask_var(socket_mask);
+ free_cpumask_var(core_mask);
return rc;
}

@@ -806,7 +806,7 @@ static int cfs_cpt_num_estimate(void)
static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
{
struct cfs_cpt_table *cptab = NULL;
- cpumask_var_t mask;
+ cpumask_var_t node_mask;
int cpt = 0;
int num;
int rc;
@@ -839,15 +839,15 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
goto failed;
}

- if (!zalloc_cpumask_var(&mask, GFP_NOFS)) {
+ if (!zalloc_cpumask_var(&node_mask, GFP_NOFS)) {
CERROR("Failed to allocate scratch cpumask\n");
goto failed;
}

for_each_online_node(i) {
- cpumask_copy(mask, cpumask_of_node(i));
+ cpumask_copy(node_mask, cpumask_of_node(i));

- while (!cpumask_empty(mask)) {
+ while (!cpumask_empty(node_mask)) {
struct cfs_cpu_partition *part;
int n;

@@ -864,7 +864,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
n = num - cpumask_weight(part->cpt_cpumask);
LASSERT(n > 0);

- rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
+ rc = cfs_cpt_choose_ncpus(cptab, cpt, node_mask, n);
if (rc < 0)
goto failed_mask;

@@ -882,12 +882,12 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
goto failed_mask;
}

- free_cpumask_var(mask);
+ free_cpumask_var(node_mask);

return cptab;

failed_mask:
- free_cpumask_var(mask);
+ free_cpumask_var(node_mask);
failed:
CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n",
ncpt, num_online_nodes(), num_online_cpus());
--
1.8.3.1


2018-04-16 04:15:44

by James Simmons

[permalink] [raw]
Subject: [PATCH 10/25] staging: lustre: libcfs: provide debugfs files for distance handling

From: Amir Shehata <[email protected]>

On systems with large number of NUMA nodes and cores it is easy
to incorrectly configure their use with Lustre. Provide debugfs
files which can help track down any issues.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/module.c | 53 +++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)

diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index a03f924..95af000 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -336,6 +336,53 @@ static int proc_cpt_table(struct ctl_table *table, int write,
__proc_cpt_table);
}

+static int __proc_cpt_distance(void *data, int write,
+ loff_t pos, void __user *buffer, int nob)
+{
+ char *buf = NULL;
+ int len = 4096;
+ int rc = 0;
+
+ if (write)
+ return -EPERM;
+
+ LASSERT(cfs_cpt_table);
+
+ while (1) {
+ buf = kzalloc(len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ rc = cfs_cpt_distance_print(cfs_cpt_table, buf, len);
+ if (rc >= 0)
+ break;
+
+ if (rc == -EFBIG) {
+ kfree(buf);
+ len <<= 1;
+ continue;
+ }
+ goto out;
+ }
+
+ if (pos >= rc) {
+ rc = 0;
+ goto out;
+ }
+
+ rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
+out:
+ kfree(buf);
+ return rc;
+}
+
+static int proc_cpt_distance(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
+ __proc_cpt_distance);
+}
+
static struct ctl_table lnet_table[] = {
{
.procname = "debug",
@@ -365,6 +412,12 @@ static int proc_cpt_table(struct ctl_table *table, int write,
.proc_handler = &proc_cpt_table,
},
{
+ .procname = "cpu_partition_distance",
+ .maxlen = 128,
+ .mode = 0444,
+ .proc_handler = &proc_cpt_distance,
+ },
+ {
.procname = "debug_log_upcall",
.data = lnet_debug_log_upcall,
.maxlen = sizeof(lnet_debug_log_upcall),
--
1.8.3.1


2018-04-16 04:16:30

by James Simmons

[permalink] [raw]
Subject: [PATCH 03/25] staging: lustre: libcfs: implement cfs_cpt_cpumask for UMP case

From: Amir Shehata <[email protected]>

The function cfs_cpt_cpumask() exist for SMP systems but when
CONFIG_SMP is disabled it only returns NULL. Fill in this missing
function. Also properly initialize ctb_mask for the UMP
case.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h | 16 +++++-----------
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 9 +++++++++
2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 1f2cd78..070f8fe 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -77,10 +77,6 @@

#ifdef CONFIG_SMP
/**
- * return cpumask of CPU partition \a cpt
- */
-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);
@@ -89,19 +85,13 @@ struct cfs_cpt_table {
/* # of CPU partitions */
int ctb_nparts;
/* cpu mask */
- cpumask_t ctb_mask;
+ cpumask_var_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)
{
@@ -133,6 +123,10 @@ struct cfs_cpt_table {
*/
int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt);
/**
+ * return cpumask of CPU partition \a cpt
+ */
+cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt);
+/**
* return nodemask of CPU partition \a cpt
*/
nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt);
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 705abf2..5ea294f 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -54,6 +54,9 @@ struct cfs_cpt_table *
cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
if (cptab) {
cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
+ if (!zalloc_cpumask_var(&cptab->ctb_mask, GFP_NOFS))
+ return NULL;
+ cpumask_set_cpu(0, cptab->ctb_mask);
node_set(0, cptab->ctb_nodemask);
cptab->ctb_nparts = ncpt;
}
@@ -108,6 +111,12 @@ struct cfs_cpt_table *
}
EXPORT_SYMBOL(cfs_cpt_online);

+cpumask_var_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)
{
--
1.8.3.1


2018-04-16 04:16:47

by James Simmons

[permalink] [raw]
Subject: [PATCH 04/25] staging: lustre: libcfs: replace MAX_NUMNODES with nr_node_ids

From: Amir Shehata <[email protected]>

Replace depricated MAX_NUMNODES with nr_node_ids.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index d8c190c..d207ae5 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -368,7 +368,7 @@ struct cfs_cpt_table *
{
const cpumask_t *mask;

- if (node < 0 || node >= MAX_NUMNODES) {
+ if (node < 0 || node >= nr_node_ids) {
CDEBUG(D_INFO,
"Invalid NUMA id %d for CPU partition %d\n", node, cpt);
return 0;
@@ -385,7 +385,7 @@ struct cfs_cpt_table *
{
const cpumask_t *mask;

- if (node < 0 || node >= MAX_NUMNODES) {
+ if (node < 0 || node >= nr_node_ids) {
CDEBUG(D_INFO,
"Invalid NUMA id %d for CPU partition %d\n", node, cpt);
return;
@@ -809,7 +809,7 @@ struct cfs_cpt_table *
return cptab;
}

- high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
+ high = node ? nr_node_ids - 1 : nr_cpu_ids - 1;

for (str = strim(pattern), c = 0;; c++) {
struct cfs_range_expr *range;
--
1.8.3.1


2018-04-16 04:16:50

by James Simmons

[permalink] [raw]
Subject: [PATCH 08/25] staging: lustre: libcfs: add cpu distance handling

From: Amir Shehata <[email protected]>

Add functionality to calculate the distance between two CPTs.
Expose those distance in debugfs so people deploying a setup
can debug what is being created for CPTs.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../lustre/include/linux/libcfs/libcfs_cpu.h | 8 +++
.../lustre/include/linux/libcfs/linux/linux-cpu.h | 4 ++
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 21 ++++++++
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 59 ++++++++++++++++++++++
4 files changed, 92 insertions(+)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 839ec02..c0922fc 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -110,6 +110,10 @@ struct cfs_cpt_table {
*/
struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
/**
+ * print distance information of cpt-table
+ */
+int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len);
+/**
* return total number of CPU partitions in \a cptab
*/
int
@@ -143,6 +147,10 @@ struct cfs_cpt_table {
*/
int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node);
/**
+ * NUMA distance between \a cpt1 and \a cpt2 in \a cptab
+ */
+unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2);
+/**
* bind current thread on a CPU-partition \a cpt of \a cptab
*/
int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt);
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
index 1bed0ba..4ac1670 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
@@ -52,6 +52,8 @@ struct cfs_cpu_partition {
cpumask_var_t cpt_cpumask;
/* nodes mask for this partition */
nodemask_t *cpt_nodemask;
+ /* NUMA distance between CPTs */
+ unsigned int *cpt_distance;
/* spread rotor for NUMA allocator */
unsigned int cpt_spread_rotor;
};
@@ -60,6 +62,8 @@ struct cfs_cpu_partition {
struct cfs_cpt_table {
/* spread rotor for NUMA allocator */
unsigned int ctb_spread_rotor;
+ /* maximum NUMA distance between all nodes in table */
+ unsigned int ctb_distance;
/* # of CPU partitions */
unsigned int ctb_nparts;
/* partitions tables */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index e6d1512..7ac2796 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -41,6 +41,8 @@

#define CFS_CPU_VERSION_MAGIC 0xbabecafe

+#define CFS_CPT_DISTANCE 1 /* Arbitrary positive value */
+
struct cfs_cpt_table *
cfs_cpt_table_alloc(unsigned int ncpt)
{
@@ -90,6 +92,19 @@ struct cfs_cpt_table *
EXPORT_SYMBOL(cfs_cpt_table_print);
#endif /* CONFIG_SMP */

+int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
+{
+ int rc;
+
+ rc = snprintf(buf, len, "0\t: 0:%d\n", CFS_CPT_DISTANCE);
+ len -= rc;
+ if (len <= 0)
+ return -EFBIG;
+
+ return rc;
+}
+EXPORT_SYMBOL(cfs_cpt_distance_print);
+
int
cfs_cpt_number(struct cfs_cpt_table *cptab)
{
@@ -124,6 +139,12 @@ cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
}
EXPORT_SYMBOL(cfs_cpt_nodemask);

+unsigned int 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)
{
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index fd0c451..1e184b1 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -76,6 +76,7 @@
struct cfs_cpu_partition *part = &cptab->ctb_parts[i];

kfree(part->cpt_nodemask);
+ kfree(part->cpt_distance);
free_cpumask_var(part->cpt_cpumask);
}

@@ -137,6 +138,12 @@ struct cfs_cpt_table *
if (!zalloc_cpumask_var(&part->cpt_cpumask, GFP_NOFS) ||
!part->cpt_nodemask)
goto failed;
+
+ part->cpt_distance = kvmalloc_array(cptab->ctb_nparts,
+ sizeof(part->cpt_distance[0]),
+ GFP_KERNEL);
+ if (!part->cpt_distance)
+ goto failed;
}

return cptab;
@@ -190,6 +197,46 @@ struct cfs_cpt_table *
}
EXPORT_SYMBOL(cfs_cpt_table_print);

+int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
+{
+ char *tmp = buf;
+ int rc = -EFBIG;
+ int i;
+ int j;
+
+ for (i = 0; i < cptab->ctb_nparts; i++) {
+ if (len <= 0)
+ goto err;
+
+ rc = snprintf(tmp, len, "%d\t:", i);
+ len -= rc;
+
+ if (len <= 0)
+ goto err;
+
+ tmp += rc;
+ for (j = 0; j < cptab->ctb_nparts; j++) {
+ rc = snprintf(tmp, len, " %d:%d",
+ j, cptab->ctb_parts[i].cpt_distance[j]);
+ len -= rc;
+ if (len <= 0)
+ goto err;
+ tmp += rc;
+ }
+
+ *tmp = '\n';
+ tmp++;
+ len--;
+ }
+ rc = 0;
+err:
+ if (rc < 0)
+ return rc;
+
+ return tmp - buf;
+}
+EXPORT_SYMBOL(cfs_cpt_distance_print);
+
int
cfs_cpt_number(struct cfs_cpt_table *cptab)
{
@@ -241,6 +288,18 @@ struct cfs_cpt_table *
}
EXPORT_SYMBOL(cfs_cpt_nodemask);

+unsigned int 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));
+
+ if (cpt1 == CFS_CPT_ANY || cpt2 == CFS_CPT_ANY)
+ return cptab->ctb_distance;
+
+ return cptab->ctb_parts[cpt1].cpt_distance[cpt2];
+}
+EXPORT_SYMBOL(cfs_cpt_distance);
+
int
cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
{
--
1.8.3.1


2018-04-16 04:16:57

by James Simmons

[permalink] [raw]
Subject: [PATCH 09/25] staging: lustre: libcfs: use distance in cpu and node handling

From: Amir Shehata <[email protected]>

Take into consideration the location of NUMA nodes and core
when calling cfs_cpt_[un]set_cpu() and cfs_cpt_[un]set_node().
This enables functioning on platforms with 100s of cores and
NUMA nodes.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 192 +++++++++++++++------
1 file changed, 143 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 1e184b1..bbf89b8 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -300,11 +300,134 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
}
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 int cfs_cpt_distance_calculate(nodemask_t *from_mask,
+ nodemask_t *to_mask)
+{
+ unsigned int maximum;
+ unsigned int distance;
+ int from;
+ int to;
+
+ maximum = 0;
+ for_each_node_mask(from, *from_mask) {
+ for_each_node_mask(to, *to_mask) {
+ distance = node_distance(from, to);
+ if (maximum < distance)
+ maximum = distance;
+ }
+ }
+ return maximum;
+}
+
+static void cfs_cpt_add_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+{
+ cptab->ctb_cpu2cpt[cpu] = cpt;
+
+ cpumask_set_cpu(cpu, cptab->ctb_cpumask);
+ cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+}
+
+static void cfs_cpt_del_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+{
+ cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+ cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
+
+ cptab->ctb_cpu2cpt[cpu] = -1;
+}
+
+static void cfs_cpt_add_node(struct cfs_cpt_table *cptab, int cpt, int node)
+{
+ struct cfs_cpu_partition *part;
+
+ if (!node_isset(node, *cptab->ctb_nodemask)) {
+ unsigned int dist;
+
+ /* first time node is added to the CPT table */
+ node_set(node, *cptab->ctb_nodemask);
+ cptab->ctb_node2cpt[node] = cpt;
+
+ dist = cfs_cpt_distance_calculate(cptab->ctb_nodemask,
+ cptab->ctb_nodemask);
+ cptab->ctb_distance = dist;
+ }
+
+ part = &cptab->ctb_parts[cpt];
+ if (!node_isset(node, *part->cpt_nodemask)) {
+ int cpt2;
+
+ /* first time node is added to this CPT */
+ node_set(node, *part->cpt_nodemask);
+ for (cpt2 = 0; cpt2 < cptab->ctb_nparts; cpt2++) {
+ struct cfs_cpu_partition *part2;
+ unsigned int dist;
+
+ part2 = &cptab->ctb_parts[cpt2];
+ dist = cfs_cpt_distance_calculate(part->cpt_nodemask,
+ part2->cpt_nodemask);
+ part->cpt_distance[cpt2] = dist;
+ dist = cfs_cpt_distance_calculate(part2->cpt_nodemask,
+ part->cpt_nodemask);
+ part2->cpt_distance[cpt] = dist;
+ }
+ }
+}
+
+static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
+{
+ struct cfs_cpu_partition *part = &cptab->ctb_parts[cpt];
+ int cpu;
+
+ for_each_cpu(cpu, part->cpt_cpumask) {
+ /* this CPT has other CPU belonging to this node? */
+ if (cpu_to_node(cpu) == node)
+ break;
+ }
+
+ if (cpu >= nr_cpu_ids && node_isset(node, *part->cpt_nodemask)) {
+ int cpt2;
+
+ /* No more CPUs in the node for this CPT. */
+ node_clear(node, *part->cpt_nodemask);
+ for (cpt2 = 0; cpt2 < cptab->ctb_nparts; cpt2++) {
+ struct cfs_cpu_partition *part2;
+ unsigned int dist;
+
+ part2 = &cptab->ctb_parts[cpt2];
+ if (node_isset(node, *part2->cpt_nodemask))
+ cptab->ctb_node2cpt[node] = cpt2;
+
+ dist = cfs_cpt_distance_calculate(part->cpt_nodemask,
+ part2->cpt_nodemask);
+ part->cpt_distance[cpt2] = dist;
+ dist = cfs_cpt_distance_calculate(part2->cpt_nodemask,
+ part->cpt_nodemask);
+ part2->cpt_distance[cpt] = dist;
+ }
+ }
+
+ for_each_cpu(cpu, cptab->ctb_cpumask) {
+ /* this CPT-table has other CPUs belonging to this node? */
+ if (cpu_to_node(cpu) == node)
+ break;
+ }
+
+ if (cpu >= nr_cpu_ids && node_isset(node, *cptab->ctb_nodemask)) {
+ /* No more CPUs in the table for this node. */
+ node_clear(node, *cptab->ctb_nodemask);
+ cptab->ctb_node2cpt[node] = -1;
+ cptab->ctb_distance =
+ cfs_cpt_distance_calculate(cptab->ctb_nodemask,
+ cptab->ctb_nodemask);
+ }
+}
+
int
cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
{
- int node;
-
LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts);

if (cpu < 0 || cpu >= nr_cpu_ids || !cpu_online(cpu)) {
@@ -318,23 +441,11 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
return 0;
}

- cptab->ctb_cpu2cpt[cpu] = cpt;
-
LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));

- cpumask_set_cpu(cpu, cptab->ctb_cpumask);
- cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
-
- node = cpu_to_node(cpu);
-
- /* first CPU of @node in this CPT table */
- if (!node_isset(node, *cptab->ctb_nodemask))
- node_set(node, *cptab->ctb_nodemask);
-
- /* first CPU of @node in this partition */
- if (!node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask))
- node_set(node, *cptab->ctb_parts[cpt].cpt_nodemask);
+ cfs_cpt_add_cpu(cptab, cpt, cpu);
+ cfs_cpt_add_node(cptab, cpt, cpu_to_node(cpu));

return 1;
}
@@ -343,9 +454,6 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
void
cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
{
- int node;
- int i;
-
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));

if (cpu < 0 || cpu >= nr_cpu_ids) {
@@ -371,32 +479,8 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
LASSERT(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask));

- cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
- cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
- cptab->ctb_cpu2cpt[cpu] = -1;
-
- node = cpu_to_node(cpu);
-
- LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
- LASSERT(node_isset(node, *cptab->ctb_nodemask));
-
- for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) {
- /* this CPT has other CPU belonging to this node? */
- if (cpu_to_node(i) == node)
- break;
- }
-
- if (i >= nr_cpu_ids)
- node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
-
- for_each_cpu(i, cptab->ctb_cpumask) {
- /* this CPT-table has other CPU belonging to this node? */
- if (cpu_to_node(i) == node)
- break;
- }
-
- if (i >= nr_cpu_ids)
- node_clear(node, *cptab->ctb_nodemask);
+ cfs_cpt_del_cpu(cptab, cpt, cpu);
+ cfs_cpt_del_node(cptab, cpt, cpu_to_node(cpu));
}
EXPORT_SYMBOL(cfs_cpt_unset_cpu);

@@ -413,8 +497,8 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
}

for_each_cpu(cpu, mask) {
- if (!cfs_cpt_set_cpu(cptab, cpt, cpu))
- return 0;
+ cfs_cpt_add_cpu(cptab, cpt, cpu);
+ cfs_cpt_add_node(cptab, cpt, cpu_to_node(cpu));
}

return 1;
@@ -436,6 +520,7 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
{
const cpumask_t *mask;
+ int cpu;

if (node < 0 || node >= nr_node_ids) {
CDEBUG(D_INFO,
@@ -445,7 +530,12 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)

mask = cpumask_of_node(node);

- return cfs_cpt_set_cpumask(cptab, cpt, mask);
+ for_each_cpu(cpu, mask)
+ cfs_cpt_add_cpu(cptab, cpt, cpu);
+
+ cfs_cpt_add_node(cptab, cpt, node);
+
+ return 1;
}
EXPORT_SYMBOL(cfs_cpt_set_node);

@@ -453,6 +543,7 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
{
const cpumask_t *mask;
+ int cpu;

if (node < 0 || node >= nr_node_ids) {
CDEBUG(D_INFO,
@@ -462,7 +553,10 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)

mask = cpumask_of_node(node);

- cfs_cpt_unset_cpumask(cptab, cpt, mask);
+ for_each_cpu(cpu, mask)
+ cfs_cpt_del_cpu(cptab, cpt, cpu);
+
+ cfs_cpt_del_node(cptab, cpt, node);
}
EXPORT_SYMBOL(cfs_cpt_unset_node);

--
1.8.3.1


2018-04-16 04:17:11

by James Simmons

[permalink] [raw]
Subject: [PATCH 01/25] staging: lustre: libcfs: remove useless CPU partition code

From: Dmitry Eremin <[email protected]>

* remove scratch buffer and mutex which guard it.
* remove global cpumask and spinlock which guard it.
* remove cpt_version for checking CPUs state change during setup
because of just disable CPUs state change during setup.
* remove whole global struct cfs_cpt_data cpt_data.
* remove few unused APIs.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23303
Reviewed-on: https://review.whamcloud.com/25048
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../lustre/include/linux/libcfs/libcfs_cpu.h | 13 +--
.../lustre/include/linux/libcfs/linux/linux-cpu.h | 2 -
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 18 +---
.../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 114 +++------------------
4 files changed, 20 insertions(+), 127 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 61bce77..1f2cd78 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -162,12 +162,12 @@ struct cfs_cpt_table {
* return 1 if successfully set all CPUs, otherwise return 0
*/
int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab,
- int cpt, cpumask_t *mask);
+ 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, cpumask_t *mask);
+ 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
@@ -190,20 +190,11 @@ int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab,
void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
int cpt, nodemask_t *mask);
/**
- * unset all cpus for CPU partition \a cpt
- */
-void cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt);
-/**
* 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.
*/
int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt);

-/**
- * return number of HTs in the same core of \a cpu
- */
-int cfs_cpu_ht_nsiblings(int cpu);
-
/*
* allocate per-cpu-partition data, returned value is an array of pointers,
* variable can be indexed by CPU ID.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
index 6035376..e8bbbaa 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
@@ -58,8 +58,6 @@ struct cfs_cpu_partition {

/** descriptor for CPU partitions */
struct cfs_cpt_table {
- /* version, reserved for hotplug */
- unsigned int ctb_version;
/* spread rotor for NUMA allocator */
unsigned int ctb_spread_rotor;
/* # of CPU partitions */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 76291a3..705abf2 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -129,14 +129,15 @@ struct cfs_cpt_table *
EXPORT_SYMBOL(cfs_cpt_unset_cpu);

int
-cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+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, cpumask_t *mask)
+cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
+ const cpumask_t *mask)
{
}
EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
@@ -167,12 +168,6 @@ struct cfs_cpt_table *
}
EXPORT_SYMBOL(cfs_cpt_unset_nodemask);

-void
-cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
-{
-}
-EXPORT_SYMBOL(cfs_cpt_clear);
-
int
cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
{
@@ -181,13 +176,6 @@ struct cfs_cpt_table *
EXPORT_SYMBOL(cfs_cpt_spread_node);

int
-cfs_cpu_ht_nsiblings(int cpu)
-{
- return 1;
-}
-EXPORT_SYMBOL(cfs_cpu_ht_nsiblings);
-
-int
cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
{
return 0;
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 388521e..134b239 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -64,30 +64,6 @@
module_param(cpu_pattern, charp, 0444);
MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern");

-struct cfs_cpt_data {
- /* serialize hotplug etc */
- spinlock_t cpt_lock;
- /* reserved for hotplug */
- unsigned long cpt_version;
- /* mutex to protect cpt_cpumask */
- struct mutex cpt_mutex;
- /* scratch buffer for set/unset_node */
- cpumask_var_t cpt_cpumask;
-};
-
-static struct cfs_cpt_data cpt_data;
-
-static void
-cfs_node_to_cpumask(int node, cpumask_t *mask)
-{
- const cpumask_t *tmp = cpumask_of_node(node);
-
- if (tmp)
- cpumask_copy(mask, tmp);
- else
- cpumask_clear(mask);
-}
-
void
cfs_cpt_table_free(struct cfs_cpt_table *cptab)
{
@@ -153,11 +129,6 @@ struct cfs_cpt_table *
goto failed;
}

- spin_lock(&cpt_data.cpt_lock);
- /* Reserved for hotplug */
- cptab->ctb_version = cpt_data.cpt_version;
- spin_unlock(&cpt_data.cpt_lock);
-
return cptab;

failed:
@@ -361,7 +332,7 @@ struct cfs_cpt_table *
EXPORT_SYMBOL(cfs_cpt_unset_cpu);

int
-cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, const cpumask_t *mask)
{
int i;

@@ -382,7 +353,8 @@ struct cfs_cpt_table *
EXPORT_SYMBOL(cfs_cpt_set_cpumask);

void
-cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
+ const cpumask_t *mask)
{
int i;

@@ -394,7 +366,7 @@ struct cfs_cpt_table *
int
cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
{
- int rc;
+ const cpumask_t *mask;

if (node < 0 || node >= MAX_NUMNODES) {
CDEBUG(D_INFO,
@@ -402,34 +374,26 @@ struct cfs_cpt_table *
return 0;
}

- mutex_lock(&cpt_data.cpt_mutex);
-
- cfs_node_to_cpumask(node, cpt_data.cpt_cpumask);
-
- rc = cfs_cpt_set_cpumask(cptab, cpt, cpt_data.cpt_cpumask);
-
- mutex_unlock(&cpt_data.cpt_mutex);
+ mask = cpumask_of_node(node);

- return rc;
+ return cfs_cpt_set_cpumask(cptab, cpt, mask);
}
EXPORT_SYMBOL(cfs_cpt_set_node);

void
cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
{
+ const cpumask_t *mask;
+
if (node < 0 || node >= MAX_NUMNODES) {
CDEBUG(D_INFO,
"Invalid NUMA id %d for CPU partition %d\n", node, cpt);
return;
}

- mutex_lock(&cpt_data.cpt_mutex);
-
- cfs_node_to_cpumask(node, cpt_data.cpt_cpumask);
+ mask = cpumask_of_node(node);

- cfs_cpt_unset_cpumask(cptab, cpt, cpt_data.cpt_cpumask);
-
- mutex_unlock(&cpt_data.cpt_mutex);
+ cfs_cpt_unset_cpumask(cptab, cpt, mask);
}
EXPORT_SYMBOL(cfs_cpt_unset_node);

@@ -457,26 +421,6 @@ struct cfs_cpt_table *
}
EXPORT_SYMBOL(cfs_cpt_unset_nodemask);

-void
-cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
-{
- int last;
- int i;
-
- if (cpt == CFS_CPT_ANY) {
- last = cptab->ctb_nparts - 1;
- cpt = 0;
- } else {
- last = cpt;
- }
-
- for (; cpt <= last; cpt++) {
- for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask)
- cfs_cpt_unset_cpu(cptab, cpt, i);
- }
-}
-EXPORT_SYMBOL(cfs_cpt_clear);
-
int
cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
{
@@ -749,7 +693,7 @@ struct cfs_cpt_table *
}

for_each_online_node(i) {
- cfs_node_to_cpumask(i, mask);
+ cpumask_copy(mask, cpumask_of_node(i));

while (!cpumask_empty(mask)) {
struct cfs_cpu_partition *part;
@@ -955,16 +899,8 @@ struct cfs_cpt_table *
#ifdef CONFIG_HOTPLUG_CPU
static enum cpuhp_state lustre_cpu_online;

-static void cfs_cpu_incr_cpt_version(void)
-{
- spin_lock(&cpt_data.cpt_lock);
- cpt_data.cpt_version++;
- spin_unlock(&cpt_data.cpt_lock);
-}
-
static int cfs_cpu_online(unsigned int cpu)
{
- cfs_cpu_incr_cpt_version();
return 0;
}

@@ -972,14 +908,9 @@ static int cfs_cpu_dead(unsigned int cpu)
{
bool warn;

- cfs_cpu_incr_cpt_version();
-
- mutex_lock(&cpt_data.cpt_mutex);
/* if all HTs in a core are offline, it may break affinity */
- cpumask_copy(cpt_data.cpt_cpumask, topology_sibling_cpumask(cpu));
- warn = cpumask_any_and(cpt_data.cpt_cpumask,
+ warn = cpumask_any_and(topology_sibling_cpumask(cpu),
cpu_online_mask) >= nr_cpu_ids;
- mutex_unlock(&cpt_data.cpt_mutex);
CDEBUG(warn ? D_WARNING : D_INFO,
"Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n",
cpu);
@@ -998,7 +929,6 @@ static int cfs_cpu_dead(unsigned int cpu)
cpuhp_remove_state_nocalls(lustre_cpu_online);
cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD);
#endif
- free_cpumask_var(cpt_data.cpt_cpumask);
}

int
@@ -1008,16 +938,6 @@ static int cfs_cpu_dead(unsigned int cpu)

LASSERT(!cfs_cpt_table);

- memset(&cpt_data, 0, sizeof(cpt_data));
-
- if (!zalloc_cpumask_var(&cpt_data.cpt_cpumask, GFP_NOFS)) {
- CERROR("Failed to allocate scratch buffer\n");
- return -1;
- }
-
- spin_lock_init(&cpt_data.cpt_lock);
- mutex_init(&cpt_data.cpt_mutex);
-
#ifdef CONFIG_HOTPLUG_CPU
ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD,
"staging/lustre/cfe:dead", NULL,
@@ -1033,6 +953,7 @@ static int cfs_cpu_dead(unsigned int cpu)
#endif
ret = -EINVAL;

+ get_online_cpus();
if (*cpu_pattern) {
char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);

@@ -1058,13 +979,7 @@ static int cfs_cpu_dead(unsigned int cpu)
}
}

- spin_lock(&cpt_data.cpt_lock);
- if (cfs_cpt_table->ctb_version != cpt_data.cpt_version) {
- spin_unlock(&cpt_data.cpt_lock);
- CERROR("CPU hotplug/unplug during setup\n");
- goto failed;
- }
- spin_unlock(&cpt_data.cpt_lock);
+ put_online_cpus();

LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
num_online_nodes(), num_online_cpus(),
@@ -1072,6 +987,7 @@ static int cfs_cpu_dead(unsigned int cpu)
return 0;

failed:
+ put_online_cpus();
cfs_cpu_fini();
return ret;
}
--
1.8.3.1


2018-04-16 04:17:53

by James Simmons

[permalink] [raw]
Subject: [PATCH 06/25] staging: lustre: libcfs: replace num_possible_cpus() with nr_cpu_ids

From: Amir Shehata <[email protected]>

Move from num_possible_cpus() to nr_cpu_ids.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index b2a88ef..741db69 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -105,14 +105,14 @@ struct cfs_cpt_table *
!cptab->ctb_nodemask)
goto failed;

- cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(),
+ cptab->ctb_cpu2cpt = kvmalloc_array(nr_cpu_ids,
sizeof(cptab->ctb_cpu2cpt[0]),
GFP_KERNEL);
if (!cptab->ctb_cpu2cpt)
goto failed;

memset(cptab->ctb_cpu2cpt, -1,
- num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
+ nr_cpu_ids * sizeof(cptab->ctb_cpu2cpt[0]));

cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
GFP_KERNEL);
--
1.8.3.1


2018-04-16 04:23:24

by James Simmons

[permalink] [raw]
Subject: [PATCH 05/25] staging: lustre: libcfs: remove excess space

From: Amir Shehata <[email protected]>

The function cfs_cpt_table_print() was adding two spaces
to the string buffer. Just add it once.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index d207ae5..b2a88ef 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -147,7 +147,7 @@ struct cfs_cpt_table *

for (i = 0; i < cptab->ctb_nparts; i++) {
if (len > 0) {
- rc = snprintf(tmp, len, "%d\t: ", i);
+ rc = snprintf(tmp, len, "%d\t:", i);
len -= rc;
}

--
1.8.3.1


2018-04-16 04:43:56

by James Simmons

[permalink] [raw]
Subject: [PATCH 02/25] staging: lustre: libcfs: rename variable i to cpu

From: Dmitry Eremin <[email protected]>

Change the name of the variable i used for for_each_cpu() to cpu
for code readability.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23303
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 134b239..d8c190c 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -334,7 +334,7 @@ struct cfs_cpt_table *
int
cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, const cpumask_t *mask)
{
- int i;
+ int cpu;

if (!cpumask_weight(mask) ||
cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
@@ -343,8 +343,8 @@ struct cfs_cpt_table *
return 0;
}

- for_each_cpu(i, mask) {
- if (!cfs_cpt_set_cpu(cptab, cpt, i))
+ for_each_cpu(cpu, mask) {
+ if (!cfs_cpt_set_cpu(cptab, cpt, cpu))
return 0;
}

@@ -356,10 +356,10 @@ struct cfs_cpt_table *
cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
const cpumask_t *mask)
{
- int i;
+ int cpu;

- for_each_cpu(i, mask)
- cfs_cpt_unset_cpu(cptab, cpt, i);
+ for_each_cpu(cpu, mask)
+ cfs_cpt_unset_cpu(cptab, cpt, cpu);
}
EXPORT_SYMBOL(cfs_cpt_unset_cpumask);

--
1.8.3.1


2018-04-16 04:44:51

by James Simmons

[permalink] [raw]
Subject: [PATCH 07/25] staging: lustre: libcfs: NUMA support

From: Amir Shehata <[email protected]>

This patch adds NUMA node support. NUMA node information is stored
in the CPT table. A NUMA node mask is maintained for the entire
table as well as for each CPT to track the NUMA nodes related to
each of the CPTs. Add new function cfs_cpt_of_node() which returns
the CPT of a particular NUMA node.

Signed-off-by: Amir Shehata <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber <[email protected]>
Reviewed-by: Doug Oucharek <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/include/linux/libcfs/libcfs_cpu.h | 4 ++++
.../lustre/include/linux/libcfs/linux/linux-cpu.h | 2 ++
drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 6 ++++++
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 19 +++++++++++++++++++
4 files changed, 31 insertions(+)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 070f8fe..839ec02 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -139,6 +139,10 @@ struct cfs_cpt_table {
*/
int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu);
/**
+ * shadow HW node ID \a NODE to CPU-partition ID by \a cptab
+ */
+int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node);
+/**
* bind current thread on a CPU-partition \a cpt of \a cptab
*/
int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt);
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
index e8bbbaa..1bed0ba 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
@@ -68,6 +68,8 @@ struct cfs_cpt_table {
int *ctb_cpu2cpt;
/* all cpus in this partition table */
cpumask_var_t ctb_cpumask;
+ /* shadow HW node to CPU partition ID */
+ int *ctb_node2cpt;
/* all nodes in this partition table */
nodemask_t *ctb_nodemask;
};
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 5ea294f..e6d1512 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -198,6 +198,12 @@ cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
}
EXPORT_SYMBOL(cfs_cpt_of_cpu);

+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)
{
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 741db69..fd0c451 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -70,6 +70,7 @@
int i;

kvfree(cptab->ctb_cpu2cpt);
+ kvfree(cptab->ctb_node2cpt);

for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
@@ -114,6 +115,15 @@ struct cfs_cpt_table *
memset(cptab->ctb_cpu2cpt, -1,
nr_cpu_ids * sizeof(cptab->ctb_cpu2cpt[0]));

+ cptab->ctb_node2cpt = kvmalloc_array(nr_node_ids,
+ sizeof(cptab->ctb_node2cpt[0]),
+ GFP_KERNEL);
+ if (!cptab->ctb_node2cpt)
+ goto failed;
+
+ memset(cptab->ctb_node2cpt, -1,
+ nr_node_ids * sizeof(cptab->ctb_node2cpt[0]));
+
cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
GFP_KERNEL);
if (!cptab->ctb_parts)
@@ -484,6 +494,15 @@ struct cfs_cpt_table *
}
EXPORT_SYMBOL(cfs_cpt_of_cpu);

+int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
+{
+ if (node < 0 || node > nr_node_ids)
+ return CFS_CPT_ANY;
+
+ return cptab->ctb_node2cpt[node];
+}
+EXPORT_SYMBOL(cfs_cpt_of_node);
+
int
cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
{
--
1.8.3.1


2018-04-16 05:10:50

by James Simmons

[permalink] [raw]
Subject: [PATCH 14/25] staging: lustre: libcfs: rename i to node for cfs_cpt_set_nodemask

From: Dmitry Eremin <[email protected]>

Rename variable i to node to make code easier to understand.

Signed-off-by: Dmitry Eremin <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata <[email protected]>
Reviewed-by: James Simmons <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 1669669..5f2ab30 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -550,10 +550,10 @@ void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt,
const nodemask_t *mask)
{
- int i;
+ int node;

- for_each_node_mask(i, *mask) {
- if (!cfs_cpt_set_node(cptab, cpt, i))
+ for_each_node_mask(node, *mask) {
+ if (!cfs_cpt_set_node(cptab, cpt, node))
return 0;
}

@@ -564,10 +564,10 @@ int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt,
void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt,
const nodemask_t *mask)
{
- int i;
+ int node;

- for_each_node_mask(i, *mask)
- cfs_cpt_unset_node(cptab, cpt, i);
+ for_each_node_mask(node, *mask)
+ cfs_cpt_unset_node(cptab, cpt, node);
}
EXPORT_SYMBOL(cfs_cpt_unset_nodemask);

--
1.8.3.1


2018-04-16 13:44:22

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 01/25] staging: lustre: libcfs: remove useless CPU partition code

On Mon, Apr 16, 2018 at 12:09:43AM -0400, James Simmons wrote:
> @@ -1033,6 +953,7 @@ static int cfs_cpu_dead(unsigned int cpu)
> #endif
> ret = -EINVAL;
>
> + get_online_cpus();
> if (*cpu_pattern) {
> char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);
>
> @@ -1058,13 +979,7 @@ static int cfs_cpu_dead(unsigned int cpu)
> }
> }
>
> - spin_lock(&cpt_data.cpt_lock);
> - if (cfs_cpt_table->ctb_version != cpt_data.cpt_version) {
> - spin_unlock(&cpt_data.cpt_lock);
> - CERROR("CPU hotplug/unplug during setup\n");
> - goto failed;
> - }
> - spin_unlock(&cpt_data.cpt_lock);
> + put_online_cpus();
>
> LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
> num_online_nodes(), num_online_cpus(),
> @@ -1072,6 +987,7 @@ static int cfs_cpu_dead(unsigned int cpu)
> return 0;
>
> failed:
> + put_online_cpus();
> cfs_cpu_fini();
> return ret;
> }

When you have a one label called "failed" then I call that "one err"
style error handling and it's the most bug prone style of error handling
to use. Always be suspicious of code that uses a "err:" labels.

The bug here is typical. We are calling put_online_cpus() on paths
where we didn't call get_online_cpus().

The best way to do error handling is to keep track of each resource that
was allocated and then only free the things that have been allocated.
Also the label name should indicate what was freed. Generally avoid
magic, opaque functions like cfs_cpu_fini(). As a reviewer, it's
harder for me to check that cfs_cpu_fini() frees everything correctly
instead of the a normal list of frees like:

free_table:
cfs_cpt_table_free(cfs_cpt_table);
free_hotplug_stuff:
cpuhp_remove_state_nocalls(lustre_cpu_online);
set_state_dead:
cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD);

When I'm reading the code, and I see a "goto free_table;", I only need
to ask, "Was table the most recently allocated resource?" If yes, then
the code is correct, if no then it's buggy. It's simple review.

regards,
dan carpenter


2018-04-16 13:57:53

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 04/25] staging: lustre: libcfs: replace MAX_NUMNODES with nr_node_ids

On Mon, Apr 16, 2018 at 12:09:46AM -0400, James Simmons wrote:
> From: Amir Shehata <[email protected]>
>
> Replace depricated MAX_NUMNODES with nr_node_ids.
>

The changelog makes it sound like this is just a style change, but it's
actually a behavior change isn't it?

regards,
dan carpenter


2018-04-16 14:35:47

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 03/25] staging: lustre: libcfs: implement cfs_cpt_cpumask for UMP case

On Mon, Apr 16, 2018 at 12:09:45AM -0400, James Simmons wrote:
> diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
> index 705abf2..5ea294f 100644
> --- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
> +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
> @@ -54,6 +54,9 @@ struct cfs_cpt_table *
> cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
> if (cptab) {
^^^^^^^^^^^^
Don't do "success handling", do "error handling". Success handling
means we have to indent the code and it makes it more complicated to
read. Ideally code would look like:

do_this();
do_that();
do_the_next_thing();

But because of error handling then we have to add a bunch of if
statements. It's better when those if statements are very quick and
we can move on. The success path is all at indent level one still like
and ideal situation above and the the error paths are at indent level
two.

if (!cptab)
return NULL;


> cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
> + if (!zalloc_cpumask_var(&cptab->ctb_mask, GFP_NOFS))
> + return NULL;

This leaks. It should be:

if (!zalloc_cpumask_var(&cptab->ctb_mask, GFP_NOFS)) {
kfree(cptab);
return NULL;
}

> + cpumask_set_cpu(0, cptab->ctb_mask);
> node_set(0, cptab->ctb_nodemask);
> cptab->ctb_nparts = ncpt;
> }

regards,
dan carpenter

2018-04-16 14:36:41

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 07/25] staging: lustre: libcfs: NUMA support

On Mon, Apr 16, 2018 at 12:09:49AM -0400, James Simmons wrote:
> @@ -114,6 +115,15 @@ struct cfs_cpt_table *
> memset(cptab->ctb_cpu2cpt, -1,
> nr_cpu_ids * sizeof(cptab->ctb_cpu2cpt[0]));
>
> + cptab->ctb_node2cpt = kvmalloc_array(nr_node_ids,
> + sizeof(cptab->ctb_node2cpt[0]),
> + GFP_KERNEL);
> + if (!cptab->ctb_node2cpt)
> + goto failed;
> +
> + memset(cptab->ctb_node2cpt, -1,
> + nr_node_ids * sizeof(cptab->ctb_node2cpt[0]));
> +
> cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
> GFP_KERNEL);
> if (!cptab->ctb_parts)


You didn't introduce this, but I was explaining earlier that you should
always be suspicious of code which does "goto failed". The bug here is
that cptab->ctb_parts is allocated with kvmalloc_array() which
doesn't zero out the memory. So if we only initialize it part way
because art->cpt_nodemask = kzalloc() fails or something then it's
problem:

91 void
92 cfs_cpt_table_free(struct cfs_cpt_table *cptab)
93 {
94 int i;
95
96 kvfree(cptab->ctb_cpu2cpt);
97
98 for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
99 struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
100
101 kfree(part->cpt_nodemask);
^^^^^^^^^^^^^^^^^^^
102 free_cpumask_var(part->cpt_cpumask);
^^^^^^^^^^^^^^^^^
These are uninitialized so it will crash. It turns out there isn't a
kvcalloc() or kvzalloc_array() function. We don't seem to have a
vcalloc() either... Very strange.

103 }
104
105 kvfree(cptab->ctb_parts);
106
107 kfree(cptab->ctb_nodemask);
108 free_cpumask_var(cptab->ctb_cpumask);
109
110 kfree(cptab);
111 }

regards,
dan carpenter

2018-04-16 14:47:42

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 08/25] staging: lustre: libcfs: add cpu distance handling

On Mon, Apr 16, 2018 at 12:09:50AM -0400, James Simmons wrote:
> +int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
> +{
> + char *tmp = buf;
> + int rc = -EFBIG;
> + int i;
> + int j;
> +
> + for (i = 0; i < cptab->ctb_nparts; i++) {
> + if (len <= 0)
> + goto err;
> +
> + rc = snprintf(tmp, len, "%d\t:", i);
> + len -= rc;
> +
> + if (len <= 0)
> + goto err;


The "goto err" here is sort of an example of a "do-nothing" goto. There
are no resources to free or anything like that.

I don't like do-nothing gotos because "return -EFBIG;" is self
documenting code and "goto err;" is totally ambiguous what it does. The
second problem is that do-nothing error labels easily turn into
do-everything one err style error paths which I loath. And the third
problem is that they introduce "forgot to set the error code" bugs.

It looks like we forgot to set the error code here although it's also
possible that was intended. This code is ambiguous.

> +
> + tmp += rc;
> + for (j = 0; j < cptab->ctb_nparts; j++) {
> + rc = snprintf(tmp, len, " %d:%d",
> + j, cptab->ctb_parts[i].cpt_distance[j]);
> + len -= rc;
> + if (len <= 0)
> + goto err;
> + tmp += rc;
> + }
> +
> + *tmp = '\n';
> + tmp++;
> + len--;
> + }
> + rc = 0;
> +err:
> + if (rc < 0)
> + return rc;
> +
> + return tmp - buf;
> +}

regards,
dan carpenter

2018-04-17 07:16:44

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 11/25] staging: lustre: libcfs: invert error handling for cfs_cpt_table_print

On Mon, Apr 16, 2018 at 12:09:53AM -0400, James Simmons wrote:
> From: Amir Shehata <[email protected]>
>
> Instead of setting rc to -EFBIG for several cases in the loop lets
> initialize rc to -EFBIG and just break out of the loop in case of
> failure. Just set rc to zero once we successfully finish the loop.
>
> Signed-off-by: Amir Shehata <[email protected]>
> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
> Reviewed-on: http://review.whamcloud.com/18916
> Reviewed-by: Olaf Weber <[email protected]>
> Reviewed-by: Doug Oucharek <[email protected]>
> Signed-off-by: James Simmons <[email protected]>
> ---
> .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
> index bbf89b8..6d8dcd3 100644
> --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
> +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
> @@ -158,29 +158,26 @@ struct cfs_cpt_table *
> cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
> {
> char *tmp = buf;
> - int rc = 0;
> + int rc = -EFBIG;
> int i;
> int j;
>
> for (i = 0; i < cptab->ctb_nparts; i++) {
> - if (len > 0) {
> - rc = snprintf(tmp, len, "%d\t:", i);
> - len -= rc;
> - }
> + if (len <= 0)
> + goto out;
> +
> + rc = snprintf(tmp, len, "%d\t:", i);
> + len -= rc;
>
> - if (len <= 0) {
> - rc = -EFBIG;
> + if (len <= 0)
> goto out;

This patch says it's a cleanup but the only thing it does is introduce
"forgot to set the error" bugs.

regards,
dan carpenter


2018-04-17 07:36:45

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 17/25] staging: lustre: libcfs: rename goto label in cfs_cpt_table_print

> diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
> index ae5ff58..435ee8e 100644
> --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
> +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
> @@ -161,20 +161,20 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
>
> for (i = 0; i < cptab->ctb_nparts; i++) {
> if (len <= 0)
> - goto out;
> + goto err;
>
> rc = snprintf(tmp, len, "%d\t:", i);
> len -= rc;
>
> if (len <= 0)
> - goto out;
> + goto err;

Labels should say what the goto does. In this case, it's a do-nothing
goto with a "forgot to set the error code" bug.

regards,
dan carpenter


2018-04-17 07:41:26

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 18/25] staging: lustre: libcfs: clear up failure patch in cfs_cpt_*_print

> -err:
> - if (rc < 0)
> - return rc;
> -
> return tmp - buf;
> +
> +err:
> + return -E2BIG;


We finally fixed this bug! Hooray! But it's like you guys are
deliberately writing in terrible style. You can just return directly
and then you would have avoided this bug altogether from square one!

People think that by adding little twists and moving code to the end
of the function the it will be less buggy. It's not true. It's like at
a hospital if they just swept the cockroaches under the bed, just
because it's at the end of the function where you can't see it or review
it doesn't mean it's not buggy.

regards,
dan carpenter


2018-04-23 13:01:59

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/25] staging: lustre: libcfs: SMP rework

On Mon, Apr 16, 2018 at 12:09:42AM -0400, James Simmons wrote:
> Recently lustre support has been expanded to extreme machines with as
> many as a 1000+ cores. On the other end lustre also has been ported
> to platforms like ARM and KNL which have uniquie NUMA and core setup.
> For example some devices exist that have NUMA nodes with no cores.
> With these new platforms the limitations of the Lustre's SMP code
> came to light so a lot of work was needed. This resulted in this
> patch set which has been tested on these platforms.

I'll wait for v2 of this patchset based on Dan's review before applying
them.

thanks,

greg k-h