linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc
@ 2021-07-26  3:23 Chen Wandun
  2021-07-26  3:25 ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Wandun @ 2021-07-26  3:23 UTC (permalink / raw)
  To: akpm, linux-mm, linux-kernel, wangkefeng.wang, weiyongjun1; +Cc: Chen Wandun

struct page array can also be allocated in highmem during vmalloc,
that will ease the low memory stress in 32bit system.

Fixes: f255935b9767 ("mm: cleanup the gfp_mask handling in __vmalloc_area_node")
Signed-off-by: Chen Wandun <chenwandun@huawei.com>
---
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 3824dc16ce1c..8d9b0b08a6dc 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2885,7 +2885,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 
 	/* Please note that the recursion is strictly bounded. */
 	if (array_size > PAGE_SIZE) {
-		area->pages = __vmalloc_node(array_size, 1, nested_gfp, node,
+		area->pages = __vmalloc_node(array_size, 1,
+					nested_gfp | __GFP_HIGHMEM, node,
 					area->caller);
 	} else {
 		area->pages = kmalloc_node(array_size, nested_gfp, node);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc
  2021-07-26  3:23 [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc Chen Wandun
@ 2021-07-26  3:25 ` Matthew Wilcox
  2021-07-26  4:05   ` Chen Wandun
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2021-07-26  3:25 UTC (permalink / raw)
  To: Chen Wandun; +Cc: akpm, linux-mm, linux-kernel, wangkefeng.wang, weiyongjun1

On Mon, Jul 26, 2021 at 11:23:33AM +0800, Chen Wandun wrote:
> struct page array can also be allocated in highmem during vmalloc,
> that will ease the low memory stress in 32bit system.

Huh?  Where does it get kmapped in order to access it?

> Fixes: f255935b9767 ("mm: cleanup the gfp_mask handling in __vmalloc_area_node")
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
> ---
>  mm/vmalloc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 3824dc16ce1c..8d9b0b08a6dc 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2885,7 +2885,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
>  
>  	/* Please note that the recursion is strictly bounded. */
>  	if (array_size > PAGE_SIZE) {
> -		area->pages = __vmalloc_node(array_size, 1, nested_gfp, node,
> +		area->pages = __vmalloc_node(array_size, 1,
> +					nested_gfp | __GFP_HIGHMEM, node,
>  					area->caller);
>  	} else {
>  		area->pages = kmalloc_node(array_size, nested_gfp, node);
> -- 
> 2.25.1
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc
  2021-07-26  3:25 ` Matthew Wilcox
@ 2021-07-26  4:05   ` Chen Wandun
  2021-07-27 17:30     ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Wandun @ 2021-07-26  4:05 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: akpm, linux-mm, linux-kernel, wangkefeng.wang, weiyongjun1


在 2021/7/26 11:25, Matthew Wilcox 写道:
> On Mon, Jul 26, 2021 at 11:23:33AM +0800, Chen Wandun wrote:
>> struct page array can also be allocated in highmem during vmalloc,
>> that will ease the low memory stress in 32bit system.
> Huh?  Where does it get kmapped in order to access it?

The struct page array contain numbers of pointer of struct page, it is used to save

pages that allocated for vmalloc mapping in vmap_pages_range, it does't need to kmap.


The main idea of this patch is come from:

https://lore.kernel.org/lkml/20170307141020.29107-1-mhocko@kernel.org/

>
>> Fixes: f255935b9767 ("mm: cleanup the gfp_mask handling in __vmalloc_area_node")
>> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
>> ---
>>   mm/vmalloc.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
>> index 3824dc16ce1c..8d9b0b08a6dc 100644
>> --- a/mm/vmalloc.c
>> +++ b/mm/vmalloc.c
>> @@ -2885,7 +2885,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
>>   
>>   	/* Please note that the recursion is strictly bounded. */
>>   	if (array_size > PAGE_SIZE) {
>> -		area->pages = __vmalloc_node(array_size, 1, nested_gfp, node,
>> +		area->pages = __vmalloc_node(array_size, 1,
>> +					nested_gfp | __GFP_HIGHMEM, node,
>>   					area->caller);
>>   	} else {
>>   		area->pages = kmalloc_node(array_size, nested_gfp, node);
>> -- 
>> 2.25.1
>>
>>
> .


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc
  2021-07-26  4:05   ` Chen Wandun
@ 2021-07-27 17:30     ` Matthew Wilcox
  2021-07-28  1:13       ` Chen Wandun
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2021-07-27 17:30 UTC (permalink / raw)
  To: Chen Wandun; +Cc: akpm, linux-mm, linux-kernel, wangkefeng.wang, weiyongjun1

On Mon, Jul 26, 2021 at 12:05:44PM +0800, Chen Wandun wrote:
> 在 2021/7/26 11:25, Matthew Wilcox 写道:
> > On Mon, Jul 26, 2021 at 11:23:33AM +0800, Chen Wandun wrote:
> > > struct page array can also be allocated in highmem during vmalloc,
> > > that will ease the low memory stress in 32bit system.
> > Huh?  Where does it get kmapped in order to access it?

(i misread your patch, apologies)

> The struct page array contain numbers of pointer of struct page, it is used to save
> 
> pages that allocated for vmalloc mapping in vmap_pages_range, it does't need to kmap.
> 
> 
> The main idea of this patch is come from:
> 
> https://lore.kernel.org/lkml/20170307141020.29107-1-mhocko@kernel.org/

you've misunderstood that patch.  think about it:

static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                                 pgprot_t prot, unsigned int page_shift,
                                 int node)
{
	const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
(now nested_gfp has neither DMA nor DMA32 set)

        gfp_mask |= __GFP_NOWARN;
        if (!(gfp_mask & (GFP_DMA | GFP_DMA32)))
                gfp_mask |= __GFP_HIGHMEM;
(we set HIGHMEM if DMA and DMA32 are both not set)

                area->pages = __vmalloc_node(array_size, 1, nested_gfp, node,
                                        area->caller);
(we don't need to set HIGHMEM here because it will be set for us in
the second call to __vmalloc_area_node)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc
  2021-07-27 17:30     ` Matthew Wilcox
@ 2021-07-28  1:13       ` Chen Wandun
  0 siblings, 0 replies; 5+ messages in thread
From: Chen Wandun @ 2021-07-28  1:13 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: akpm, linux-mm, linux-kernel, wangkefeng.wang, weiyongjun1


在 2021/7/28 1:30, Matthew Wilcox 写道:
> On Mon, Jul 26, 2021 at 12:05:44PM +0800, Chen Wandun wrote:
>> 在 2021/7/26 11:25, Matthew Wilcox 写道:
>>> On Mon, Jul 26, 2021 at 11:23:33AM +0800, Chen Wandun wrote:
>>>> struct page array can also be allocated in highmem during vmalloc,
>>>> that will ease the low memory stress in 32bit system.
>>> Huh?  Where does it get kmapped in order to access it?
> (i misread your patch, apologies)
>
>> The struct page array contain numbers of pointer of struct page, it is used to save
>>
>> pages that allocated for vmalloc mapping in vmap_pages_range, it does't need to kmap.
>>
>>
>> The main idea of this patch is come from:
>>
>> https://lore.kernel.org/lkml/20170307141020.29107-1-mhocko@kernel.org/
> you've misunderstood that patch.  think about it:
>
> static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
>                                   pgprot_t prot, unsigned int page_shift,
>                                   int node)
> {
> 	const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
> (now nested_gfp has neither DMA nor DMA32 set)
>
>          gfp_mask |= __GFP_NOWARN;
>          if (!(gfp_mask & (GFP_DMA | GFP_DMA32)))
>                  gfp_mask |= __GFP_HIGHMEM;
> (we set HIGHMEM if DMA and DMA32 are both not set)
>
>                  area->pages = __vmalloc_node(array_size, 1, nested_gfp, node,
>                                          area->caller);
> (we don't need to set HIGHMEM here because it will be set for us in
> the second call to __vmalloc_area_node)

Oh yes,I misunderstood about this.

Thanks

Wandun

> .


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-28  1:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26  3:23 [PATCH] mm/vmalloc: add missing __GFP_HIGHMEM flag for vmalloc Chen Wandun
2021-07-26  3:25 ` Matthew Wilcox
2021-07-26  4:05   ` Chen Wandun
2021-07-27 17:30     ` Matthew Wilcox
2021-07-28  1:13       ` Chen Wandun

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).