From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org
Cc: lkp@intel.com, kbuild-all@lists.01.org, linux-mm@kvack.org,
Wei Yang <richard.weiyang@gmail.com>,
Mel Gorman <mgorman@suse.de>, Daero Lee <skseofh@gmail.com>
Subject: Re: [PATCH] mm/vmscan: reduce double-check if kswapd is not able to sleep
Date: Mon, 24 Oct 2022 10:04:31 +0300 [thread overview]
Message-ID: <202210231820.4uiXIJeC-lkp@intel.com> (raw)
In-Reply-To: <20221023080431.30893-1-richard.weiyang@gmail.com>
Hi Wei,
url: https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/mm-vmscan-reduce-double-check-if-kswapd-is-not-able-to-sleep/20221023-160625
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20221023080431.30893-1-richard.weiyang%40gmail.com
patch subject: [PATCH] mm/vmscan: reduce double-check if kswapd is not able to sleep
config: microblaze-randconfig-m041-20221023
compiler: microblaze-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
mm/vmscan.c:7261 kswapd_try_to_sleep() error: uninitialized symbol 'remaining'.
vim +/remaining +7261 mm/vmscan.c
38087d9b036098 Mel Gorman 2016-07-28 7179 static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
97a225e69a1f88 Joonsoo Kim 2020-06-03 7180 unsigned int highest_zoneidx)
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7181 {
de349a300443b3 Wei Yang 2022-10-23 7182 long remaining;
de349a300443b3 Wei Yang 2022-10-23 7183 bool can_sleep;
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7184 DEFINE_WAIT(wait);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7185
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7186 if (freezing(current) || kthread_should_stop())
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7187 return;
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7188
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7189 prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7190
333b0a459c0e1b Shantanu Goel 2017-05-03 7191 /*
333b0a459c0e1b Shantanu Goel 2017-05-03 7192 * Try to sleep for a short interval. Note that kcompactd will only be
333b0a459c0e1b Shantanu Goel 2017-05-03 7193 * woken if it is possible to sleep for a short interval. This is
333b0a459c0e1b Shantanu Goel 2017-05-03 7194 * deliberate on the assumption that if reclaim cannot keep an
333b0a459c0e1b Shantanu Goel 2017-05-03 7195 * eligible zone balanced that it's also unlikely that compaction will
333b0a459c0e1b Shantanu Goel 2017-05-03 7196 * succeed.
333b0a459c0e1b Shantanu Goel 2017-05-03 7197 */
de349a300443b3 Wei Yang 2022-10-23 7198 can_sleep = prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx);
de349a300443b3 Wei Yang 2022-10-23 7199 if (can_sleep) {
fd901c95388b3b Vlastimil Babka 2016-04-28 7200 /*
fd901c95388b3b Vlastimil Babka 2016-04-28 7201 * Compaction records what page blocks it recently failed to
fd901c95388b3b Vlastimil Babka 2016-04-28 7202 * isolate pages from and skips them in the future scanning.
fd901c95388b3b Vlastimil Babka 2016-04-28 7203 * When kswapd is going to sleep, it is reasonable to assume
fd901c95388b3b Vlastimil Babka 2016-04-28 7204 * that pages and compaction may succeed so reset the cache.
fd901c95388b3b Vlastimil Babka 2016-04-28 7205 */
fd901c95388b3b Vlastimil Babka 2016-04-28 7206 reset_isolation_suitable(pgdat);
fd901c95388b3b Vlastimil Babka 2016-04-28 7207
fd901c95388b3b Vlastimil Babka 2016-04-28 7208 /*
fd901c95388b3b Vlastimil Babka 2016-04-28 7209 * We have freed the memory, now we should compact it to make
fd901c95388b3b Vlastimil Babka 2016-04-28 7210 * allocation of the requested order possible.
fd901c95388b3b Vlastimil Babka 2016-04-28 7211 */
97a225e69a1f88 Joonsoo Kim 2020-06-03 7212 wakeup_kcompactd(pgdat, alloc_order, highest_zoneidx);
fd901c95388b3b Vlastimil Babka 2016-04-28 7213
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7214 remaining = schedule_timeout(HZ/10);
"remaining" only set when can_sleep is true.
38087d9b036098 Mel Gorman 2016-07-28 7215
38087d9b036098 Mel Gorman 2016-07-28 7216 /*
97a225e69a1f88 Joonsoo Kim 2020-06-03 7217 * If woken prematurely then reset kswapd_highest_zoneidx and
38087d9b036098 Mel Gorman 2016-07-28 7218 * order. The values will either be from a wakeup request or
38087d9b036098 Mel Gorman 2016-07-28 7219 * the previous request that slept prematurely.
38087d9b036098 Mel Gorman 2016-07-28 7220 */
38087d9b036098 Mel Gorman 2016-07-28 7221 if (remaining) {
97a225e69a1f88 Joonsoo Kim 2020-06-03 7222 WRITE_ONCE(pgdat->kswapd_highest_zoneidx,
97a225e69a1f88 Joonsoo Kim 2020-06-03 7223 kswapd_highest_zoneidx(pgdat,
97a225e69a1f88 Joonsoo Kim 2020-06-03 7224 highest_zoneidx));
5644e1fbbfe15a Qian Cai 2020-04-01 7225
5644e1fbbfe15a Qian Cai 2020-04-01 7226 if (READ_ONCE(pgdat->kswapd_order) < reclaim_order)
5644e1fbbfe15a Qian Cai 2020-04-01 7227 WRITE_ONCE(pgdat->kswapd_order, reclaim_order);
de349a300443b3 Wei Yang 2022-10-23 7228 can_sleep = false;
de349a300443b3 Wei Yang 2022-10-23 7229 } else {
de349a300443b3 Wei Yang 2022-10-23 7230 can_sleep = prepare_kswapd_sleep(pgdat, reclaim_order,
de349a300443b3 Wei Yang 2022-10-23 7231 highest_zoneidx);
38087d9b036098 Mel Gorman 2016-07-28 7232 }
38087d9b036098 Mel Gorman 2016-07-28 7233
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7234 finish_wait(&pgdat->kswapd_wait, &wait);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7235 prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7236 }
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7237
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7238 /*
de349a300443b3 Wei Yang 2022-10-23 7239 * If kswapd is fine to sleep, restore vmstat thresholds and kswapd
de349a300443b3 Wei Yang 2022-10-23 7240 * goes to sleep.
de349a300443b3 Wei Yang 2022-10-23 7241 * If not, account whether the low or high watermark was hit quickly.
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7242 */
de349a300443b3 Wei Yang 2022-10-23 7243 if (can_sleep) {
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7244 trace_mm_vmscan_kswapd_sleep(pgdat->node_id);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7245
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7246 /*
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7247 * vmstat counters are not perfectly accurate and the estimated
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7248 * value for counters such as NR_FREE_PAGES can deviate from the
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7249 * true value by nr_online_cpus * threshold. To avoid the zone
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7250 * watermarks being breached while under pressure, we reduce the
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7251 * per-cpu vmstat threshold while kswapd is awake and restore
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7252 * them before going back to sleep.
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7253 */
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7254 set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold);
1c7e7f6c0703d0 Aaditya Kumar 2012-07-17 7255
1c7e7f6c0703d0 Aaditya Kumar 2012-07-17 7256 if (!kthread_should_stop())
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7257 schedule();
1c7e7f6c0703d0 Aaditya Kumar 2012-07-17 7258
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7259 set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7260 } else {
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 @7261 if (remaining)
Uninitialized here.
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7262 count_vm_event(KSWAPD_LOW_WMARK_HIT_QUICKLY);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7263 else
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7264 count_vm_event(KSWAPD_HIGH_WMARK_HIT_QUICKLY);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7265 }
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7266 finish_wait(&pgdat->kswapd_wait, &wait);
f0bc0a60b13f20 KOSAKI Motohiro 2011-01-13 7267 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
next prev parent reply other threads:[~2022-10-24 7:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-23 8:04 [PATCH] mm/vmscan: reduce double-check if kswapd is not able to sleep Wei Yang
2022-10-23 13:11 ` Wei Yang
2022-10-24 7:04 ` Dan Carpenter [this message]
2022-10-24 8:32 ` Wei Yang
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=202210231820.4uiXIJeC-lkp@intel.com \
--to=dan.carpenter@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=mgorman@suse.de \
--cc=richard.weiyang@gmail.com \
--cc=skseofh@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).