All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate
@ 2015-03-16 18:29 ` Laura Abbott
  0 siblings, 0 replies; 6+ messages in thread
From: Laura Abbott @ 2015-03-16 18:29 UTC (permalink / raw)
  To: Joonsoo Kim, Vlastimil Babka, Gioh Kim
  Cc: Laura Abbott, linux-mm, linux-kernel, Naoya Horiguchi,
	Mel Gorman, Rik van Riel, Yasuaki Ishimatsu, Zhang Yanfei,
	Xishi Qiu, Vladimir Davydov, Michal Nazarewicz, Marek Szyprowski

Commit 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
changed the logic of unset_migratetype_isolate to check the buddy allocator
and explicitly call __free_pages to merge. The page that is being freed in
this path never had prep_new_page called so set_page_refcounted is called
explicitly but there is no call to kernel_map_pages. With the default
kernel_map_pages this is mostly harmless but if kernel_map_pages does any
manipulation of the page tables (unmapping or setting pages to read only) this
may trigger a fault:

    alloc_contig_range test_pages_isolated(ceb00, ced00) failed
    Unable to handle kernel paging request at virtual address ffffffc0cec00000
    pgd = ffffffc045fc4000
    [ffffffc0cec00000] *pgd=0000000000000000
    Internal error: Oops: 9600004f [#1] PREEMPT SMP
    Modules linked in: exfatfs
    CPU: 1 PID: 23237 Comm: TimedEventQueue Not tainted 3.10.49-gc72ad36-dirty #1
    task: ffffffc03de52100 ti: ffffffc015388000 task.ti: ffffffc015388000
    PC is at memset+0xc8/0x1c0
    LR is at kernel_map_pages+0x1ec/0x244

Fix this by calling kernel_map_pages to ensure the page is set in the
page table properly

Fixes: 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Vladimir Davydov <vdavydov@parallels.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Gioh Kim <gioh.kim@lge.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
Note this was found on a backport to 3.10 and the code to make kernel_map_pages
change the page table state is currently out of tree. The original had stable,
so this may need to go into stable as well.
---
 mm/page_isolation.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 72f5ac3..755a42c 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -103,6 +103,7 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype)
 
 			if (!is_migrate_isolate_page(buddy)) {
 				__isolate_free_page(page, order);
+				kernel_map_pages(page, (1 << order), 1);
 				set_page_refcounted(page);
 				isolated_page = page;
 			}
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
This e-mail address will be inactive after March 20, 2015
Please contact privately for follow up after that date.


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

* [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate
@ 2015-03-16 18:29 ` Laura Abbott
  0 siblings, 0 replies; 6+ messages in thread
From: Laura Abbott @ 2015-03-16 18:29 UTC (permalink / raw)
  To: Joonsoo Kim, Vlastimil Babka, Gioh Kim
  Cc: Laura Abbott, linux-mm, linux-kernel, Naoya Horiguchi,
	Mel Gorman, Rik van Riel, Yasuaki Ishimatsu, Zhang Yanfei,
	Xishi Qiu, Vladimir Davydov, Michal Nazarewicz, Marek Szyprowski

