* [PATCH] drivers: base: dma-mapping: use nth_page helper
@ 2017-03-24 14:10 Geliang Tang
2017-03-24 14:10 ` [PATCH] mm/page_alloc: " Geliang Tang
0 siblings, 1 reply; 3+ messages in thread
From: Geliang Tang @ 2017-03-24 14:10 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Geliang Tang, linux-kernel
Use nth_page() helper instead of page_to_pfn() and pfn_to_page() to
simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
drivers/base/dma-mapping.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index efd71cf..51b7061 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -309,14 +309,13 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
int i;
struct page **pages;
void *ptr;
- unsigned long pfn;
pages = kmalloc(sizeof(struct page *) << get_order(size), GFP_KERNEL);
if (!pages)
return NULL;
- for (i = 0, pfn = page_to_pfn(page); i < (size >> PAGE_SHIFT); i++)
- pages[i] = pfn_to_page(pfn + i);
+ for (i = 0; i < (size >> PAGE_SHIFT); i++)
+ pages[i] = nth_page(page, i);
ptr = dma_common_pages_remap(pages, size, vm_flags, prot, caller);
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] mm/page_alloc: use nth_page helper
2017-03-24 14:10 [PATCH] drivers: base: dma-mapping: use nth_page helper Geliang Tang
@ 2017-03-24 14:10 ` Geliang Tang
2017-03-24 17:43 ` Vlastimil Babka
0 siblings, 1 reply; 3+ messages in thread
From: Geliang Tang @ 2017-03-24 14:10 UTC (permalink / raw)
To: Andrew Morton, Vlastimil Babka, Mel Gorman, Michal Hocko,
Johannes Weiner, Joonsoo Kim
Cc: Geliang Tang, linux-mm, linux-kernel
Use nth_page() helper instead of page_to_pfn() and pfn_to_page() to
simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
mm/page_alloc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f749b7f..3354f56 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2511,9 +2511,8 @@ void mark_free_pages(struct zone *zone)
&zone->free_area[order].free_list[t], lru) {
unsigned long i;
- pfn = page_to_pfn(page);
for (i = 0; i < (1UL << order); i++)
- swsusp_set_page_free(pfn_to_page(pfn + i));
+ swsusp_set_page_free(nth_page(page, i));
}
}
spin_unlock_irqrestore(&zone->lock, flags);
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/page_alloc: use nth_page helper
2017-03-24 14:10 ` [PATCH] mm/page_alloc: " Geliang Tang
@ 2017-03-24 17:43 ` Vlastimil Babka
0 siblings, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2017-03-24 17:43 UTC (permalink / raw)
To: Geliang Tang, Andrew Morton, Mel Gorman, Michal Hocko,
Johannes Weiner, Joonsoo Kim
Cc: linux-mm, linux-kernel
On 24.3.2017 15:10, Geliang Tang wrote:
> Use nth_page() helper instead of page_to_pfn() and pfn_to_page() to
> simplify the code.
Well I've never heard of this helper so I would have to look it up to see what
it does. Looks like there's not many users.
Anyway it's simpler to use just "page + i" if within MAX_ORDER_NR_PAGES, which
should be the case here. That can also actually save a few cycles. Otherwise it
looks like a pointless churn to me.
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
> mm/page_alloc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index f749b7f..3354f56 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2511,9 +2511,8 @@ void mark_free_pages(struct zone *zone)
> &zone->free_area[order].free_list[t], lru) {
> unsigned long i;
>
> - pfn = page_to_pfn(page);
> for (i = 0; i < (1UL << order); i++)
> - swsusp_set_page_free(pfn_to_page(pfn + i));
> + swsusp_set_page_free(nth_page(page, i));
> }
> }
> spin_unlock_irqrestore(&zone->lock, flags);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-24 17:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 14:10 [PATCH] drivers: base: dma-mapping: use nth_page helper Geliang Tang
2017-03-24 14:10 ` [PATCH] mm/page_alloc: " Geliang Tang
2017-03-24 17:43 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).