CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Johannes Weiner <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Linux Memory Management List <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   6a37ebbe07bf72cd5fd791d67a664f37c8f17a13
commit: 2d8a580492b79cdfd1cb01a9ba2c63902312d1b4 [11942/13220] vfs: keep inodes 
with page cache off the inode shrinker LRU
:::::: branch date: 2 days ago
:::::: commit date: 8 days ago
config: x86_64-rhel-8.3-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Julia Lawall <[email protected]>


cocci warnings: (new ones prefixed by >>)
>> mm/vmscan.c:1192:1-7: preceding lock on line 1109

vim +1192 mm/vmscan.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  1094  
a649fd9271773d Andrew Morton     2006-10-17  1095  /*
e286781d5f2e9c Nicholas Piggin   2008-07-25  1096   * Same as remove_mapping, 
but if the page is removed from the mapping, it
e286781d5f2e9c Nicholas Piggin   2008-07-25  1097   * gets returned with a 
refcount of 0.
a649fd9271773d Andrew Morton     2006-10-17  1098   */
a528910e12ec7e Johannes Weiner   2014-04-03  1099  static int 
__remove_mapping(struct address_space *mapping, struct page *page,
b910718a948a91 Johannes Weiner   2019-11-30  1100                           
bool reclaimed, struct mem_cgroup *target_memcg)
49d2e9cc454436 Christoph Lameter 2006-01-08  1101  {
bd4c82c22c367e Huang Ying        2017-09-06  1102       int refcount;
aae466b0052e18 Joonsoo Kim       2020-08-11  1103       void *shadow = NULL;
c4843a7593a9df Greg Thelen       2015-05-22  1104  
28e4d965e6131a Nicholas Piggin   2006-09-25  1105       
BUG_ON(!PageLocked(page));
28e4d965e6131a Nicholas Piggin   2006-09-25  1106       BUG_ON(mapping != 
page_mapping(page));
49d2e9cc454436 Christoph Lameter 2006-01-08  1107  
2d8a580492b79c Johannes Weiner   2021-10-28  1108       if 
(!PageSwapCache(page))
2d8a580492b79c Johannes Weiner   2021-10-28 @1109               
spin_lock(&mapping->host->i_lock);
3047250972ff93 Johannes Weiner   2021-09-02  1110       
xa_lock_irq(&mapping->i_pages);
49d2e9cc454436 Christoph Lameter 2006-01-08  1111       /*
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1112        * The non racy check 
for a busy page.
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1113        *
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1114        * Must be careful with 
the order of the tests. When someone has
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1115        * a ref to the page, 
it may be possible that they dirty it then
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1116        * drop the reference. 
So if PageDirty is tested before page_count
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1117        * here, then the 
following race may occur:
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1118        *
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1119        * 
get_user_pages(&page);
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1120        * [user mapping goes 
away]
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1121        * write_to(page);
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1122        *                      
        !PageDirty(page)    [good]
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1123        * SetPageDirty(page);
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1124        * put_page(page);
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1125        *                      
        !page_count(page)   [good, discard it]
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1126        *
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1127        * [oops, our write_to 
data is lost]
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1128        *
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1129        * Reversing the order 
of the tests ensures such a situation cannot
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1130        * escape unnoticed. 
The smp_rmb is needed to ensure the page->flags
0139aa7b7fa12c Joonsoo Kim       2016-05-19  1131        * load is not 
satisfied before that of page->_refcount.
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1132        *
0fd0e6b05aa096 Nicholas Piggin   2006-09-27  1133        * Note that if 
SetPageDirty is always performed via set_page_dirty,
b93b016313b3ba Matthew Wilcox    2018-04-10  1134        * and thus under the 
i_pages lock, then this ordering is not required.
49d2e9cc454436 Christoph Lameter 2006-01-08  1135        */
906d278d75e364 William Kucharski 2019-10-18  1136       refcount = 1 + 
compound_nr(page);
bd4c82c22c367e Huang Ying        2017-09-06  1137       if 
(!page_ref_freeze(page, refcount))
49d2e9cc454436 Christoph Lameter 2006-01-08  1138               goto 
cannot_free;
1c4c3b99c03d3e Jiang Biao        2018-08-21  1139       /* note: atomic_cmpxchg 
in page_ref_freeze provides the smp_rmb */
e286781d5f2e9c Nicholas Piggin   2008-07-25  1140       if 
(unlikely(PageDirty(page))) {
bd4c82c22c367e Huang Ying        2017-09-06  1141               
page_ref_unfreeze(page, refcount);
49d2e9cc454436 Christoph Lameter 2006-01-08  1142               goto 
cannot_free;
e286781d5f2e9c Nicholas Piggin   2008-07-25  1143       }
49d2e9cc454436 Christoph Lameter 2006-01-08  1144  
49d2e9cc454436 Christoph Lameter 2006-01-08  1145       if 
(PageSwapCache(page)) {
49d2e9cc454436 Christoph Lameter 2006-01-08  1146               swp_entry_t 
swap = { .val = page_private(page) };
0a31bc97c80c3f Johannes Weiner   2014-08-08  1147               
mem_cgroup_swapout(page, swap);
aae466b0052e18 Joonsoo Kim       2020-08-11  1148               if (reclaimed 
&& !mapping_exiting(mapping))
aae466b0052e18 Joonsoo Kim       2020-08-11  1149                       shadow 
= workingset_eviction(page, target_memcg);
aae466b0052e18 Joonsoo Kim       2020-08-11  1150               
__delete_from_swap_cache(page, swap, shadow);
3047250972ff93 Johannes Weiner   2021-09-02  1151               
xa_unlock_irq(&mapping->i_pages);
75f6d6d29a40b5 Minchan Kim       2017-07-06  1152               
put_swap_page(page, swap);
e286781d5f2e9c Nicholas Piggin   2008-07-25  1153       } else {
6072d13c429373 Linus Torvalds    2010-12-01  1154               void 
(*freepage)(struct page *);
6072d13c429373 Linus Torvalds    2010-12-01  1155  
6072d13c429373 Linus Torvalds    2010-12-01  1156               freepage = 
mapping->a_ops->freepage;
a528910e12ec7e Johannes Weiner   2014-04-03  1157               /*
a528910e12ec7e Johannes Weiner   2014-04-03  1158                * Remember a 
shadow entry for reclaimed file cache in
a528910e12ec7e Johannes Weiner   2014-04-03  1159                * order to 
detect refaults, thus thrashing, later on.
a528910e12ec7e Johannes Weiner   2014-04-03  1160                *
a528910e12ec7e Johannes Weiner   2014-04-03  1161                * But don't 
store shadows in an address space that is
238c30468f46b1 dylan-meiners     2020-08-06  1162                * already 
exiting.  This is not just an optimization,
a528910e12ec7e Johannes Weiner   2014-04-03  1163                * inode 
reclaim needs to empty out the radix tree or
a528910e12ec7e Johannes Weiner   2014-04-03  1164                * the nodes 
are lost.  Don't plant shadows behind its
a528910e12ec7e Johannes Weiner   2014-04-03  1165                * back.
f9fe48bece3af2 Ross Zwisler      2016-01-22  1166                *
f9fe48bece3af2 Ross Zwisler      2016-01-22  1167                * We also 
don't store shadows for DAX mappings because the
f9fe48bece3af2 Ross Zwisler      2016-01-22  1168                * only page 
cache pages found in these are zero pages
f9fe48bece3af2 Ross Zwisler      2016-01-22  1169                * covering 
holes, and because we don't want to mix DAX
f9fe48bece3af2 Ross Zwisler      2016-01-22  1170                * exceptional 
entries and shadow exceptional entries in the
b93b016313b3ba Matthew Wilcox    2018-04-10  1171                * same 
address_space.
a528910e12ec7e Johannes Weiner   2014-04-03  1172                */
9de4f22a60f731 Huang Ying        2020-04-06  1173               if (reclaimed 
&& page_is_file_lru(page) &&
f9fe48bece3af2 Ross Zwisler      2016-01-22  1174                   
!mapping_exiting(mapping) && !dax_mapping(mapping))
b910718a948a91 Johannes Weiner   2019-11-30  1175                       shadow 
= workingset_eviction(page, target_memcg);
62cccb8c8e7a3c Johannes Weiner   2016-03-15  1176               
__delete_from_page_cache(page, shadow);
3047250972ff93 Johannes Weiner   2021-09-02  1177               
xa_unlock_irq(&mapping->i_pages);
2d8a580492b79c Johannes Weiner   2021-10-28  1178               if 
(mapping_shrinkable(mapping))
2d8a580492b79c Johannes Weiner   2021-10-28  1179                       
inode_add_lru(mapping->host);
2d8a580492b79c Johannes Weiner   2021-10-28  1180               
spin_unlock(&mapping->host->i_lock);
6072d13c429373 Linus Torvalds    2010-12-01  1181  
6072d13c429373 Linus Torvalds    2010-12-01  1182               if (freepage != 
NULL)
6072d13c429373 Linus Torvalds    2010-12-01  1183                       
freepage(page);
e286781d5f2e9c Nicholas Piggin   2008-07-25  1184       }
e286781d5f2e9c Nicholas Piggin   2008-07-25  1185  
49d2e9cc454436 Christoph Lameter 2006-01-08  1186       return 1;
49d2e9cc454436 Christoph Lameter 2006-01-08  1187  
49d2e9cc454436 Christoph Lameter 2006-01-08  1188  cannot_free:
3047250972ff93 Johannes Weiner   2021-09-02  1189       
xa_unlock_irq(&mapping->i_pages);
2d8a580492b79c Johannes Weiner   2021-10-28  1190       if 
(!PageSwapCache(page))
2d8a580492b79c Johannes Weiner   2021-10-28  1191               
spin_unlock(&mapping->host->i_lock);
49d2e9cc454436 Christoph Lameter 2006-01-08 @1192       return 0;
49d2e9cc454436 Christoph Lameter 2006-01-08  1193  }
49d2e9cc454436 Christoph Lameter 2006-01-08  1194  

:::::: The code at line 1192 was first introduced by commit
:::::: 49d2e9cc4544369635cd6f4ef6d5bb0f757079a7 [PATCH] Swap Migration V5: 
migrate_pages() function

:::::: TO: Christoph Lameter <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to