* [bug report] mm/mglru: fix underprotected page cache
@ 2024-01-12 7:13 Dan Carpenter
2024-01-12 7:42 ` Yu Zhao
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-01-12 7:13 UTC (permalink / raw)
To: yuzhao; +Cc: linux-mm
Hello Yu Zhao,
The patch 081488051d28: "mm/mglru: fix underprotected page cache"
from Dec 7, 2023 (linux-next), leads to the following Smatch static
checker warning:
mm/workingset.c:318 lru_gen_refault()
warn: always true condition '(refs >= ((((1))) << (__builtin_choose_expr((4 == 4), (((2) < (64 - 26 - 3 - 3 - 0 - 10 - 0 - (8 + 14))) ?(2):(64 - 26 - 3 - 3 - 0 - 10 - 0 - (8 + 14))), ))) - 1) => (s32min-s32max >= 0)'
mm/workingset.c
308 atomic_long_add(delta, &lrugen->refaulted[hist][type][tier]);
309 mod_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + type, delta);
310
311 /*
312 * Count the following two cases as stalls:
313 * 1. For pages accessed through page tables, hotter pages pushed out
314 * hot pages which refaulted immediately.
315 * 2. For pages accessed multiple times through file descriptors,
316 * they would have been protected by sort_folio().
317 */
--> 318 if (lru_gen_in_fault() || refs >= BIT(LRU_REFS_WIDTH) - 1) {
^^^^^^^^^^^^^^^^^^^^^^^
In my x86 allmodconfig this is zero and refs is always >= 0. This could
be intentional, but I thought it was worth checking.
319 set_mask_bits(&folio->flags, 0, LRU_REFS_MASK | BIT(PG_workingset));
320 mod_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + type, delta);
321 }
322 unlock:
323 rcu_read_unlock();
324 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] mm/mglru: fix underprotected page cache
2024-01-12 7:13 [bug report] mm/mglru: fix underprotected page cache Dan Carpenter
@ 2024-01-12 7:42 ` Yu Zhao
2024-01-12 8:29 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Yu Zhao @ 2024-01-12 7:42 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-mm
On Fri, Jan 12, 2024 at 12:13 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Hello Yu Zhao,
>
> The patch 081488051d28: "mm/mglru: fix underprotected page cache"
> from Dec 7, 2023 (linux-next), leads to the following Smatch static
> checker warning:
>
> mm/workingset.c:318 lru_gen_refault()
> warn: always true condition '(refs >= ((((1))) << (__builtin_choose_expr((4 == 4), (((2) < (64 - 26 - 3 - 3 - 0 - 10 - 0 - (8 + 14))) ?(2):(64 - 26 - 3 - 3 - 0 - 10 - 0 - (8 + 14))), ))) - 1) => (s32min-s32max >= 0)'
>
> mm/workingset.c
> 308 atomic_long_add(delta, &lrugen->refaulted[hist][type][tier]);
> 309 mod_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + type, delta);
> 310
> 311 /*
> 312 * Count the following two cases as stalls:
> 313 * 1. For pages accessed through page tables, hotter pages pushed out
> 314 * hot pages which refaulted immediately.
> 315 * 2. For pages accessed multiple times through file descriptors,
> 316 * they would have been protected by sort_folio().
> 317 */
> --> 318 if (lru_gen_in_fault() || refs >= BIT(LRU_REFS_WIDTH) - 1) {
> ^^^^^^^^^^^^^^^^^^^^^^^
> In my x86 allmodconfig this is zero and refs is always >= 0. This could
> be intentional, but I thought it was worth checking.
Appreciate the manual work!
This indeed is intentional if LRU_REFS_WIDTH is 0. What would be the
best way to suppress this warning?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] mm/mglru: fix underprotected page cache
2024-01-12 7:42 ` Yu Zhao
@ 2024-01-12 8:29 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-01-12 8:29 UTC (permalink / raw)
To: Yu Zhao; +Cc: linux-mm
On Fri, Jan 12, 2024 at 12:42:37AM -0700, Yu Zhao wrote:
> On Fri, Jan 12, 2024 at 12:13 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > Hello Yu Zhao,
> >
> > The patch 081488051d28: "mm/mglru: fix underprotected page cache"
> > from Dec 7, 2023 (linux-next), leads to the following Smatch static
> > checker warning:
> >
> > mm/workingset.c:318 lru_gen_refault()
> > warn: always true condition '(refs >= ((((1))) << (__builtin_choose_expr((4 == 4), (((2) < (64 - 26 - 3 - 3 - 0 - 10 - 0 - (8 + 14))) ?(2):(64 - 26 - 3 - 3 - 0 - 10 - 0 - (8 + 14))), ))) - 1) => (s32min-s32max >= 0)'
> >
> > mm/workingset.c
> > 308 atomic_long_add(delta, &lrugen->refaulted[hist][type][tier]);
> > 309 mod_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + type, delta);
> > 310
> > 311 /*
> > 312 * Count the following two cases as stalls:
> > 313 * 1. For pages accessed through page tables, hotter pages pushed out
> > 314 * hot pages which refaulted immediately.
> > 315 * 2. For pages accessed multiple times through file descriptors,
> > 316 * they would have been protected by sort_folio().
> > 317 */
> > --> 318 if (lru_gen_in_fault() || refs >= BIT(LRU_REFS_WIDTH) - 1) {
> > ^^^^^^^^^^^^^^^^^^^^^^^
> > In my x86 allmodconfig this is zero and refs is always >= 0. This could
> > be intentional, but I thought it was worth checking.
>
> Appreciate the manual work!
>
> This indeed is intentional if LRU_REFS_WIDTH is 0. What would be the
> best way to suppress this warning?
No need.
These warnings are a one time thing. Ignore the false positives. If
people are curious in the future they can find this conversation on
lore.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-12 8:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12 7:13 [bug report] mm/mglru: fix underprotected page cache Dan Carpenter
2024-01-12 7:42 ` Yu Zhao
2024-01-12 8:29 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox