From: Wan Jiabing <wanjiabing@vivo.com>
To: Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: kael_w@yeah.net, Wan Jiabing <wanjiabing@vivo.com>
Subject: [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated
Date: Fri, 18 Jun 2021 23:14:36 +0800 [thread overview]
Message-ID: <20210618151436.38217-1-wanjiabing@vivo.com> (raw)
Fix coccicheck warning:
./mm/percpu.c:2045:19-29: ERROR: function pcpu_balance_populated
called on line 2232 inside lock on line 2228 but uses GFP_KERNEL
When pcpu_balance_populated() is called in pcpu_balance_workfn(),
it helds spin_lock but use GFP_KERNEL to alloc mem, which is unsafe.
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
mm/percpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index b4cebeca4c0c..4031f32e6975 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -2042,7 +2042,7 @@ static void pcpu_balance_free(bool empty_only)
static void pcpu_balance_populated(void)
{
/* gfp flags passed to underlying allocators */
- const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
+ const gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
struct pcpu_chunk *chunk;
int slot, nr_to_pop, ret;
--
2.30.2
next reply other threads:[~2021-06-18 15:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 15:14 Wan Jiabing [this message]
2021-06-18 18:20 ` [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated Dennis Zhou
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=20210618151436.38217-1-wanjiabing@vivo.com \
--to=wanjiabing@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=kael_w@yeah.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
/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).