All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [openeuler:OLK-6.6 1351/1351] mm/page_alloc.c:4591 check_after_alloc() warn: bitwise AND condition is false here
Date: Tue, 5 Nov 2024 18:44:11 +0800	[thread overview]
Message-ID: <202411052003.6oqMloey-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Wupeng Ma <mawupeng1@huawei.com>

tree:   https://gitee.com/openeuler/kernel.git OLK-6.6
head:   93af945a84362704003ed46f6c5068cb8a7ee60a
commit: 200321e8a69ef82350d070de35ac4a666ab79ba6 [1351/1351] mm: mem_reliable: Add limiting the usage of reliable memory
:::::: branch date: 5 hours ago
:::::: commit date: 10 months ago
config: x86_64-randconfig-161-20241103 (https://download.01.org/0day-ci/archive/20241105/202411052003.6oqMloey-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202411052003.6oqMloey-lkp@intel.com/

smatch warnings:
mm/page_alloc.c:4591 check_after_alloc() warn: bitwise AND condition is false here

vim +4591 mm/page_alloc.c

200321e8a69ef8 Ma Wupeng 2024-01-10  4575  
200321e8a69ef8 Ma Wupeng 2024-01-10  4576  /*
200321e8a69ef8 Ma Wupeng 2024-01-10  4577   * return true means memory allocation need retry and flag GFP_RELIABLE
200321e8a69ef8 Ma Wupeng 2024-01-10  4578   * must be cleared.
200321e8a69ef8 Ma Wupeng 2024-01-10  4579   */
200321e8a69ef8 Ma Wupeng 2024-01-10  4580  static inline bool check_after_alloc(gfp_t *gfp, unsigned int order,
200321e8a69ef8 Ma Wupeng 2024-01-10  4581  				     int preferred_nid,
200321e8a69ef8 Ma Wupeng 2024-01-10  4582  				     struct alloc_context *ac,
200321e8a69ef8 Ma Wupeng 2024-01-10  4583  				     struct page **_page)
200321e8a69ef8 Ma Wupeng 2024-01-10  4584  {
200321e8a69ef8 Ma Wupeng 2024-01-10  4585  	int retry_times = MAX_RECLAIM_RETRIES;
200321e8a69ef8 Ma Wupeng 2024-01-10  4586  	int nr_pages;
200321e8a69ef8 Ma Wupeng 2024-01-10  4587  
200321e8a69ef8 Ma Wupeng 2024-01-10  4588  	if (!mem_reliable_is_enabled())
200321e8a69ef8 Ma Wupeng 2024-01-10  4589  		return false;
200321e8a69ef8 Ma Wupeng 2024-01-10  4590  
200321e8a69ef8 Ma Wupeng 2024-01-10 @4591  	if (!(*gfp & GFP_RELIABLE))
200321e8a69ef8 Ma Wupeng 2024-01-10  4592  		return false;
200321e8a69ef8 Ma Wupeng 2024-01-10  4593  
200321e8a69ef8 Ma Wupeng 2024-01-10  4594  	if (!*_page)
200321e8a69ef8 Ma Wupeng 2024-01-10  4595  		goto out_retry;
200321e8a69ef8 Ma Wupeng 2024-01-10  4596  
200321e8a69ef8 Ma Wupeng 2024-01-10  4597  	if (*gfp & __GFP_NOFAIL || current->flags & PF_MEMALLOC)
200321e8a69ef8 Ma Wupeng 2024-01-10  4598  		goto out;
200321e8a69ef8 Ma Wupeng 2024-01-10  4599  
200321e8a69ef8 Ma Wupeng 2024-01-10  4600  	/* percpu counter is not initialized, ignore limit check */
200321e8a69ef8 Ma Wupeng 2024-01-10  4601  	if (!mem_reliable_counter_initialized())
200321e8a69ef8 Ma Wupeng 2024-01-10  4602  		goto out;
200321e8a69ef8 Ma Wupeng 2024-01-10  4603  
200321e8a69ef8 Ma Wupeng 2024-01-10  4604  limit_check:
200321e8a69ef8 Ma Wupeng 2024-01-10  4605  	/* user task is limited by task_reliable_limit */
200321e8a69ef8 Ma Wupeng 2024-01-10  4606  	if (!reliable_mem_limit_check(1 << order))
200321e8a69ef8 Ma Wupeng 2024-01-10  4607  		goto out_free_page;
200321e8a69ef8 Ma Wupeng 2024-01-10  4608  
200321e8a69ef8 Ma Wupeng 2024-01-10  4609  	goto out;
200321e8a69ef8 Ma Wupeng 2024-01-10  4610  
200321e8a69ef8 Ma Wupeng 2024-01-10  4611  out_free_page:
200321e8a69ef8 Ma Wupeng 2024-01-10  4612  	if (mem_reliable_should_reclaim() && retry_times--) {
200321e8a69ef8 Ma Wupeng 2024-01-10  4613  		nr_pages = mem_reliable_direct_reclaim(1 << order, ac);
200321e8a69ef8 Ma Wupeng 2024-01-10  4614  		if (nr_pages)
200321e8a69ef8 Ma Wupeng 2024-01-10  4615  			goto limit_check;
200321e8a69ef8 Ma Wupeng 2024-01-10  4616  	}
200321e8a69ef8 Ma Wupeng 2024-01-10  4617  
200321e8a69ef8 Ma Wupeng 2024-01-10  4618  	__free_pages(*_page, order);
200321e8a69ef8 Ma Wupeng 2024-01-10  4619  	*_page = NULL;
200321e8a69ef8 Ma Wupeng 2024-01-10  4620  
200321e8a69ef8 Ma Wupeng 2024-01-10  4621  out_retry:
200321e8a69ef8 Ma Wupeng 2024-01-10  4622  	if (is_global_init(current)) {
200321e8a69ef8 Ma Wupeng 2024-01-10  4623  		*gfp &= ~GFP_RELIABLE;
200321e8a69ef8 Ma Wupeng 2024-01-10  4624  		return true;
200321e8a69ef8 Ma Wupeng 2024-01-10  4625  	}
200321e8a69ef8 Ma Wupeng 2024-01-10  4626  
200321e8a69ef8 Ma Wupeng 2024-01-10  4627  	if (*gfp & (__GFP_NORETRY | __GFP_RETRY_MAYFAIL | __GFP_THISNODE))
200321e8a69ef8 Ma Wupeng 2024-01-10  4628  		goto out;
200321e8a69ef8 Ma Wupeng 2024-01-10  4629  
200321e8a69ef8 Ma Wupeng 2024-01-10  4630  	/* Coredumps can quickly deplete all memory reserves */
200321e8a69ef8 Ma Wupeng 2024-01-10  4631  	if (current->flags & PF_DUMPCORE)
200321e8a69ef8 Ma Wupeng 2024-01-10  4632  		goto out;
200321e8a69ef8 Ma Wupeng 2024-01-10  4633  	/* The OOM killer will not help higher order allocs */
200321e8a69ef8 Ma Wupeng 2024-01-10  4634  	if (order > PAGE_ALLOC_COSTLY_ORDER)
200321e8a69ef8 Ma Wupeng 2024-01-10  4635  		goto out;
200321e8a69ef8 Ma Wupeng 2024-01-10  4636  
200321e8a69ef8 Ma Wupeng 2024-01-10  4637  	/* oom here */
200321e8a69ef8 Ma Wupeng 2024-01-10  4638  	mem_reliable_out_of_memory(*gfp, order, preferred_nid, ac->nodemask);
200321e8a69ef8 Ma Wupeng 2024-01-10  4639  out:
200321e8a69ef8 Ma Wupeng 2024-01-10  4640  	return false;
200321e8a69ef8 Ma Wupeng 2024-01-10  4641  }
200321e8a69ef8 Ma Wupeng 2024-01-10  4642  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2024-11-05 10:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202411052003.6oqMloey-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.