Commit 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
changed the logic of unset_migratetype_isolate to check the buddy allocator
and explicitly call __free_pages to merge. The page that is being freed in
this path never had prep_new_page called so set_page_refcounted is called
explicitly but there is no call to kernel_map_pages. With the default
kernel_map_pages this is mostly harmless but if kernel_map_pages does any
manipulation of the page tables (unmapping or setting pages to read only) this
may trigger a fault:

    alloc_contig_range test_pages_isolated(ceb00, ced00) failed
    Unable to handle kernel paging request at virtual address ffffffc0cec00000
    pgd = ffffffc045fc4000
    [ffffffc0cec00000] *pgd=0000000000000000
    Internal error: Oops: 9600004f [#1] PREEMPT SMP
    Modules linked in: exfatfs
    CPU: 1 PID: 23237 Comm: TimedEventQueue Not tainted 3.10.49-gc72ad36-dirty #1
    task: ffffffc03de52100 ti: ffffffc015388000 task.ti: ffffffc015388000
    PC is at memset+0xc8/0x1c0
    LR is at kernel_map_pages+0x1ec/0x244

Fix this by calling kernel_map_pages to ensure the page is set in the
page table properly

Fixes: 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Vladimir Davydov <vdavydov@parallels.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Gioh Kim <gioh.kim@lge.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
Note this was found on a backport to 3.10 and the code to make kernel_map_pages
change the page table state is currently out of tree. The original had stable,
so this may need to go into stable as well.
---
 mm/page_isolation.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 72f5ac3..755a42c 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -103,6 +103,7 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype)
 
 			if (!is_migrate_isolate_page(buddy)) {
 				__isolate_free_page(page, order);
+				kernel_map_pages(page, (1 << order), 1);
 				set_page_refcounted(page);
 				isolated_page = page;
 			}
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
This e-mail address will be inactive after March 20, 2015
Please contact privately for follow up after that date.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate
  2015-03-16 18:29 ` Laura Abbott
@ 2015-03-17  2:08   ` Joonsoo Kim
  -1 siblings, 0 replies; 6+ messages in thread
From: Joonsoo Kim @ 2015-03-17  2:08 UTC (permalink / raw)
  To: Laura Abbott
  Cc: Vlastimil Babka, Gioh Kim, linux-mm, linux-kernel,
	Naoya Horiguchi, Mel Gorman, Rik van Riel, Yasuaki Ishimatsu,
	Zhang Yanfei, Xishi Qiu, Vladimir Davydov, Michal Nazarewicz,
	Marek Szyprowski

