Whamcloud - gitweb
LU-9859 libcfs: migrate libcfs_mem.c to lnet/lib-mem.c 01/52701/5
authorJames Simmons <jsimmons@infradead.org>
Sun, 15 Oct 2023 00:25:55 +0000 (20:25 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Nov 2023 22:01:58 +0000 (22:01 +0000)
Move the libcfs_mem.c code to the LNet core. The prototypes are declared in libcfs_cpu.h
but we don't move them yet since the CPT code depends on the libcfs_mem.c work. This can
end up in a modular cyclic dependency if we move the CPT work right away so limit what is
changed at this point.

Test-Parameters: trivial
Change-Id: I6bf5cd9f20033f988dde1989f0fc5f89ea74b5a2
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52701
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/libcfs/Makefile.in
libcfs/libcfs/autoMakefile.am
lnet/lnet/Makefile.in
lnet/lnet/lib-mem.c [moved from libcfs/libcfs/libcfs_mem.c with 73% similarity]

index 2205ad7..3dd6942 100644 (file)
@@ -18,7 +18,6 @@ libcfs-crypto-objs := $(addprefix crypto/,$(libcfs-crypto-objs))
 libcfs-objs-$(CONFIG_SMP) = libcfs_cpu.o
 libcfs-all-objs := debug.o fail.o module.o tracefile.o \
                   libcfs_string.o hash.o \
-                  libcfs_mem.o \
                   linux-crypto.o linux-crypto-adler.o \
                   $(libcfs-objs-y)
 
index 70698e6..8c312a0 100644 (file)
@@ -58,5 +58,4 @@ endif # MODULES
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux/*.o libcfs crypto/*.o
 EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) tracefile.h \
-             fail.c libcfs_cpu.c \
-             libcfs_mem.c linux-crypto.h
+             fail.c libcfs_cpu.c linux-crypto.h
index b5a7c77..21ba3c0 100644 (file)
@@ -1,7 +1,7 @@
 MODULES := lnet
 
 lnet-objs := api-ni.o config.o nidstrings.o lnet_rdma.o lock.o
-lnet-objs += lib-me.o lib-msg.o lib-md.o lib-ptl.o
+lnet-objs += lib-me.o lib-msg.o lib-md.o lib-ptl.o lib-mem.o
 lnet-objs += lib-socket.o lib-move.o module.o lo.o
 lnet-objs += router.o router_proc.o acceptor.o peer.o net_fault.o udsp.o
 
similarity index 73%
rename from libcfs/libcfs/libcfs_mem.c
rename to lnet/lnet/lib-mem.c
index 1edfc53..2e3d5f2 100644 (file)
  * General Public License version 2 for more details (a copy is included
  * in the LICENSE file that accompanied this code).
  *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA
- *
  * GPL HEADER END
  */
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+/* 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/
+/* This file is part of Lustre, http://www.lustre.org/
  *
  * Author: liang@whamcloud.com
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <linux/workqueue.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
 #include <libcfs/libcfs.h>
+#include <libcfs/libcfs_cpu.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
 
 struct cfs_var_array {
        unsigned int            va_count;       /* # of buffers */
@@ -42,14 +39,13 @@ struct cfs_var_array {
        void                    *va_ptrs[0];    /* buffer addresses */
 };
 
-/*
- * free per-cpu data, see more detail in cfs_percpt_free
+/* free per-cpu data, see more detail in cfs_percpt_free
  */
 void
 cfs_percpt_free(void *vars)
 {
-       struct  cfs_var_array *arr;
-       int     i;
+       struct cfs_var_array *arr;
+       int i;
 
        arr = container_of(vars, struct cfs_var_array, va_ptrs[0]);
 
@@ -63,8 +59,7 @@ cfs_percpt_free(void *vars)
 }
 EXPORT_SYMBOL(cfs_percpt_free);
 
-/*
- * allocate per cpu-partition variables, returned value is an array of pointers,
+/* allocate per cpu-partition variables, returned value is an array of pointers,
  * variable can be indexed by CPU partition ID, i.e:
  *
  *     arr = cfs_percpt_alloc(cfs_cpu_pt, size);
@@ -77,23 +72,24 @@ EXPORT_SYMBOL(cfs_percpt_free);
 void *
 cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size)
 {
-       struct cfs_var_array    *arr;
-       int                     count;
-       int                     i;
+       struct cfs_var_array *arr;
+       int count;
+       int i;
 
        count = cfs_cpt_number(cptab);
 
        LIBCFS_ALLOC(arr, offsetof(struct cfs_var_array, va_ptrs[count]));
-       if (arr == NULL)
+       if (!arr)
                return NULL;
 
-       arr->va_size    = size = L1_CACHE_ALIGN(size);
-       arr->va_count   = count;
-       arr->va_cptab   = cptab;
+       size = L1_CACHE_ALIGN(size);
+       arr->va_size = size;
+       arr->va_count = count;
+       arr->va_cptab = cptab;
 
        for (i = 0; i < count; i++) {
                LIBCFS_CPT_ALLOC(arr->va_ptrs[i], cptab, i, size);
-               if (arr->va_ptrs[i] == NULL) {
+               if (!arr->va_ptrs[i]) {
                        cfs_percpt_free((void *)&arr->va_ptrs[0]);
                        return NULL;
                }
@@ -103,8 +99,7 @@ cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size)
 }
 EXPORT_SYMBOL(cfs_percpt_alloc);
 
-/*
- * return number of CPUs (or number of elements in per-cpu data)
+/* return number of CPUs (or number of elements in per-cpu data)
  * according to cptab of @vars
  */
 int