mm/page_alloc: fix comment is __get_free_pages
Subsystems (2)
PATCH RESEND 1/1 mm/page_alloc: fix comment is __get_free_pages
From: Jiankang Chen <[email protected]>
__get_free_pages will return an virtual address,
but it is not just 32-bit address, for example a 64-bit system. And this comment really confuse new bigenner of mm.
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
@@ -4240,7 +4240,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)struct page *page;/* -* __get_free_pages() returns a 32-bit address, which cannot represent +* __get_free_pages() returns a virtual address, which cannot represent * a highmem page */ VM_BUG_ON ((gfp_mask & __GFP_HIGHMEM) !=0 );
Signature · 7 lines
1.7.12.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · JianKang Chen
From: Jiankang Chen <[email protected]>
__get_free_pageswill return an virtual address,
but it is not just 32-bit address, for example a 64-bit system. And this comment really confuse new bigenner of mm.
s@bigenner@beginner@
Anyway, do we really need a bug on for this? Has this actually caught any wrong usage? VM_BUG_ON tends to be enabled these days AFAIK and panicking the kernel seems like an over-reaction. If there is a real risk then why don't we simply mask __GFP_HIGHMEM off when calling alloc_pages?
Quoted 22 lines
reported-by Hanjun Guo <[email protected]>Signed-off-by Jiankang Chen <[email protected]>--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/page_alloc.c +1
-1@@ -4240,7 +4240,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)struct page *page;/* -* __get_free_pages() returns a 32-bit address, which cannot represent +* __get_free_pages() returns a virtual address, which cannot represent * a highmem page */ VM_BUG_ON ((gfp_mask & __GFP_HIGHMEM) !=0 );Signature · 1 line
1.7.12.4
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Michal Hocko
Quoted 5 lines · JianKang Chen
From: Jiankang Chen <[email protected]>
__get_free_pageswill return an virtual address,
but it is not just 32-bit address, for example a 64-bit system. And this comment really confuse new bigenner of mm.
Quoted 7 lines
s@bigenner@beginner@
Anyway, do we really need a bug on for this? Has this actually caught any wrong usage?
VM_BUG_ONtends to be enabled these days AFAIK and panicking the kernel seems like an over-reaction. If there is a real risk then why don't we simply mask__GFP_HIGHMEMoff when callingalloc_pages?
I meant this
---
Andrew Morton
maintainerQuoted 19 lines · On Wed, 29 Nov 2017 17:04:46 +0100 Michal Hocko <[email protected]> wrote:
Quoted 7 lines · Michal Hocko
Quoted 5 lines · JianKang Chen
From: Jiankang Chen <[email protected]>
__get_free_pageswill return an virtual address,
but it is not just 32-bit address, for example a 64-bit system. And this comment really confuse new bigenner of mm.Quoted 7 lines
s@bigenner@beginner@
Anyway, do we really need a bug on for this? Has this actually caught any wrong usage?
VM_BUG_ONtends to be enabled these days AFAIK and panicking the kernel seems like an over-reaction. If there is a real risk then why don't we simply mask__GFP_HIGHMEMoff when callingalloc_pages?I meant this
---Quoted 1 line
From
000bb422fe07adbfa8cd8ed953b18f48647a45d6Mon Sep 17 00:00:00 2001
Quoted 8 lines
From: Michal Hocko <[email protected]>
Date: Wed, 29 Nov 2017 17:02:33 +0100
Subject: [PATCH] mm: dropVM_BUG_ONfrom__get_free_pagesThere is no real reason to blow up just because the caller doesn't know that
__get_free_pagescannot return highmem pages. Simply fix that up silently. Even if we have some confused users such a fixup will not be harmful.
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
I do think we should help ferret out such bogosity. A WARN_ON_ONCE would suffice.
Quoted 30 lines · Andrew Morton
Quoted 19 lines · On Wed, 29 Nov 2017 17:04:46 +0100 Michal Hocko <[email protected]> wrote:
Quoted 7 lines · Michal Hocko
Quoted 5 lines · JianKang Chen
From: Jiankang Chen <[email protected]>
__get_free_pageswill return an virtual address,
but it is not just 32-bit address, for example a 64-bit system. And this comment really confuse new bigenner of mm.Quoted 7 lines
s@bigenner@beginner@
Anyway, do we really need a bug on for this? Has this actually caught any wrong usage?
VM_BUG_ONtends to be enabled these days AFAIK and panicking the kernel seems like an over-reaction. If there is a real risk then why don't we simply mask__GFP_HIGHMEMoff when callingalloc_pages?I meant this
---Quoted 1 line
From
000bb422fe07adbfa8cd8ed953b18f48647a45d6Mon Sep 17 00:00:00 2001Quoted 8 lines
From: Michal Hocko <[email protected]>
Date: Wed, 29 Nov 2017 17:02:33 +0100
Subject: [PATCH] mm: dropVM_BUG_ONfrom__get_free_pagesThere is no real reason to blow up just because the caller doesn't know that
__get_free_pagescannot return highmem pages. Simply fix that up silently. Even if we have some confused users such a fixup will not be harmful.
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.
This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as VM_BUG_ON tends to be enabled on many setups.
Signature · 2 lines
Michal Hocko SUSE Labs
Andrew Morton
maintainerQuoted 6 lines · On Thu, 30 Nov 2017 07:53:35 +0100 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
doh.
Quoted 7 lines
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as
VM_BUG_ONtends to be enabled on many setups.
OK. But silently accepting __GFP_HIGHMEM is a bit weird - callers shouldn't be doing that in the first place.
I wonder what happens if we just remove the WARN_ON and pass any __GFP_HIGHMEM straight through. The caller gets a weird address from page_to_virt(highmem page) and usually goes splat? Good enough treatment for something which never happens anyway?
Quoted 14 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Nov 2017 07:53:35 +0100 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
doh.
Quoted 3 lines
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.
Quoted 7 lines
Quoted 4 lines
This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as
VM_BUG_ONtends to be enabled on many setups.OK. But silently accepting
__GFP_HIGHMEMis a bit weird - callers shouldn't be doing that in the first place.
Yes, they shouldn't be.
Quoted 4 lines
I wonder what happens if we just remove the
WARN_ONand pass any__GFP_HIGHMEMstraight through. The caller gets a weird address frompage_to_virt(highmem page)and usually goes splat? Good enough treatment for something which never happens anyway?
page_address will return NULL so they will blow up and leak the freshly allocated memory. I do not think this is really desirable. We _could_ handle this case but I am not really sure this is a win. A silent fixup sounds like the most simply protection.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 25 lines · Michal Hocko
Quoted 14 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Nov 2017 07:53:35 +0100 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
doh.
Quoted 3 lines
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.Quoted 7 lines
Quoted 4 lines
This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as
VM_BUG_ONtends to be enabled on many setups.OK. But silently accepting
__GFP_HIGHMEMis a bit weird - callers shouldn't be doing that in the first place.Yes, they shouldn't be.
Quoted 7 lines
Quoted 4 lines
I wonder what happens if we just remove the
WARN_ONand pass any__GFP_HIGHMEMstraight through. The caller gets a weird address frompage_to_virt(highmem page)and usually goes splat? Good enough treatment for something which never happens anyway?
page_addresswill return NULL so they will blow up and leak the freshly allocated memory.
let me be more specific. They will blow up and leak if the returned address is not checked. If it is then we just leak. None of that sounds good to me.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 31 lines · Michal Hocko
Quoted 30 lines · Michal Hocko
Quoted 14 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Nov 2017 07:53:35 +0100 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
doh.
Quoted 3 lines
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.Quoted 7 lines
Quoted 4 lines
This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as
VM_BUG_ONtends to be enabled on many setups.OK. But silently accepting
__GFP_HIGHMEMis a bit weird - callers shouldn't be doing that in the first place.Yes, they shouldn't be.
Quoted 4 lines
I wonder what happens if we just remove the
WARN_ONand pass any__GFP_HIGHMEMstraight through. The caller gets a weird address frompage_to_virt(highmem page)and usually goes splat? Good enough treatment for something which never happens anyway?
Quoted 6 lines
Quoted 2 lines
page_addresswill return NULL so they will blow up and leak the freshly allocated memory.let me be more specific. They will blow up and leak if the returned address is not checked. If it is then we just leak. None of that sounds good to me.
So do we care and I will resend the patch in that case or I just drop this from my patch queue?
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 35 lines · On Thu, 14 Dec 2017 15:06:08 +0100 Michal Hocko <[email protected]> wrote:
Quoted 34 lines · Michal Hocko
Quoted 32 lines · Michal Hocko
Quoted 14 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Nov 2017 07:53:35 +0100 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
doh.
Quoted 3 lines
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.Quoted 7 lines
Quoted 4 lines
This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as
VM_BUG_ONtends to be enabled on many setups.OK. But silently accepting
__GFP_HIGHMEMis a bit weird - callers shouldn't be doing that in the first place.Yes, they shouldn't be.
Quoted 4 lines
I wonder what happens if we just remove the
WARN_ONand pass any__GFP_HIGHMEMstraight through. The caller gets a weird address frompage_to_virt(highmem page)and usually goes splat? Good enough treatment for something which never happens anyway?
page_addresswill return NULL so they will blow up and leak the freshly allocated memory.
Quoted 6 lines
Quoted 3 lines
let me be more specific. They will blow up and leak if the returned address is not checked. If it is then we just leak. None of that sounds good to me.
So do we care and I will resend the patch in that case or I just drop this from my patch queue?
Well.. I still think that silently accepting bad input would be bad practice. If we can just delete the assertion and have such a caller reliably blow up later on then that's good enough. Otherwise let's leave the code as-is?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 41 lines · Andrew Morton
Quoted 39 lines · On Thu, 14 Dec 2017 15:06:08 +0100 Michal Hocko <[email protected]> wrote:
Quoted 37 lines · Michal Hocko
Quoted 25 lines · Michal Hocko
Quoted 14 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Nov 2017 07:53:35 +0100 Michal Hocko <[email protected]> wrote:
Quoted 4 lines
mm... So we have a caller which hopes to be getting highmem pages but isn't. Caller then proceeds to pointlessly kmap the page and wonders why it isn't getting as much memory as it would like on 32-bit systems, etc.
How he can kmap the page when he gets a _virtual_ address?
doh.
Quoted 3 lines
Quoted 2 lines
I do think we should help ferret out such bogosity. A
WARN_ON_ONCEwould suffice.Quoted 7 lines
Quoted 4 lines
This function has always been about lowmem pages. I seriously doubt we have anybody confused and asking for a highmem page in the kernel. I haven't checked that but it would already blow up as
VM_BUG_ONtends to be enabled on many setups.OK. But silently accepting
__GFP_HIGHMEMis a bit weird - callers shouldn't be doing that in the first place.Yes, they shouldn't be.
Quoted 7 lines
Quoted 4 lines
I wonder what happens if we just remove the
WARN_ONand pass any__GFP_HIGHMEMstraight through. The caller gets a weird address frompage_to_virt(highmem page)and usually goes splat? Good enough treatment for something which never happens anyway?
page_addresswill return NULL so they will blow up and leak the freshly allocated memory.let me be more specific. They will blow up and leak if the returned address is not checked. If it is then we just leak. None of that sounds good to me.
Quoted 6 lines
Quoted 2 lines
So do we care and I will resend the patch in that case or I just drop this from my patch queue?
Well.. I still think that silently accepting bad input would be bad practice. If we can just delete the assertion and have such a caller reliably blow up later on then that's good enough.
The point is that if the caller checks for the failed allocation then the result is a memory leak.
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 10 lines · On Fri, 15 Dec 2017 10:36:18 +0100 Michal Hocko <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
So do we care and I will resend the patch in that case or I just drop this from my patch queue?
Well.. I still think that silently accepting bad input would be bad practice. If we can just delete the assertion and have such a caller reliably blow up later on then that's good enough.
The point is that if the caller checks for the failed allocation then the result is a memory leak.
That's if page_address(highmem page) returns NULL. I'm not sure what it returns, really - so many different implementations across so many different architectures.
Oh well, it would have been nice to remove that VM_BUG_ON(). Why not just leave the code as it is now?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Andrew Morton
Quoted 8 lines · On Fri, 15 Dec 2017 10:36:18 +0100 Michal Hocko <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
So do we care and I will resend the patch in that case or I just drop this from my patch queue?
Well.. I still think that silently accepting bad input would be bad practice. If we can just delete the assertion and have such a caller reliably blow up later on then that's good enough.
Quoted 6 lines
Quoted 2 lines
The point is that if the caller checks for the failed allocation then the result is a memory leak.
That's if
page_address(highmem page)returns NULL. I'm not sure what it returns, really - so many different implementations across so many different architectures.
I am not sure I follow. We only do care for HIGHMEM, right? And that one returns NULL unless the high mem page is not kmaped.
Quoted 2 lines
Oh well, it would have been nice to remove that
VM_BUG_ON(). Why not just leave the code as it is now?
BUGing on a bogus usage is not popular anymore. Also checking for something nobody actually does is a bit pointless. I will not insist though.
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
On Wed 29-11-17 17:04:46, Michal Hocko wrote:
[...]
Quoted 11 lines
From
000bb422fe07adbfa8cd8ed953b18f48647a45d6Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Wed, 29 Nov 2017 17:02:33 +0100
Subject: [PATCH] mm: dropVM_BUG_ONfrom__get_free_pagesThere is no real reason to blow up just because the caller doesn't know that
__get_free_pagescannot return highmem pages. Simply fix that up silently. Even if we have some confused users such a fixup will not be harmful.Signed-off-by Michal Hocko <[email protected]>
Andrew, have we reached any conclusion for this? Should I repost or drop it on the floor?
Quoted 25 lines
--- mm/page_alloc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)mm/page_alloc.c +1
-3@@ -4284,9 +4284,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)* __get_free_pages() returns a virtual address, which cannot represent * a highmem page */ -VM_BUG_ON ((gfp_mask & __GFP_HIGHMEM) !=0 ); - - page =alloc_pages (gfp_mask, order); + page =alloc_pages (gfp_mask & ~__GFP_HIGHMEM, order);if (!page)return 0 ;return (unsigned long )page_address (page);Signature · 5 lines
2.15.0 -- Michal Hocko SUSE Labs
Signature · 2 lines
Michal Hocko SUSE Labs
Andrew Morton
maintainerQuoted 12 lines · On Fri, 6 Apr 2018 12:02:36 +0200 Michal Hocko <[email protected]> wrote:
On Wed 29-11-17 17:04:46, Michal Hocko wrote:
[...]Quoted 10 lines
From
000bb422fe07adbfa8cd8ed953b18f48647a45d6Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Wed, 29 Nov 2017 17:02:33 +0100
Subject: [PATCH] mm: dropVM_BUG_ONfrom__get_free_pagesThere is no real reason to blow up just because the caller doesn't know that
__get_free_pagescannot return highmem pages. Simply fix that up silently. Even if we have some confused users such a fixup will not be harmful.
Quoted 4 lines
Quoted 1 line
Signed-off-by Michal Hocko <[email protected]>Andrew, have we reached any conclusion for this? Should I repost or drop it on the floor?
I actually thought we'd settled on something and merged it. hrm.
Please send a fresh patch sometime?