On Mon, Mar 16, 2015 at 11:29:45AM -0700, Laura Abbott wrote:
> Commit 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
> changed the logic of unset_migratetype_isolate to check the buddy allocator
> and explicitly call __free_pages to merge. The page that is being freed in
> this path never had prep_new_page called so set_page_refcounted is called
> explicitly but there is no call to kernel_map_pages. With the default
> kernel_map_pages this is mostly harmless but if kernel_map_pages does any
> manipulation of the page tables (unmapping or setting pages to read only) this
> may trigger a fault:
> 
>     alloc_contig_range test_pages_isolated(ceb00, ced00) failed
>     Unable to handle kernel paging request at virtual address ffffffc0cec00000
>     pgd = ffffffc045fc4000
>     [ffffffc0cec00000] *pgd=0000000000000000
>     Internal error: Oops: 9600004f [#1] PREEMPT SMP
>     Modules linked in: exfatfs
>     CPU: 1 PID: 23237 Comm: TimedEventQueue Not tainted 3.10.49-gc72ad36-dirty #1
>     task: ffffffc03de52100 ti: ffffffc015388000 task.ti: ffffffc015388000
>     PC is at memset+0xc8/0x1c0
>     LR is at kernel_map_pages+0x1ec/0x244
> 
> Fix this by calling kernel_map_pages to ensure the page is set in the
> page table properly
> 
> Fixes: 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> Cc: Xishi Qiu <qiuxishi@huawei.com>
> Cc: Vladimir Davydov <vdavydov@parallels.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Gioh Kim <gioh.kim@lge.com>
> Cc: Michal Nazarewicz <mina86@mina86.com>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
> ---
> Note this was found on a backport to 3.10 and the code to make kernel_map_pages
> change the page table state is currently out of tree. The original had stable,
> so this may need to go into stable as well.

I found that some implementation of kernel_map_pages() in mainline also require
this change. Some implementation doesn't check previous state of page table, but
some others check previous state of page table when calling kernel_map_pages().

Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Thanks.

> ---
>  mm/page_isolation.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index 72f5ac3..755a42c 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -103,6 +103,7 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype)
>  
>  			if (!is_migrate_isolate_page(buddy)) {
>  				__isolate_free_page(page, order);
> +				kernel_map_pages(page, (1 << order), 1);
>  				set_page_refcounted(page);
>  				isolated_page = page;
>  			}
> -- 
> Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
> This e-mail address will be inactive after March 20, 2015
> Please contact privately for follow up after that date.
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate
@ 2015-03-17  2:08   ` Joonsoo Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Joonsoo Kim @ 2015-03-17  2:08 UTC (permalink / raw)
  To: Laura Abbott
  Cc: Vlastimil Babka, Gioh Kim, linux-mm, linux-kernel,
	Naoya Horiguchi, Mel Gorman, Rik van Riel, Yasuaki Ishimatsu,
	Zhang Yanfei, Xishi Qiu, Vladimir Davydov, Michal Nazarewicz,
	Marek Szyprowski

On Mon, Mar 16, 2015 at 11:29:45AM -0700, Laura Abbott wrote:
> Commit 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
> changed the logic of unset_migratetype_isolate to check the buddy allocator
> and explicitly call __free_pages to merge. The page that is being freed in
> this path never had prep_new_page called so set_page_refcounted is called
> explicitly but there is no call to kernel_map_pages. With the default
> kernel_map_pages this is mostly harmless but if kernel_map_pages does any
> manipulation of the page tables (unmapping or setting pages to read only) this
> may trigger a fault:
> 
>     alloc_contig_range test_pages_isolated(ceb00, ced00) failed
>     Unable to handle kernel paging request at virtual address ffffffc0cec00000
>     pgd = ffffffc045fc4000
>     [ffffffc0cec00000] *pgd=0000000000000000
>     Internal error: Oops: 9600004f [#1] PREEMPT SMP
>     Modules linked in: exfatfs
>     CPU: 1 PID: 23237 Comm: TimedEventQueue Not tainted 3.10.49-gc72ad36-dirty #1
>     task: ffffffc03de52100 ti: ffffffc015388000 task.ti: ffffffc015388000
>     PC is at memset+0xc8/0x1c0
>     LR is at kernel_map_pages+0x1ec/0x244
> 
> Fix this by calling kernel_map_pages to ensure the page is set in the
> page table properly
> 
> Fixes: 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> Cc: Xishi Qiu <qiuxishi@huawei.com>
> Cc: Vladimir Davydov <vdavydov@parallels.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Gioh Kim <gioh.kim@lge.com>
> Cc: Michal Nazarewicz <mina86@mina86.com>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
> ---
> Note this was found on a backport to 3.10 and the code to make kernel_map_pages
> change the page table state is currently out of tree. The original had stable,
> so this may need to go into stable as well.

I found that some implementation of kernel_map_pages() in mainline also require
this change. Some implementation doesn't check previous state of page table, but
some others check previous state of page table when calling kernel_map_pages().

Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Thanks.

> ---
>  mm/page_isolation.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index 72f5ac3..755a42c 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -103,6 +103,7 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype)
>  
>  			if (!is_migrate_isolate_page(buddy)) {
>  				__isolate_free_page(page, order);
> +				kernel_map_pages(page, (1 << order), 1);
>  				set_page_refcounted(page);
>  				isolated_page = page;
>  			}
> -- 
> Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
> This e-mail address will be inactive after March 20, 2015
> Please contact privately for follow up after that date.
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate
  2015-03-16 18:29 ` Laura Abbott
@ 2015-03-17  2:23   ` Rik van Riel
  -1 siblings, 0 replies; 6+ messages in thread
From: Rik van Riel @ 2015-03-17  2:23 UTC (permalink / raw)
  To: Laura Abbott, Joonsoo Kim, Vlastimil Babka, Gioh Kim
  Cc: linux-mm, linux-kernel, Naoya Horiguchi, Mel Gorman,
	Yasuaki Ishimatsu, Zhang Yanfei, Xishi Qiu, Vladimir Davydov,
	Michal Nazarewicz, Marek Szyprowski

On 03/16/2015 02:29 PM, Laura Abbott wrote:
> Commit 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
> changed the logic of unset_migratetype_isolate to check the buddy allocator
> and explicitly call __free_pages to merge. The page that is being freed in
> this path never had prep_new_page called so set_page_refcounted is called
> explicitly but there is no call to kernel_map_pages. With the default
> kernel_map_pages this is mostly harmless but if kernel_map_pages does any
> manipulation of the page tables (unmapping or setting pages to read only) this
> may trigger a fault:
> 
>     alloc_contig_range test_pages_isolated(ceb00, ced00) failed
>     Unable to handle kernel paging request at virtual address ffffffc0cec00000
>     pgd = ffffffc045fc4000
>     [ffffffc0cec00000] *pgd=0000000000000000
>     Internal error: Oops: 9600004f [#1] PREEMPT SMP
>     Modules linked in: exfatfs
>     CPU: 1 PID: 23237 Comm: TimedEventQueue Not tainted 3.10.49-gc72ad36-dirty #1
>     task: ffffffc03de52100 ti: ffffffc015388000 task.ti: ffffffc015388000
>     PC is at memset+0xc8/0x1c0
>     LR is at kernel_map_pages+0x1ec/0x244
> 
> Fix this by calling kernel_map_pages to ensure the page is set in the
> page table properly

Acked-by: Rik van Riel <riel@redhat.com>

-- 
All rights reversed

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

* Re: [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate
@ 2015-03-17  2:23   ` Rik van Riel
  0 siblings, 0 replies; 6+ messages in thread
From: Rik van Riel @ 2015-03-17  2:23 UTC (permalink / raw)
  To: Laura Abbott, Joonsoo Kim, Vlastimil Babka, Gioh Kim
  Cc: linux-mm, linux-kernel, Naoya Horiguchi, Mel Gorman,
	Yasuaki Ishimatsu, Zhang Yanfei, Xishi Qiu, Vladimir Davydov,
	Michal Nazarewicz, Marek Szyprowski

On 03/16/2015 02:29 PM, Laura Abbott wrote:
> Commit 3c605096d315 ("mm/page_alloc: restrict max order of merging on isolated pageblock")
> changed the logic of unset_migratetype_isolate to check the buddy allocator
> and explicitly call __free_pages to merge. The page that is being freed in
> this path never had prep_new_page called so set_page_refcounted is called
> explicitly but there is no call to kernel_map_pages. With the default
> kernel_map_pages this is mostly harmless but if kernel_map_pages does any
> manipulation of the page tables (unmapping or setting pages to read only) this
> may trigger a fault:
> 
>     alloc_contig_range test_pages_isolated(ceb00, ced00) failed
>     Unable to handle kernel paging request at virtual address ffffffc0cec00000
>     pgd = ffffffc045fc4000
>     [ffffffc0cec00000] *pgd=0000000000000000
>     Internal error: Oops: 9600004f [#1] PREEMPT SMP
>     Modules linked in: exfatfs
>     CPU: 1 PID: 23237 Comm: TimedEventQueue Not tainted 3.10.49-gc72ad36-dirty #1
>     task: ffffffc03de52100 ti: ffffffc015388000 task.ti: ffffffc015388000
>     PC is at memset+0xc8/0x1c0
>     LR is at kernel_map_pages+0x1ec/0x244
> 
> Fix this by calling kernel_map_pages to ensure the page is set in the
> page table properly

Acked-by: Rik van Riel <riel@redhat.com>

-- 
All rights reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-03-17  2:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 18:29 [PATCH] mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate Laura Abbott
2015-03-16 18:29 ` Laura Abbott
2015-03-17  2:08 ` Joonsoo Kim
2015-03-17  2:08   ` Joonsoo Kim
2015-03-17  2:23 ` Rik van Riel
2015-03-17  2:23   ` Rik van Riel

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.