Hi, On 4/28/21 2:39 PM, Qiaowei Ren wrote: > From: Jianpeng Ma <jianpeng.ma@xxxxxxxxx> > > This patch define the prototype data structures in memory and initializes > the nvm pages allocator. > > The nvm address space which is managed by this allocatior can consist of allocator > many nvm namespaces, and some namespaces can compose into one nvm set, > like cache set. For this initial implementation, only one set can be > supported. > > The users of this nvm pages allocator need to call regiseter_namespace() register_namespace() > to register the nvdimm device (like /dev/pmemX) into this allocator as > the instance of struct nvm_namespace. > > v9: > -Fix Kconfig dependance error(Reported-by Randy) dependence > -Fix an uninitialized return value(Colin) > > Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx> > Signed-off-by: Jianpeng Ma <jianpeng.ma@xxxxxxxxx> > Co-developed-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx> > Signed-off-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx> > Signed-off-by: Coly Li <colyli@xxxxxxx> > Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx> > --- > drivers/md/bcache/Kconfig | 8 + > drivers/md/bcache/Makefile | 2 +- > drivers/md/bcache/nvm-pages.c | 285 ++++++++++++++++++++++++++++++++++ > drivers/md/bcache/nvm-pages.h | 74 +++++++++ > drivers/md/bcache/super.c | 3 + > 5 files changed, 371 insertions(+), 1 deletion(-) > create mode 100644 drivers/md/bcache/nvm-pages.c > create mode 100644 drivers/md/bcache/nvm-pages.h > > diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig > index d1ca4d059c20..3057da4cf8ff 100644 > --- a/drivers/md/bcache/Kconfig > +++ b/drivers/md/bcache/Kconfig > @@ -35,3 +35,11 @@ config BCACHE_ASYNC_REGISTRATION > device path into this file will returns immediately and the real > registration work is handled in kernel work queue in asynchronous > way. > + > +config BCACHE_NVM_PAGES > + bool "NVDIMM support for bcache (EXPERIMENTAL)" > + depends on BCACHE > + depends on LIBNVDIMM > + depends on DAX > + help > + nvm pages allocator for bcache. > diff --git a/drivers/md/bcache/Makefile b/drivers/md/bcache/Makefile > index 5b87e59676b8..948e5ed2ca66 100644 > --- a/drivers/md/bcache/Makefile > +++ b/drivers/md/bcache/Makefile > @@ -4,4 +4,4 @@ obj-$(CONFIG_BCACHE) += bcache.o > > bcache-y := alloc.o bset.o btree.o closure.o debug.o extents.o\ > io.o journal.o movinggc.o request.o stats.o super.o sysfs.o trace.o\ > - util.o writeback.o features.o > + util.o writeback.o features.o nvm-pages.o This is not the right way to add an optional piece of code (nvm-pages.o) to the full linked binary. I.e., it is added unconditionally here and then inside its .c file, the entire file is bracketed with (see below): #ifdef CONFIG_BCACHE_NVM_PAGES ... #endif /* CONFIG_BCACHE_NVM_PAGES */ The right way to do this is in Kconfig and Makefile changes alone, and then nvm-pages.c does not need that huge #ifdef/#endif bracketing. Documentation/kbuild/*.rst has some references to this, but it's probably easier just to look at some examples. E.g., see drivers/usb/common/: Kconfig and Makefile and how CONFIG_TRACING adds debug.o to the usb-common-y binary build. Same for USB_LED_TRIG and led.o. > diff --git a/drivers/md/bcache/nvm-pages.c b/drivers/md/bcache/nvm-pages.c > new file mode 100644 > index 000000000000..976ab9002c17 > --- /dev/null > +++ b/drivers/md/bcache/nvm-pages.c > @@ -0,0 +1,285 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Nvdimm page-buddy allocator > + * > + * Copyright (c) 2021, Intel Corporation. > + * Copyright (c) 2021, Qiaowei Ren <qiaowei.ren@xxxxxxxxx>. > + * Copyright (c) 2021, Jianpeng Ma <jianpeng.ma@xxxxxxxxx>. > + */ > + > +#ifdef CONFIG_BCACHE_NVM_PAGES [delete many lines] > + > +#endif /* CONFIG_BCACHE_NVM_PAGES */ The header (.h) file also probably needs some fixing up. thanks. -- ~Randy