Skip to contentSkip to conversation

New: f2fs: possibly fail to pageout because PagePrivate is set without increasing page count in .set_page_dirty()

Bug 202749 [email protected] 1 participant 3 messages Mar 4, 2019 – Mar 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=202749

Bug ID: 202749
Summary: f2fs: possibly fail to pageout because PagePrivate is
set without increasing page count in .set_page_dirty()
Product: File System
Version: 2.5
Kernel Version: 5.0 and older
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: f2fs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Regression: No

Hi,

It seems that f2fs sets PagePrivate in f2fs_set_data_page_dirty to indicate that it tend to enable corresponding .invalidatepage and .releasepage for these dirty pages.

However, it seems that it misses to add an extra page count when PagePrivate is set [1].

Therefore, I guess that it can cause that dirty pages are failed to pageout in some cases, therefore I changed mm/vmscan.c code to confirm my thought as follows:

mm/vmscan.c +0 -0
index b247e2c7bbc6..32ee664e686b 100644
@@ -642,8 +642,19 @@ static pageout_t pageout(struct page *page, struct

address_space *mapping,
* swap_backing_dev_info is bust: it doesn't reflect the
* congestion state of the swapdevs. Easy to fix, if needed. */
- if (!is_page_cache_freeable(page))
+ if (!is_page_cache_freeable(page)) {
+ if (page_is_file_cache(page)) {
+ struct inode *const inode = page->mapping->host;
+
+ if (inode->i_sb->s_magic == F2FS_SUPER_MAGIC) {
+ if (PagePrivate(page)) {
+ printk(KERN_EMERG "gx: page %px inode
%px page_private %lx count: %d\n", page, inode, page_private(page), page_count(page));
+ WARN_ON(1);
+ }
+ }
+ }

                return PAGE_KEEP;
+       }
        if (!mapping) {
                /*
                 * Some data journaling orphaned pages can have

with some fsstress pressures I got the following results:

...

[  123.545939] (3)[117:kswapd0]gx: page ffffffbf9638fe80 inode ffffffe57ea2c618
page_private 0 count: 2
[  123.545962] -(3)[117:kswapd0]------------[ cut here ]------------
[  123.545973] -(3)[117:kswapd0]WARNING: CPU: 3 PID: 117 at
/home/g00380047/mt6761_2/kernel-4.9/mm/vmscan.c:652
shrink_page_list+0x5fc/0xddc
[  123.545980] -(3)[117:kswapd0]Modules linked in:
[  123.545990] -(3)[117:kswapd0]
[  123.546000] -(3)[117:kswapd0]CPU: 3 PID: 117 Comm: kswapd0 Tainted: G       
W       4.9.117+ #144
[  123.546008] -(3)[117:kswapd0]Hardware name: MT6761V/WBB (DT)
[  123.546015] -(3)[117:kswapd0]task: ffffffe54ee68000 task.stack:
ffffffe553158000
[  123.546023] -(3)[117:kswapd0]PC is at shrink_page_list+0x5fc/0xddc
[  123.546031] -(3)[117:kswapd0]LR is at shrink_page_list+0x5fc/0xddc
[  123.546038] -(3)[117:kswapd0]pc : [<ffffff84ce4065d4>] lr :
[<ffffff84ce4065d4>] pstate: 60400145
--
[  123.549730] -(3)[117:kswapd0]b800: 0000000000000059 0000000000040975
0000000000040975 0000000000000001
[  123.549738] -(3)[117:kswapd0]b820: ffffff84d0068b68 ffffffe5bfebe050
0000000000008080 feff64716e73726f
[  123.549746] -(3)[117:kswapd0]b840: 7f7f7f7f7f7f7f7f 0000000000040975
0101010101010101 0000000000000030
[  123.549759] -(3)[117:kswapd0][<ffffff84ce4065d4>]
shrink_page_list+0x5fc/0xddc
[  123.549768] -(3)[117:kswapd0][<ffffff84ce407770>]
shrink_inactive_list+0x2e4/0x548
[  123.549777] -(3)[117:kswapd0][<ffffff84ce4084a0>]
shrink_node_memcg.isra.77+0x7a0/0xad8
[  123.549784] -(3)[117:kswapd0][<ffffff84ce408838>] shrink_node+0x60/0x214
[  123.549792] -(3)[117:kswapd0][<ffffff84ce409438>] kswapd+0x36c/0x640
[  123.549803] -(3)[117:kswapd0][<ffffff84ce2d2164>] kthread+0xec/0x100
[  123.549812] -(3)[117:kswapd0][<ffffff84ce283d70>] ret_from_fork+0x10/0x20
[  123.549908] (3)[117:kswapd0]gx: page ffffffbf9638fec0 inode ffffffe57ea2c618
page_private 0 count: 2
[  123.549932] -(3)[117:kswapd0]------------[ cut here ]------------
[  123.549943] -(3)[117:kswapd0]WARNING: CPU: 3 PID: 117 at
/home/g00380047/mt6761_2/kernel-4.9/mm/vmscan.c:652
shrink_page_list+0x5fc/0xddc
[  123.549951] -(3)[117:kswapd0]Modules linked in:
[  123.549960] -(3)[117:kswapd0]
[  123.549969] -(3)[117:kswapd0]CPU: 3 PID: 117 Comm: kswapd0 Tainted: G       
W       4.9.117+ #144
[  123.549976] -(3)[117:kswapd0]Hardware name: MT6761V/WBB (DT)
[  123.549983] -(3)[117:kswapd0]task: ffffffe54ee68000 task.stack:
ffffffe553158000
[  123.549991] -(3)[117:kswapd0]PC is at shrink_page_list+0x5fc/0xddc
[  123.549999] -(3)[117:kswapd0]LR is at shrink_page_list+0x5fc/0xddc
[  123.550006] -(3)[117:kswapd0]pc : [<ffffff84ce4065d4>] lr :
[<ffffff84ce4065d4>] pstate: 60400145
--
[  123.553776] -(3)[117:kswapd0]b800: 0000000000000059 0000000000040975
0000000000040975 0000000000000001
[  123.553784] -(3)[117:kswapd0]b820: ffffff84d0068b68 ffffffe5bfebe050
0000000000008080 feff64716e73726f
[  123.553793] -(3)[117:kswapd0]b840: 7f7f7f7f7f7f7f7f 0000000000040975
0101010101010101 0000000000000030
[  123.553810] -(3)[117:kswapd0][<ffffff84ce4065d4>]
shrink_page_list+0x5fc/0xddc
[  123.553818] -(3)[117:kswapd0][<ffffff84ce407770>]
shrink_inactive_list+0x2e4/0x548
[  123.553827] -(3)[117:kswapd0][<ffffff84ce4084a0>]
shrink_node_memcg.isra.77+0x7a0/0xad8
[  123.553835] -(3)[117:kswapd0][<ffffff84ce408838>] shrink_node+0x60/0x214
[  123.553842] -(3)[117:kswapd0][<ffffff84ce409438>] kswapd+0x36c/0x640
[  123.553853] -(3)[117:kswapd0][<ffffff84ce2d2164>] kthread+0xec/0x100
[  123.553863] -(3)[117:kswapd0][<ffffff84ce283d70>] ret_from_fork+0x10/0x20
[  123.556520] (3)[117:kswapd0]gx: page ffffffbf96385600 inode ffffffe57ea2c618
page_private 0 count: 2
[  123.556560] -(3)[117:kswapd0]------------[ cut here ]------------
[  123.556579] -(3)[117:kswapd0]WARNING: CPU: 3 PID: 117 at
/home/g00380047/mt6761_2/kernel-4.9/mm/vmscan.c:652
shrink_page_list+0x5fc/0xddc
[  123.556587] -(3)[117:kswapd0]Modules linked in:
[  123.556599] -(3)[117:kswapd0]
[  123.556611] -(3)[117:kswapd0]CPU: 3 PID: 117 Comm: kswapd0 Tainted: G       
W       4.9.117+ #144
[  123.556618] -(3)[117:kswapd0]Hardware name: MT6761V/WBB (DT)
[  123.556625] -(3)[117:kswapd0]task: ffffffe54ee68000 task.stack:
ffffffe553158000
[  123.556634] -(3)[117:kswapd0]PC is at shrink_page_list+0x5fc/0xddc
[  123.556642] -(3)[117:kswapd0]LR is at shrink_page_list+0x5fc/0xddc
[  123.556650] -(3)[117:kswapd0]pc : [<ffffff84ce4065d4>] lr :
[<ffffff84ce4065d4>] pstate: 60400145
--
[  123.560464] -(3)[117:kswapd0]b800: 0000000000000059 0000000000040975
0000000000040975 0000000000000001
[  123.560472] -(3)[117:kswapd0]b820: ffffff84d0068b68 ffffffe5bfebe050
0000000000008080 feff64716e73726f
[  123.560480] -(3)[117:kswapd0]b840: 7f7f7f7f7f7f7f7f 0000000000040975
0101010101010101 0000000000000030
[  123.560493] -(3)[117:kswapd0][<ffffff84ce4065d4>]
shrink_page_list+0x5fc/0xddc
[  123.560502] -(3)[117:kswapd0][<ffffff84ce407770>]
shrink_inactive_list+0x2e4/0x548
[  123.560511] -(3)[117:kswapd0][<ffffff84ce4084a0>]
shrink_node_memcg.isra.77+0x7a0/0xad8
[  123.560518] -(3)[117:kswapd0][<ffffff84ce408838>] shrink_node+0x60/0x214
[  123.560527] -(3)[117:kswapd0][<ffffff84ce409438>] kswapd+0x36c/0x640
[  123.560537] -(3)[117:kswapd0][<ffffff84ce2d2164>] kthread+0xec/0x100
[  123.560547] -(3)[117:kswapd0][<ffffff84ce283d70>] ret_from_fork+0x10/0x20

...

and my random pressures generate from
1. echo 0 > /proc/sys/vm/swappiness
2. run 3 threads with
/data/fsstress -d /data/test -p 1000 -n 10000 -l0 -S -c on my test low-end Android phone.

[1] for this constraint, see more details in
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Thanks,
Gao Xiang

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 202749] f2fs: possibly fail to pageout because PagePrivate is set without increasing page count in .set_page_dirty()

https://bugzilla.kernel.org/show_bug.cgi?id=202749

Gao Xiang ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEW                         |RESOLVED
         Resolution|---                         |CODE_FIX

--- Comment #1 from Gao Xiang ([email protected]) --- mark as fixed.

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#2 lore raw

[Bug 202749] f2fs: possibly fail to pageout because PagePrivate is set without increasing page count in .set_page_dirty()

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=202749

--- Comment #2 from Chao Yu ([email protected]) ---
For better bug track, attaching related fixing patch info as below:

240a59156d9b ("f2fs: fix to add refcount once page is tagged PG_private")

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=240a59156d9bcfabceddb66be449e7b32fb5dc4a

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.