Rafael Aquini 7a9a0be1be percpu: fix race on alloc failed warning limit
JIRA: https://redhat.atlassian.net/browse/RHEL-145695

commit 7989fdce69ec0a928e136477da2aa208a191fba2
Author: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Date:   Fri Aug 22 15:55:16 2025 -0700

    percpu: fix race on alloc failed warning limit

    The 'allocation failed, ...' warning messages can cause unlimited log
    spam, contrary to the implementation's intent.

    The warn_limit variable is accessed without synchronization.  If more than
    <warn_limit> threads enter the warning path at the same time, the variable
    will get decremented past 0.  Once it becomes negative, the non-zero check
    will always return true leading to unlimited log spam.

    Use atomic operation to access warn_limit and change condition to test for
    non-negative (>= 0) - atomic_dec_if_positive will return -1 once
    warn_limit becomes 0.  Continue to print disable message alongside the
    last warning.

    While the change cited in Fixes is only adjacent, the warning limit
    implementation was correct before it.  Only non-atomic allocations were
    considered for warnings, and those happened to hold pcpu_alloc_mutex while
    accessing warn_limit.

    [vdumitrescu@nvidia.com: prevent warn_limit from going negative, per Christoph Lameter]
      Link: https://lkml.kernel.org/r/ee87cc59-2717-4dbb-8052-1d2692c5aaaa@nvidia.com
    Link: https://lkml.kernel.org/r/ab22061a-a62f-4429-945b-744e5cc4ba35@nvidia.com
    Fixes: f7d77dfc91 ("mm/percpu.c: print error message too if atomic alloc failed")
    Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
    Reviewed-by: Baoquan He <bhe@redhat.com>
    Cc: Christoph Lameter (Ampere) <cl@gentwo.org>
    Cc: Dennis Zhou <dennis@kernel.org>
    Cc: Tejun Heo <tj@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Rafael Aquini <raquini@redhat.com>
2026-07-31 14:51:03 -04:00
2026-07-31 14:50:55 -04:00
2026-07-01 16:16:28 -04:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.
S
Description
No description provided
Readme
2.8 GiB
Languages
C 97.5%
Assembly 1%
Shell 0.6%
Python 0.3%
Makefile 0.3%