Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP)
@ 2020-03-10 23:58 Qian Cai
  2020-03-11  0:48 ` Huang, Ying
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qian Cai @ 2020-03-10 23:58 UTC (permalink / raw)
  To: akpm
  Cc: ying.huang, kirill.shutemov, linux-mm, linux-kernel, Qian Cai, stable

The commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after
swapped out") supported writing THP to a swap device but forgot to
upgrade an older commit df8c94d13c7e ("page-flags: define behavior of
FS/IO-related flags on compound pages") which could trigger a crash
during THP swapping out with DEBUG_VM_PGFLAGS=y,

kernel BUG at include/linux/page-flags.h:317!

page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page))
page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c
index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0
compound_pincount:0
anon flags:
0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked)

end_swap_bio_write()
  SetPageError(page)
    VM_BUG_ON_PAGE(1 && PageCompound(page))

<IRQ>
bio_endio+0x297/0x560
dec_pending+0x218/0x430 [dm_mod]
clone_endio+0xe4/0x2c0 [dm_mod]
bio_endio+0x297/0x560
blk_update_request+0x201/0x920
scsi_end_request+0x6b/0x4b0
scsi_io_completion+0x509/0x7e0
scsi_finish_command+0x1ed/0x2a0
scsi_softirq_done+0x1c9/0x1d0
__blk_mqnterrupt+0xf/0x20
</IRQ>

Fix by checking PF_NO_TAIL in those places instead.

Fixes: bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out")
Cc: <stable@vger.kernel.org>
Signed-off-by: Qian Cai <cai@lca.pw>
---
 include/linux/page-flags.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 1bf83c8fcaa7..77de28bfefb0 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -311,7 +311,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; }
 
 __PAGEFLAG(Locked, locked, PF_NO_TAIL)
 PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD)
-PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
+PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL)
 PAGEFLAG(Referenced, referenced, PF_HEAD)
 	TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
 	__SETPAGEFLAG(Referenced, referenced, PF_HEAD)
-- 
2.21.0 (Apple Git-122.2)



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

* Re: [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP)
  2020-03-10 23:58 [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP) Qian Cai
@ 2020-03-11  0:48 ` Huang, Ying
  2020-03-11 13:57 ` David Hildenbrand
  2020-03-13 21:43 ` Rafael Aquini
  2 siblings, 0 replies; 4+ messages in thread
From: Huang, Ying @ 2020-03-11  0:48 UTC (permalink / raw)
  To: Qian Cai; +Cc: akpm, kirill.shutemov, linux-mm, linux-kernel, stable

Qian Cai <cai@lca.pw> writes:

> The commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after
> swapped out") supported writing THP to a swap device but forgot to
> upgrade an older commit df8c94d13c7e ("page-flags: define behavior of
> FS/IO-related flags on compound pages") which could trigger a crash
> during THP swapping out with DEBUG_VM_PGFLAGS=y,
>
> kernel BUG at include/linux/page-flags.h:317!
>
> page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page))
> page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c
> index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0
> compound_pincount:0
> anon flags:
> 0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked)
>
> end_swap_bio_write()
>   SetPageError(page)
>     VM_BUG_ON_PAGE(1 && PageCompound(page))
>
> <IRQ>
> bio_endio+0x297/0x560
> dec_pending+0x218/0x430 [dm_mod]
> clone_endio+0xe4/0x2c0 [dm_mod]
> bio_endio+0x297/0x560
> blk_update_request+0x201/0x920
> scsi_end_request+0x6b/0x4b0
> scsi_io_completion+0x509/0x7e0
> scsi_finish_command+0x1ed/0x2a0
> scsi_softirq_done+0x1c9/0x1d0
> __blk_mqnterrupt+0xf/0x20
> </IRQ>
>
> Fix by checking PF_NO_TAIL in those places instead.
>
> Fixes: bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Qian Cai <cai@lca.pw>

Good catch!  Thanks!

Acked-by: "Huang, Ying" <ying.huang@intel.com>

> ---
>  include/linux/page-flags.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 1bf83c8fcaa7..77de28bfefb0 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -311,7 +311,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; }
>  
>  __PAGEFLAG(Locked, locked, PF_NO_TAIL)
>  PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD)
> -PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
> +PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL)
>  PAGEFLAG(Referenced, referenced, PF_HEAD)
>  	TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
>  	__SETPAGEFLAG(Referenced, referenced, PF_HEAD)


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

