CC: [email protected]
CC: [email protected]
BCC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: "Matthew Wilcox (Oracle)" <[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:   38a288f5941ef03752887ad86f2d85442358c99a
commit: b5a5d07ad0bbab66e0d24f93860423361d763453 [7388/9759] swap: turn 
get_swap_page() into folio_alloc_swap()
:::::: branch date: 2 days ago
:::::: commit date: 9 days ago
config: mips-randconfig-c004-20220508 
(https://download.01.org/0day-ci/archive/20220508/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
af4cf1c6b8ed0d8102fc5e69acdc2fcbbcdaa9a7)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=b5a5d07ad0bbab66e0d24f93860423361d763453
        git remote add linux-next 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout b5a5d07ad0bbab66e0d24f93860423361d763453
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 
clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-utils.c:48:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(new_map + old_num, 0, (new_num - old_num) * sizeof(*new_map));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   38 warnings generated.
   drivers/gpio/gpio-tqmx86.c:318:27: warning: Access to field 'domain' results 
in a dereference of an undefined pointer value (loaded from variable 'girq') 
[clang-analyzer-core.NullDereference]
           irq_domain_set_pm_device(girq->domain, dev);
                                    ^~~~
   drivers/gpio/gpio-tqmx86.c:234:2: note: 'girq' declared without an initial 
value
           struct gpio_irq_chip *girq;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpio/gpio-tqmx86.c:240:6: note: Assuming 'irq' is >= 0
           if (irq < 0 && irq != -ENXIO)
               ^~~~~~~
   drivers/gpio/gpio-tqmx86.c:240:14: note: Left side of '&&' is false
           if (irq < 0 && irq != -ENXIO)
                       ^
   drivers/gpio/gpio-tqmx86.c:244:6: note: Assuming 'res' is non-null
           if (!res) {
               ^~~~
   drivers/gpio/gpio-tqmx86.c:244:2: note: Taking false branch
           if (!res) {
           ^
   drivers/gpio/gpio-tqmx86.c:250:6: note: Assuming 'io_base' is non-null
           if (!io_base)
               ^~~~~~~~
   drivers/gpio/gpio-tqmx86.c:250:2: note: Taking false branch
           if (!io_base)
           ^
   drivers/gpio/gpio-tqmx86.c:254:6: note: Assuming 'gpio' is non-null
           if (!gpio)
               ^~~~~
   drivers/gpio/gpio-tqmx86.c:254:2: note: Taking false branch
           if (!gpio)
           ^
   drivers/gpio/gpio-tqmx86.c:257:2: note: Loop condition is false.  Exiting 
loop
           raw_spin_lock_init(&gpio->spinlock);
           ^
   include/linux/spinlock.h:102:39: note: expanded from macro 
'raw_spin_lock_init'
   # define raw_spin_lock_init(lock)                                       \
                                                                           ^
   drivers/gpio/gpio-tqmx86.c:279:6: note: Assuming 'irq' is <= 0
           if (irq > 0) {
               ^~~~~~~
   drivers/gpio/gpio-tqmx86.c:279:2: note: Taking false branch
           if (irq > 0) {
           ^
   drivers/gpio/gpio-tqmx86.c:313:6: note: Assuming 'ret' is 0
           if (ret) {
               ^~~
   drivers/gpio/gpio-tqmx86.c:313:2: note: Taking false branch
           if (ret) {
           ^
   drivers/gpio/gpio-tqmx86.c:318:27: note: Access to field 'domain' results in 
a dereference of an undefined pointer value (loaded from variable 'girq')
           irq_domain_set_pm_device(girq->domain, dev);
                                    ^~~~
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   46 warnings generated.
   Suppressed 46 warnings (46 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   46 warnings generated.
   Suppressed 46 warnings (46 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   51 warnings generated.
>> mm/shmem.c:1316:16: warning: Value stored to 'folio' during its 
>> initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct folio *folio = page_folio(page);
                         ^~~~~
   mm/shmem.c:1316:16: note: Value stored to 'folio' during its initialization 
is never read
           struct folio *folio = page_folio(page);
                         ^~~~~
   mm/shmem.c:1338:2: warning: Value stored to 'index' is never read 
[clang-analyzer-deadcode.DeadStores]
           index = page->index;
           ^       ~~~~~~~~~~~
   mm/shmem.c:1338:2: note: Value stored to 'index' is never read
           index = page->index;
           ^       ~~~~~~~~~~~
   mm/shmem.c:1530:24: warning: Value stored to 'mapping' during its 
initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct address_space *mapping = info->vfs_inode.i_mapping;
                                 ^~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/shmem.c:1530:24: note: Value stored to 'mapping' during its 
initialization is never read
           struct address_space *mapping = info->vfs_inode.i_mapping;
                                 ^~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/shmem.c:2269:3: warning: Call to function 'memset' is insecure as it does 
not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memset(info, 0, (char *)inode - (char *)info);
                   ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   mm/shmem.c:2269:3: note: Call to function 'memset' is insecure as it does 
not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memset_s' in case of C11
                   memset(info, 0, (char *)inode - (char *)info);
                   ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   Suppressed 47 warnings (46 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   51 warnings generated.
   mm/util.c:63:3: warning: Call to function 'memcpy' is insecure as it does 
not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(buf, s, len);
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   mm/util.c:63:3: note: Call to function 'memcpy' is insecure as it does not 
provide security checks introduced in the C11 standard. Replace with analogous 
functions that support length arguments or provides boundary checks such as 
'memcpy_s' in case of C11
                   memcpy(buf, s, len);
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   mm/util.c:109:3: warning: Call to function 'memcpy' is insecure as it does 
not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(buf, s, len);
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   mm/util.c:109:3: note: Call to function 'memcpy' is insecure as it does not 
provide security checks introduced in the C11 standard. Replace with analogous 
functions that support length arguments or provides boundary checks such as 
'memcpy_s' in case of C11
                   memcpy(buf, s, len);
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   mm/util.c:131:3: warning: Call to function 'memcpy' is insecure as it does 
not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(p, src, len);
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'

vim +/folio +1316 mm/shmem.c

^1da177e4c3f41 Linus Torvalds          2005-04-16  1310  
^1da177e4c3f41 Linus Torvalds          2005-04-16  1311  /*
^1da177e4c3f41 Linus Torvalds          2005-04-16  1312   * Move the page from 
the page cache to the swap cache.
^1da177e4c3f41 Linus Torvalds          2005-04-16  1313   */
^1da177e4c3f41 Linus Torvalds          2005-04-16  1314  static int 
shmem_writepage(struct page *page, struct writeback_control *wbc)
^1da177e4c3f41 Linus Torvalds          2005-04-16  1315  {
b5a5d07ad0bbab Matthew Wilcox (Oracle  2022-04-29 @1316)        struct folio 
*folio = page_folio(page);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1317         struct 
shmem_inode_info *info;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1318         struct 
address_space *mapping;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1319         struct inode 
*inode;
6922c0c7abd387 Hugh Dickins            2011-08-03  1320         swp_entry_t 
swap;
6922c0c7abd387 Hugh Dickins            2011-08-03  1321         pgoff_t index;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1322  
1e6decf30af5c5 Hugh Dickins            2021-09-02  1323         /*
1e6decf30af5c5 Hugh Dickins            2021-09-02  1324          * If 
/sys/kernel/mm/transparent_hugepage/shmem_enabled is "always" or
1e6decf30af5c5 Hugh Dickins            2021-09-02  1325          * "force", 
drivers/gpu/drm/i915/gem/i915_gem_shmem.c gets huge pages,
1e6decf30af5c5 Hugh Dickins            2021-09-02  1326          * and its 
shmem_writeback() needs them to be split when swapping.
1e6decf30af5c5 Hugh Dickins            2021-09-02  1327          */
1e6decf30af5c5 Hugh Dickins            2021-09-02  1328         if 
(PageTransCompound(page)) {
1e6decf30af5c5 Hugh Dickins            2021-09-02  1329                 /* 
Ensure the subpages are still dirty */
1e6decf30af5c5 Hugh Dickins            2021-09-02  1330                 
SetPageDirty(page);
1e6decf30af5c5 Hugh Dickins            2021-09-02  1331                 if 
(split_huge_page(page) < 0)
1e6decf30af5c5 Hugh Dickins            2021-09-02  1332                         
goto redirty;
1e6decf30af5c5 Hugh Dickins            2021-09-02  1333                 
ClearPageDirty(page);
1e6decf30af5c5 Hugh Dickins            2021-09-02  1334         }
1e6decf30af5c5 Hugh Dickins            2021-09-02  1335  
^1da177e4c3f41 Linus Torvalds          2005-04-16  1336         
BUG_ON(!PageLocked(page));
^1da177e4c3f41 Linus Torvalds          2005-04-16  1337         mapping = 
page->mapping;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1338         index = 
page->index;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1339         inode = 
mapping->host;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1340         info = 
SHMEM_I(inode);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1341         if (info->flags 
& VM_LOCKED)
^1da177e4c3f41 Linus Torvalds          2005-04-16  1342                 goto 
redirty;
d9fe526a83b84e Hugh Dickins            2008-02-04  1343         if 
(!total_swap_pages)
^1da177e4c3f41 Linus Torvalds          2005-04-16  1344                 goto 
redirty;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1345  
d9fe526a83b84e Hugh Dickins            2008-02-04  1346         /*
97b713ba3ebaa6 Christoph Hellwig       2015-01-14  1347          * Our 
capabilities prevent regular writeback or sync from ever calling
97b713ba3ebaa6 Christoph Hellwig       2015-01-14  1348          * 
shmem_writepage; but a stacking filesystem might use ->writepage of
97b713ba3ebaa6 Christoph Hellwig       2015-01-14  1349          * its 
underlying filesystem, in which case tmpfs should write out to
97b713ba3ebaa6 Christoph Hellwig       2015-01-14  1350          * swap only in 
response to memory pressure, and not for the writeback
97b713ba3ebaa6 Christoph Hellwig       2015-01-14  1351          * threads or 
sync.
d9fe526a83b84e Hugh Dickins            2008-02-04  1352          */
48f170fb7d7db8 Hugh Dickins            2011-07-25  1353         if 
(!wbc->for_reclaim) {
48f170fb7d7db8 Hugh Dickins            2011-07-25  1354                 
WARN_ON_ONCE(1);        /* Still happens? Tell us about it! */
48f170fb7d7db8 Hugh Dickins            2011-07-25  1355                 goto 
redirty;
48f170fb7d7db8 Hugh Dickins            2011-07-25  1356         }
1635f6a74152f1 Hugh Dickins            2012-05-29  1357  
1635f6a74152f1 Hugh Dickins            2012-05-29  1358         /*
1635f6a74152f1 Hugh Dickins            2012-05-29  1359          * This is 
somewhat ridiculous, but without plumbing a SWAP_MAP_FALLOC
1635f6a74152f1 Hugh Dickins            2012-05-29  1360          * value into 
swapfile.c, the only way we can correctly account for a
1635f6a74152f1 Hugh Dickins            2012-05-29  1361          * fallocated 
page arriving here is now to initialize it and write it.
1aac1400319d30 Hugh Dickins            2012-05-29  1362          *
1aac1400319d30 Hugh Dickins            2012-05-29  1363          * That's okay 
for a page already fallocated earlier, but if we have
1aac1400319d30 Hugh Dickins            2012-05-29  1364          * not yet 
completed the fallocation, then (a) we want to keep track
1aac1400319d30 Hugh Dickins            2012-05-29  1365          * of this page 
in case we have to undo it, and (b) it may not be a
1aac1400319d30 Hugh Dickins            2012-05-29  1366          * good idea to 
continue anyway, once we're pushing into swap.  So
1aac1400319d30 Hugh Dickins            2012-05-29  1367          * reactivate 
the page, and let shmem_fallocate() quit when too many.
1635f6a74152f1 Hugh Dickins            2012-05-29  1368          */
1635f6a74152f1 Hugh Dickins            2012-05-29  1369         if 
(!PageUptodate(page)) {
1aac1400319d30 Hugh Dickins            2012-05-29  1370                 if 
(inode->i_private) {
1aac1400319d30 Hugh Dickins            2012-05-29  1371                         
struct shmem_falloc *shmem_falloc;
1aac1400319d30 Hugh Dickins            2012-05-29  1372                         
spin_lock(&inode->i_lock);
1aac1400319d30 Hugh Dickins            2012-05-29  1373                         
shmem_falloc = inode->i_private;
1aac1400319d30 Hugh Dickins            2012-05-29  1374                         
if (shmem_falloc &&
8e205f779d1443 Hugh Dickins            2014-07-23  1375                         
    !shmem_falloc->waitq &&
1aac1400319d30 Hugh Dickins            2012-05-29  1376                         
    index >= shmem_falloc->start &&
1aac1400319d30 Hugh Dickins            2012-05-29  1377                         
    index < shmem_falloc->next)
1aac1400319d30 Hugh Dickins            2012-05-29  1378                         
        shmem_falloc->nr_unswapped++;
1aac1400319d30 Hugh Dickins            2012-05-29  1379                         
else
1aac1400319d30 Hugh Dickins            2012-05-29  1380                         
        shmem_falloc = NULL;
1aac1400319d30 Hugh Dickins            2012-05-29  1381                         
spin_unlock(&inode->i_lock);
1aac1400319d30 Hugh Dickins            2012-05-29  1382                         
if (shmem_falloc)
1aac1400319d30 Hugh Dickins            2012-05-29  1383                         
        goto redirty;
1aac1400319d30 Hugh Dickins            2012-05-29  1384                 }
1635f6a74152f1 Hugh Dickins            2012-05-29  1385                 
clear_highpage(page);
1635f6a74152f1 Hugh Dickins            2012-05-29  1386                 
flush_dcache_page(page);
1635f6a74152f1 Hugh Dickins            2012-05-29  1387                 
SetPageUptodate(page);
1635f6a74152f1 Hugh Dickins            2012-05-29  1388         }
1635f6a74152f1 Hugh Dickins            2012-05-29  1389  
b5a5d07ad0bbab Matthew Wilcox (Oracle  2022-04-29  1390)        swap = 
folio_alloc_swap(folio);
48f170fb7d7db8 Hugh Dickins            2011-07-25  1391         if (!swap.val)
48f170fb7d7db8 Hugh Dickins            2011-07-25  1392                 goto 
redirty;
d9fe526a83b84e Hugh Dickins            2008-02-04  1393  
b1dea800ac3959 Hugh Dickins            2011-05-11  1394         /*
b1dea800ac3959 Hugh Dickins            2011-05-11  1395          * Add inode to 
shmem_unuse()'s list of swapped-out inodes,
6922c0c7abd387 Hugh Dickins            2011-08-03  1396          * if it's not 
already there.  Do it now before the page is
6922c0c7abd387 Hugh Dickins            2011-08-03  1397          * moved to 
swap cache, when its pagelock no longer protects
b1dea800ac3959 Hugh Dickins            2011-05-11  1398          * the inode 
from eviction.  But don't unlock the mutex until
6922c0c7abd387 Hugh Dickins            2011-08-03  1399          * we've 
incremented swapped, because shmem_unuse_inode() will
6922c0c7abd387 Hugh Dickins            2011-08-03  1400          * prune a 
!swapped inode from the swaplist under this mutex.
b1dea800ac3959 Hugh Dickins            2011-05-11  1401          */
b1dea800ac3959 Hugh Dickins            2011-05-11  1402         
mutex_lock(&shmem_swaplist_mutex);
05bf86b4ccfd0f Hugh Dickins            2011-05-14  1403         if 
(list_empty(&info->swaplist))
b56a2d8af9147a Vineeth Remanan Pillai  2019-03-05  1404                 
list_add(&info->swaplist, &shmem_swaplist);
b1dea800ac3959 Hugh Dickins            2011-05-11  1405  
4afab1cd256e42 Yang Shi                2019-11-30  1406         if 
(add_to_swap_cache(page, swap,
3852f6768ede54 Joonsoo Kim             2020-08-11  1407                         
__GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN,
3852f6768ede54 Joonsoo Kim             2020-08-11  1408                         
NULL) == 0) {
4595ef88d13613 Kirill A. Shutemov      2016-07-26  1409                 
spin_lock_irq(&info->lock);
6922c0c7abd387 Hugh Dickins            2011-08-03  1410                 
shmem_recalc_inode(inode);
267a4c76bbdb95 Hugh Dickins            2015-12-11  1411                 
info->swapped++;
4595ef88d13613 Kirill A. Shutemov      2016-07-26  1412                 
spin_unlock_irq(&info->lock);
6922c0c7abd387 Hugh Dickins            2011-08-03  1413  
267a4c76bbdb95 Hugh Dickins            2015-12-11  1414                 
swap_shmem_alloc(swap);
267a4c76bbdb95 Hugh Dickins            2015-12-11  1415                 
shmem_delete_from_page_cache(page, swp_to_radix_entry(swap));
267a4c76bbdb95 Hugh Dickins            2015-12-11  1416  
6922c0c7abd387 Hugh Dickins            2011-08-03  1417                 
mutex_unlock(&shmem_swaplist_mutex);
d9fe526a83b84e Hugh Dickins            2008-02-04  1418                 
BUG_ON(page_mapped(page));
9fab5619bdd7f8 Hugh Dickins            2009-03-31  1419                 
swap_writepage(page, wbc);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1420                 return 
0;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1421         }
^1da177e4c3f41 Linus Torvalds          2005-04-16  1422  
6922c0c7abd387 Hugh Dickins            2011-08-03  1423         
mutex_unlock(&shmem_swaplist_mutex);
75f6d6d29a40b5 Minchan Kim             2017-07-06  1424         
put_swap_page(page, swap);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1425  redirty:
^1da177e4c3f41 Linus Torvalds          2005-04-16  1426         
set_page_dirty(page);
d9fe526a83b84e Hugh Dickins            2008-02-04  1427         if 
(wbc->for_reclaim)
d9fe526a83b84e Hugh Dickins            2008-02-04  1428                 return 
AOP_WRITEPAGE_ACTIVATE;  /* Return with page locked */
d9fe526a83b84e Hugh Dickins            2008-02-04  1429         
unlock_page(page);
d9fe526a83b84e Hugh Dickins            2008-02-04  1430         return 0;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1431  }
^1da177e4c3f41 Linus Torvalds          2005-04-16  1432  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to