diff options
| author | Tony Luck <tony.luck@intel.com> | 2021-07-25 14:00:18 -0700 |
|---|---|---|
| committer | Xiaochen Shen <xiaochen.shen@intel.com> | 2021-10-23 00:26:24 +0800 |
| commit | ec41aa6ef6cba25e349a04e3b4cc1e37217d54f6 (patch) | |
| tree | cade50a6aa80c65a29bfc971bc8d2307292dbf08 | |
| parent | 1cbda083dce71e5bcaeae60233ae5ed7eaa519b5 (diff) | |
| download | linux-ec41aa6ef6cba25e349a04e3b4cc1e37217d54f6.tar.gz | |
mm/pagezero: Add stub driver to test registration API
Add the init/exit stubs to register a page clearing driver that
actually does nothing when called to allocate/clear memory.
Signed-off-by: Tony Luck <tony.luck@intel.com>
| -rw-r--r-- | drivers/dma/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/dma/idxd/Makefile | 2 | ||||
| -rw-r--r-- | drivers/dma/idxd/dsa_page_clear_engine.c | 78 |
3 files changed, 90 insertions, 0 deletions
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 3be8f744ce2fc..d5b44d82eaca9 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -345,6 +345,16 @@ config INTEL_IDXD_KTEST If unsure, say N +config INTEL_IDXD_PAGE_CLEAR + tristate "Intel DSA page clearing engine" + depends on INTEL_IDXD_SVM + help + Driver to use DSA to allocate and clear kernel memory + to build a pool of pre-zeroed 4KB pages on each node + to speed up __GFP_ZERO allocations. User must manually + configure a DSA work queue on each NUMA node before + loading this driver. + config INTEL_IOATDMA tristate "Intel I/OAT DMA support" depends on PCI && X86_64 && !UML diff --git a/drivers/dma/idxd/Makefile b/drivers/dma/idxd/Makefile index e761de91328a5..7ef558af17229 100644 --- a/drivers/dma/idxd/Makefile +++ b/drivers/dma/idxd/Makefile @@ -13,3 +13,5 @@ idxd_compat-y := compat.o obj-$(CONFIG_INTEL_IDXD_KTEST) += idxd_ktest.o idxd_ktest-y := ktest.o + +obj-$(CONFIG_INTEL_IDXD_PAGE_CLEAR) += dsa_page_clear_engine.o diff --git a/drivers/dma/idxd/dsa_page_clear_engine.c b/drivers/dma/idxd/dsa_page_clear_engine.c new file mode 100644 index 0000000000000..be6ed86ad4ee2 --- /dev/null +++ b/drivers/dma/idxd/dsa_page_clear_engine.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) 2021 Intel Corporation */ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/highmem.h> +#include <linux/mm.h> +#include <linux/slab.h> + +struct perzone { + void *portal; + struct list_head pages; +}; + +static void *alloc_engine_descriptor(int node) +{ + struct perzone *pz; + + pz = kzalloc_node(sizeof(*pz), GFP_KERNEL, node); + if (!pz) + return NULL; + + INIT_LIST_HEAD(&pz->pages); + + return pz; +} + +/* Called with zone->lock held */ +int get_clear_pages(void *v, int migratetype, int want, struct list_head *l, int *countp) +{ + return 0; +} + +/* Called with zone->lock held */ +void add_new_page(void *v, struct page *page) +{ +} + +static int engine_cleanup(int node, void **v) +{ + struct perzone *pz; + + if (!*v) + return 0; + pz = *v; + + kfree(pz); + *v = NULL; + + return 0; +} + +static const struct page_clear_engine_ops dsa_page_engine_ops = { + .create = alloc_engine_descriptor, + .getpages = get_clear_pages, + .provide = add_new_page, + .clean = engine_cleanup, +}; + +static int __init init_page_clear_engine(void) +{ + int ret; + + ret = register_page_clear_engine(&dsa_page_engine_ops); + + return ret; +} +module_init(init_page_clear_engine); + +static void __exit exit_page_clear_driver(void) +{ + unregister_page_clear_engine(&dsa_page_engine_ops); +} +module_exit(exit_page_clear_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Jing Lin + Tony Luck"); +MODULE_DESCRIPTION("DSA page clear engine to zero pages"); |
