[linux-next:master 7462/8237] mm/shmem.c:1761:12: warning: 'folio' is used uninitialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   44a2f39e611ac0bc1f17c288a583d7f2e5684aa7
commit: 2b58b3f33ba268c00aa7181e203c58fab6661751 [7462/8237] mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio()
config: sparc-randconfig-c023-20220501 (https://download.01.org/0day-ci/archive/20220504/202205040154.ijA4ofuQ-lkp@xxxxxxxxx/config)
compiler: sparc-linux-gcc (GCC) 11.3.0
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
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=2b58b3f33ba268c00aa7181e203c58fab6661751
        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 2b58b3f33ba268c00aa7181e203c58fab6661751
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   mm/shmem.c: In function 'shmem_swapin_folio.constprop':
>> mm/shmem.c:1761:12: warning: 'folio' is used uninitialized [-Wuninitialized]
    1761 |         if (folio) {
         |            ^
   In file included from <command-line>:
   mm/shmem.c: In function 'shmem_add_to_page_cache.constprop':
   include/linux/compiler_types.h:352:45: error: call to '__compiletime_assert_256' declared with attribute error: BUILD_BUG failed
     352 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:333:25: note: in definition of macro '__compiletime_assert'
     333 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:352:9: note: in expansion of macro '_compiletime_assert'
     352 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:59:21: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^~~~~~~~~~~~~~~~
   include/linux/vm_event_item.h:147:27: note: in expansion of macro 'BUILD_BUG'
     147 | #define THP_FILE_ALLOC ({ BUILD_BUG(); 0; })
         |                           ^~~~~~~~~
   mm/shmem.c:743:40: note: in expansion of macro 'THP_FILE_ALLOC'
     743 |                         count_vm_event(THP_FILE_ALLOC);
         |                                        ^~~~~~~~~~~~~~
   In file included from include/linux/math64.h:6,
                    from include/linux/time64.h:5,
                    from include/linux/restart_block.h:10,
                    from include/linux/thread_info.h:14,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/sparc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:55,
                    from include/linux/wait.h:9,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from mm/shmem.c:24:
   mm/shmem.c: In function 'shmem_getpage_gfp':
   include/linux/compiler_types.h:352:45: error: call to '__compiletime_assert_264' declared with attribute error: BUILD_BUG failed
     352 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/math.h:15:46: note: in definition of macro '__round_mask'
      15 | #define __round_mask(x, y) ((__typeof__(x))((y)-1))
         |                                              ^
   mm/shmem.c:1892:26: note: in expansion of macro 'round_down'
    1892 |                 hindex = round_down(index, HPAGE_PMD_NR);
         |                          ^~~~~~~~~~
   include/linux/compiler_types.h:340:9: note: in expansion of macro '__compiletime_assert'
     340 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:352:9: note: in expansion of macro '_compiletime_assert'
     352 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:59:21: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^~~~~~~~~~~~~~~~
   include/linux/huge_mm.h:307:28: note: in expansion of macro 'BUILD_BUG'
     307 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
         |                            ^~~~~~~~~
   include/linux/huge_mm.h:105:26: note: in expansion of macro 'HPAGE_PMD_SHIFT'
     105 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
         |                          ^~~~~~~~~~~~~~~
   include/linux/huge_mm.h:106:26: note: in expansion of macro 'HPAGE_PMD_ORDER'
     106 | #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
         |                          ^~~~~~~~~~~~~~~
   mm/shmem.c:1892:44: note: in expansion of macro 'HPAGE_PMD_NR'
    1892 |                 hindex = round_down(index, HPAGE_PMD_NR);
         |                                            ^~~~~~~~~~~~
   In file included from <command-line>:
   include/linux/compiler_types.h:352:45: error: call to '__compiletime_assert_265' declared with attribute error: BUILD_BUG failed
     352 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:333:25: note: in definition of macro '__compiletime_assert'
     333 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:352:9: note: in expansion of macro '_compiletime_assert'
     352 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:59:21: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^~~~~~~~~~~~~~~~
   include/linux/huge_mm.h:307:28: note: in expansion of macro 'BUILD_BUG'
     307 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
         |                            ^~~~~~~~~
   include/linux/huge_mm.h:105:26: note: in expansion of macro 'HPAGE_PMD_SHIFT'
     105 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
         |                          ^~~~~~~~~~~~~~~
   include/linux/huge_mm.h:106:26: note: in expansion of macro 'HPAGE_PMD_ORDER'
     106 | #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
         |                          ^~~~~~~~~~~~~~~
   mm/shmem.c:1915:34: note: in expansion of macro 'HPAGE_PMD_NR'
    1915 |                         hindex + HPAGE_PMD_NR - 1) {
         |                                  ^~~~~~~~~~~~


vim +/folio +1761 mm/shmem.c

  1669	
  1670	/*
  1671	 * Swap in the page pointed to by *pagep.
  1672	 * Caller has to make sure that *pagep contains a valid swapped page.
  1673	 * Returns 0 and the page in pagep if success. On failure, returns the
  1674	 * error code and NULL in *pagep.
  1675	 */
  1676	static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
  1677				     struct folio **foliop, enum sgp_type sgp,
  1678				     gfp_t gfp, struct vm_area_struct *vma,
  1679				     vm_fault_t *fault_type)
  1680	{
  1681		struct address_space *mapping = inode->i_mapping;
  1682		struct shmem_inode_info *info = SHMEM_I(inode);
  1683		struct mm_struct *charge_mm = vma ? vma->vm_mm : NULL;
  1684		struct page *page;
  1685		struct folio *folio;
  1686		swp_entry_t swap;
  1687		int error;
  1688	
  1689		VM_BUG_ON(!*foliop || !xa_is_value(*foliop));
  1690		swap = radix_to_swp_entry(*foliop);
  1691		*foliop = NULL;
  1692	
  1693		/* Look it up and read it in.. */
  1694		page = lookup_swap_cache(swap, NULL, 0);
  1695		if (!page) {
  1696			/* Or update major stats only when swapin succeeds?? */
  1697			if (fault_type) {
  1698				*fault_type |= VM_FAULT_MAJOR;
  1699				count_vm_event(PGMAJFAULT);
  1700				count_memcg_event_mm(charge_mm, PGMAJFAULT);
  1701			}
  1702			/* Here we actually start the io */
  1703			page = shmem_swapin(swap, gfp, info, index);
  1704			if (!page) {
  1705				error = -ENOMEM;
  1706				goto failed;
  1707			}
  1708		}
  1709		folio = page_folio(page);
  1710	
  1711		/* We have to do this with page locked to prevent races */
  1712		folio_lock(folio);
  1713		if (!folio_test_swapcache(folio) ||
  1714		    folio_swap_entry(folio).val != swap.val ||
  1715		    !shmem_confirm_swap(mapping, index, swap)) {
  1716			error = -EEXIST;
  1717			goto unlock;
  1718		}
  1719		if (!folio_test_uptodate(folio)) {
  1720			error = -EIO;
  1721			goto failed;
  1722		}
  1723		folio_wait_writeback(folio);
  1724	
  1725		/*
  1726		 * Some architectures may have to restore extra metadata to the
  1727		 * folio after reading from swap.
  1728		 */
  1729		arch_swap_restore(swap, folio);
  1730	
  1731		if (shmem_should_replace_folio(folio, gfp)) {
  1732			error = shmem_replace_page(&page, gfp, info, index);
  1733			if (error)
  1734				goto failed;
  1735		}
  1736	
  1737		error = shmem_add_to_page_cache(folio, mapping, index,
  1738						swp_to_radix_entry(swap), gfp,
  1739						charge_mm);
  1740		if (error)
  1741			goto failed;
  1742	
  1743		spin_lock_irq(&info->lock);
  1744		info->swapped--;
  1745		shmem_recalc_inode(inode);
  1746		spin_unlock_irq(&info->lock);
  1747	
  1748		if (sgp == SGP_WRITE)
  1749			folio_mark_accessed(folio);
  1750	
  1751		delete_from_swap_cache(&folio->page);
  1752		folio_mark_dirty(folio);
  1753		swap_free(swap);
  1754	
  1755		*foliop = folio;
  1756		return 0;
  1757	failed:
  1758		if (!shmem_confirm_swap(mapping, index, swap))
  1759			error = -EEXIST;
  1760	unlock:
> 1761		if (folio) {
  1762			folio_unlock(folio);
  1763			folio_put(folio);
  1764		}
  1765	
  1766		return error;
  1767	}
  1768	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux