From 24d515367f44de6b92b453cc9a1c8384e52b5e3f Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sat, 14 Oct 2023 20:25:55 -0400 Subject: [PATCH] LU-9859 libcfs: migrate libcfs_mem.c to lnet/lib-mem.c 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 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52701 Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- libcfs/libcfs/Makefile.in | 1 - libcfs/libcfs/autoMakefile.am | 3 +- lnet/lnet/Makefile.in | 2 +- libcfs/libcfs/libcfs_mem.c => lnet/lnet/lib-mem.c | 47 ++++++++++------------- 4 files changed, 23 insertions(+), 30 deletions(-) rename libcfs/libcfs/libcfs_mem.c => lnet/lnet/lib-mem.c (73%) diff --git a/libcfs/libcfs/Makefile.in b/libcfs/libcfs/Makefile.in index 2205ad7..3dd6942 100644 --- a/libcfs/libcfs/Makefile.in +++ b/libcfs/libcfs/Makefile.in @@ -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) diff --git a/libcfs/libcfs/autoMakefile.am b/libcfs/libcfs/autoMakefile.am index 70698e6..8c312a0 100644 --- a/libcfs/libcfs/autoMakefile.am +++ b/libcfs/libcfs/autoMakefile.am @@ -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 diff --git a/lnet/lnet/Makefile.in b/lnet/lnet/Makefile.in index b5a7c77..21ba3c0 100644 --- a/lnet/lnet/Makefile.in +++ b/lnet/lnet/Makefile.in @@ -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 diff --git a/libcfs/libcfs/libcfs_mem.c b/lnet/lnet/lib-mem.c similarity index 73% rename from libcfs/libcfs/libcfs_mem.c rename to lnet/lnet/lib-mem.c index 1edfc53..2e3d5f2 100644 --- a/libcfs/libcfs/libcfs_mem.c +++ b/lnet/lnet/lib-mem.c @@ -13,27 +13,24 @@ * 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 +#include +#include #include +#include +#include +#include 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 -- 1.8.3.1