From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Matthew Wilcox <willy@infradead.org>, linux-mm@kvack.org, hch@lst.de Subject: [PATCH v2 05/14] mm, memremap: Up-level foreach_order_pgoff() Date: Mon, 16 Jul 2018 10:00:48 -0700 [thread overview] Message-ID: <153176044796.12695.10692625606054072713.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> The foreach_order_pgoff() helper takes advantage of the ability to insert multi-order entries into a radix. It is currently used by devm_memremap_pages() to minimize the number of entries in the pgmap radix. Instead of dividing a range by a constant power-of-2 sized unit and inserting an entry for each unit, it determines the maximum power-of-2 sized entry (subject to alignment offset) that can be inserted at each iteration. Up-level this helper so it can be used for populating other radix instances. For example asynchronous-memmap-initialization-thread lookups arriving in a follow on change. Cc: Logan Gunthorpe <logang@deltatee.com> Cc: Matthew Wilcox <willy@infradead.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- include/linux/memremap.h | 25 +++++++++++++++++++++++++ kernel/memremap.c | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index bfdc7363b13b..bff314de3f55 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -126,6 +126,31 @@ struct dev_pagemap { enum memory_type type; }; +static inline unsigned long order_at(struct resource *res, unsigned long pgoff) +{ + unsigned long phys_pgoff = PHYS_PFN(res->start) + pgoff; + unsigned long nr_pages, mask; + + nr_pages = PHYS_PFN(resource_size(res)); + if (nr_pages == pgoff) + return ULONG_MAX; + + /* + * What is the largest aligned power-of-2 range available from + * this resource pgoff to the end of the resource range, + * considering the alignment of the current pgoff? + */ + mask = phys_pgoff | rounddown_pow_of_two(nr_pages - pgoff); + if (!mask) + return ULONG_MAX; + + return find_first_bit(&mask, BITS_PER_LONG); +} + +#define foreach_order_pgoff(res, order, pgoff) \ + for (pgoff = 0, order = order_at((res), pgoff); order < ULONG_MAX; \ + pgoff += 1UL << order, order = order_at((res), pgoff)) + #ifdef CONFIG_ZONE_DEVICE void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap, void (*kill)(struct percpu_ref *)); diff --git a/kernel/memremap.c b/kernel/memremap.c index 85e4a7c576b2..fc2f28033460 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -16,31 +16,6 @@ static RADIX_TREE(pgmap_radix, GFP_KERNEL); #define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1) #define SECTION_SIZE (1UL << PA_SECTION_SHIFT) -static unsigned long order_at(struct resource *res, unsigned long pgoff) -{ - unsigned long phys_pgoff = PHYS_PFN(res->start) + pgoff; - unsigned long nr_pages, mask; - - nr_pages = PHYS_PFN(resource_size(res)); - if (nr_pages == pgoff) - return ULONG_MAX; - - /* - * What is the largest aligned power-of-2 range available from - * this resource pgoff to the end of the resource range, - * considering the alignment of the current pgoff? - */ - mask = phys_pgoff | rounddown_pow_of_two(nr_pages - pgoff); - if (!mask) - return ULONG_MAX; - - return find_first_bit(&mask, BITS_PER_LONG); -} - -#define foreach_order_pgoff(res, order, pgoff) \ - for (pgoff = 0, order = order_at((res), pgoff); order < ULONG_MAX; \ - pgoff += 1UL << order, order = order_at((res), pgoff)) - #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) int device_private_entry_fault(struct vm_area_struct *vma, unsigned long addr, _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: Logan Gunthorpe <logang@deltatee.com>, Matthew Wilcox <willy@infradead.org>, vishal.l.verma@intel.com, hch@lst.de, linux-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/14] mm, memremap: Up-level foreach_order_pgoff() Date: Mon, 16 Jul 2018 10:00:48 -0700 [thread overview] Message-ID: <153176044796.12695.10692625606054072713.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> The foreach_order_pgoff() helper takes advantage of the ability to insert multi-order entries into a radix. It is currently used by devm_memremap_pages() to minimize the number of entries in the pgmap radix. Instead of dividing a range by a constant power-of-2 sized unit and inserting an entry for each unit, it determines the maximum power-of-2 sized entry (subject to alignment offset) that can be inserted at each iteration. Up-level this helper so it can be used for populating other radix instances. For example asynchronous-memmap-initialization-thread lookups arriving in a follow on change. Cc: Logan Gunthorpe <logang@deltatee.com> Cc: Matthew Wilcox <willy@infradead.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- include/linux/memremap.h | 25 +++++++++++++++++++++++++ kernel/memremap.c | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index bfdc7363b13b..bff314de3f55 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -126,6 +126,31 @@ struct dev_pagemap { enum memory_type type; }; +static inline unsigned long order_at(struct resource *res, unsigned long pgoff) +{ + unsigned long phys_pgoff = PHYS_PFN(res->start) + pgoff; + unsigned long nr_pages, mask; + + nr_pages = PHYS_PFN(resource_size(res)); + if (nr_pages == pgoff) + return ULONG_MAX; + + /* + * What is the largest aligned power-of-2 range available from + * this resource pgoff to the end of the resource range, + * considering the alignment of the current pgoff? + */ + mask = phys_pgoff | rounddown_pow_of_two(nr_pages - pgoff); + if (!mask) + return ULONG_MAX; + + return find_first_bit(&mask, BITS_PER_LONG); +} + +#define foreach_order_pgoff(res, order, pgoff) \ + for (pgoff = 0, order = order_at((res), pgoff); order < ULONG_MAX; \ + pgoff += 1UL << order, order = order_at((res), pgoff)) + #ifdef CONFIG_ZONE_DEVICE void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap, void (*kill)(struct percpu_ref *)); diff --git a/kernel/memremap.c b/kernel/memremap.c index 85e4a7c576b2..fc2f28033460 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -16,31 +16,6 @@ static RADIX_TREE(pgmap_radix, GFP_KERNEL); #define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1) #define SECTION_SIZE (1UL << PA_SECTION_SHIFT) -static unsigned long order_at(struct resource *res, unsigned long pgoff) -{ - unsigned long phys_pgoff = PHYS_PFN(res->start) + pgoff; - unsigned long nr_pages, mask; - - nr_pages = PHYS_PFN(resource_size(res)); - if (nr_pages == pgoff) - return ULONG_MAX; - - /* - * What is the largest aligned power-of-2 range available from - * this resource pgoff to the end of the resource range, - * considering the alignment of the current pgoff? - */ - mask = phys_pgoff | rounddown_pow_of_two(nr_pages - pgoff); - if (!mask) - return ULONG_MAX; - - return find_first_bit(&mask, BITS_PER_LONG); -} - -#define foreach_order_pgoff(res, order, pgoff) \ - for (pgoff = 0, order = order_at((res), pgoff); order < ULONG_MAX; \ - pgoff += 1UL << order, order = order_at((res), pgoff)) - #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) int device_private_entry_fault(struct vm_area_struct *vma, unsigned long addr,
next prev parent reply other threads:[~2018-07-16 17:10 UTC|newest] Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-16 17:00 [PATCH v2 00/14] mm: Asynchronous + multithreaded memmap init for ZONE_DEVICE Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` [PATCH v2 01/14] mm: Plumb dev_pagemap instead of vmem_altmap to memmap_init_zone() Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` [PATCH v2 02/14] mm: Enable asynchronous __add_pages() and vmemmap_populate_hugepages() Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` [PATCH v2 03/14] mm: Teach memmap_init_zone() to initialize ZONE_DEVICE pages Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` [PATCH v2 04/14] mm: Multithread ZONE_DEVICE initialization Dan Williams 2018-07-16 17:00 ` Dan Williams [this message] 2018-07-16 17:00 ` [PATCH v2 05/14] mm, memremap: Up-level foreach_order_pgoff() Dan Williams 2018-07-16 21:00 ` Matthew Wilcox 2018-07-16 21:00 ` Matthew Wilcox 2018-07-16 17:00 ` [PATCH v2 06/14] mm: Allow an external agent to coordinate memmap initialization Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` [PATCH v2 07/14] libnvdimm, pmem: Allow a NULL-pfn to ->direct_access() Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:00 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 08/14] tools/testing/nvdimm: " Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 09/14] s390, dcssblk: " Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 10/14] filesystem-dax: Do not request a pfn when not required Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 11/14] filesystem-dax: Make mount time pfn validation a debug check Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 12/14] libnvdimm, pmem: Initialize the memmap in the background Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 13/14] device-dax: " Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 17:01 ` [PATCH v2 14/14] libnvdimm, namespace: Publish page structure init state / control Dan Williams 2018-07-16 17:01 ` Dan Williams 2018-07-16 19:12 ` [PATCH v2 00/14] mm: Asynchronous + multithreaded memmap init for ZONE_DEVICE Pavel Tatashin 2018-07-16 20:30 ` Dan Williams 2018-07-16 20:30 ` Dan Williams 2018-07-17 14:46 ` Pavel Tatashin 2018-07-17 14:46 ` Pavel Tatashin 2018-07-17 15:50 ` Michal Hocko 2018-07-17 15:50 ` Michal Hocko 2018-07-17 17:32 ` Dan Williams 2018-07-17 17:32 ` Dan Williams 2018-07-17 17:32 ` Dan Williams 2018-07-18 12:05 ` Michal Hocko 2018-07-18 12:05 ` Michal Hocko 2018-07-19 18:41 ` Dave Hansen 2018-07-19 18:41 ` Dave Hansen 2018-07-23 11:09 ` Michal Hocko 2018-07-23 16:15 ` Dave Hansen 2018-07-23 16:15 ` Dave Hansen 2018-07-24 7:29 ` Michal Hocko 2018-09-10 19:06 ` Dan Williams 2018-09-10 19:06 ` Dan Williams 2018-09-10 19:47 ` Alexander Duyck
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=153176044796.12695.10692625606054072713.stgit@dwillia2-desk3.amr.corp.intel.com \ --to=dan.j.williams@intel.com \ --cc=akpm@linux-foundation.org \ --cc=hch@lst.de \ --cc=jack@suse.cz \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-nvdimm@lists.01.org \ --cc=willy@infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.