Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vmstat: Remove BUG_ON from vmstat_update

If we detect that there is nothing to do just set the flag and do not
check if it was already set before. Races really do not matter. If the
flag is set by any code then the shepherd will start dealing with the
situation and reenable the vmstat workers when necessary again.

Since commit 0eb77e988032 ("vmstat: make vmstat_updater deferrable again
and shut down on idle") quiet_vmstat might update cpu_stat_off and mark
a particular cpu to be handled by vmstat_shepherd. This might trigger a
VM_BUG_ON in vmstat_update because the work item might have been
sleeping during the idle period and see the cpu_stat_off updated after
the wake up. The VM_BUG_ON is therefore misleading and no more
appropriate. Moreover it doesn't really suite any protection from real
bugs because vmstat_shepherd will simply reschedule the vmstat_work
anytime it sees a particular cpu set or vmstat_update would do the same
from the worker context directly. Even when the two would race the
result wouldn't be incorrect as the counters update is fully idempotent.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christoph Lameter and committed by
Linus Torvalds
587198ba 048ccca8

+1 -11
+1 -11
mm/vmstat.c
··· 1408 1408 * Defer the checking for differentials to the 1409 1409 * shepherd thread on a different processor. 1410 1410 */ 1411 - int r; 1412 - /* 1413 - * Shepherd work thread does not race since it never 1414 - * changes the bit if its zero but the cpu 1415 - * online / off line code may race if 1416 - * worker threads are still allowed during 1417 - * shutdown / startup. 1418 - */ 1419 - r = cpumask_test_and_set_cpu(smp_processor_id(), 1420 - cpu_stat_off); 1421 - VM_BUG_ON(r); 1411 + cpumask_set_cpu(smp_processor_id(), cpu_stat_off); 1422 1412 } 1423 1413 } 1424 1414