* Re: [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP)
  2020-03-10 23:58 [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP) Qian Cai
  2020-03-11  0:48 ` Huang, Ying
@ 2020-03-11 13:57 ` David Hildenbrand
  2020-03-13 21:43 ` Rafael Aquini
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2020-03-11 13:57 UTC (permalink / raw)
  To: Qian Cai, akpm
  Cc: ying.huang, kirill.shutemov, linux-mm, linux-kernel, stable

On 11.03.20 00:58, Qian Cai wrote:
> The commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after
> swapped out") supported writing THP to a swap device but forgot to
> upgrade an older commit df8c94d13c7e ("page-flags: define behavior of
> FS/IO-related flags on compound pages") which could trigger a crash
> during THP swapping out with DEBUG_VM_PGFLAGS=y,
> 
> kernel BUG at include/linux/page-flags.h:317!
> 
> page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page))
> page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c
> index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0
> compound_pincount:0
> anon flags:
> 0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked)
> 
> end_swap_bio_write()
>   SetPageError(page)
>     VM_BUG_ON_PAGE(1 && PageCompound(page))
> 
> <IRQ>
> bio_endio+0x297/0x560
> dec_pending+0x218/0x430 [dm_mod]
> clone_endio+0xe4/0x2c0 [dm_mod]
> bio_endio+0x297/0x560
> blk_update_request+0x201/0x920
> scsi_end_request+0x6b/0x4b0
> scsi_io_completion+0x509/0x7e0
> scsi_finish_command+0x1ed/0x2a0
> scsi_softirq_done+0x1c9/0x1d0
> __blk_mqnterrupt+0xf/0x20
> </IRQ>
> 
> Fix by checking PF_NO_TAIL in those places instead.
> 
> Fixes: bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  include/linux/page-flags.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 1bf83c8fcaa7..77de28bfefb0 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -311,7 +311,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; }
>  
>  __PAGEFLAG(Locked, locked, PF_NO_TAIL)
>  PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD)
> -PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
> +PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL)
>  PAGEFLAG(Referenced, referenced, PF_HEAD)
>  	TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
>  	__SETPAGEFLAG(Referenced, referenced, PF_HEAD)
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



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

* Re: [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP)
  2020-03-10 23:58 [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP) Qian Cai
  2020-03-11  0:48 ` Huang, Ying
  2020-03-11 13:57 ` David Hildenbrand
@ 2020-03-13 21:43 ` Rafael Aquini
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael Aquini @ 2020-03-13 21:43 UTC (permalink / raw)
  To: Qian Cai
  Cc: akpm, ying.huang, kirill.shutemov, linux-mm, linux-kernel, stable

On Tue, Mar 10, 2020 at 07:58:46PM -0400, Qian Cai wrote:
> The commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after
> swapped out") supported writing THP to a swap device but forgot to
> upgrade an older commit df8c94d13c7e ("page-flags: define behavior of
> FS/IO-related flags on compound pages") which could trigger a crash
> during THP swapping out with DEBUG_VM_PGFLAGS=y,
> 
> kernel BUG at include/linux/page-flags.h:317!
> 
> page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page))
> page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c
> index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0
> compound_pincount:0
> anon flags:
> 0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked)
> 
> end_swap_bio_write()
>   SetPageError(page)
>     VM_BUG_ON_PAGE(1 && PageCompound(page))
> 
> <IRQ>
> bio_endio+0x297/0x560
> dec_pending+0x218/0x430 [dm_mod]
> clone_endio+0xe4/0x2c0 [dm_mod]
> bio_endio+0x297/0x560
> blk_update_request+0x201/0x920
> scsi_end_request+0x6b/0x4b0
> scsi_io_completion+0x509/0x7e0
> scsi_finish_command+0x1ed/0x2a0
> scsi_softirq_done+0x1c9/0x1d0
> __blk_mqnterrupt+0xf/0x20
> </IRQ>
> 
> Fix by checking PF_NO_TAIL in those places instead.
> 
> Fixes: bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  include/linux/page-flags.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 1bf83c8fcaa7..77de28bfefb0 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -311,7 +311,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; }
>  
>  __PAGEFLAG(Locked, locked, PF_NO_TAIL)
>  PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD)
> -PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
> +PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL)
>  PAGEFLAG(Referenced, referenced, PF_HEAD)
>  	TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
>  	__SETPAGEFLAG(Referenced, referenced, PF_HEAD)
> -- 
> 2.21.0 (Apple Git-122.2)
> 
Acked-by: Rafael Aquini <aquini@redhat.com>



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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 23:58 [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP) Qian Cai
2020-03-11  0:48 ` Huang, Ying
2020-03-11 13:57 ` David Hildenbrand
2020-03-13 21:43 ` Rafael Aquini

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git