From patchwork Fri Jun 18 15:14:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiabing Wan X-Patchwork-Id: 12331605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 228CDC48BDF for ; Fri, 18 Jun 2021 15:15:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B9E1D6127C for ; Fri, 18 Jun 2021 15:15:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9E1D6127C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vivo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 540516B007D; Fri, 18 Jun 2021 11:15:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F1206B007E; Fri, 18 Jun 2021 11:15:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36A356B0080; Fri, 18 Jun 2021 11:15:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id F3FD16B007D for ; Fri, 18 Jun 2021 11:15:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7C66C181AC9CB for ; Fri, 18 Jun 2021 15:15:01 +0000 (UTC) X-FDA: 78267192402.04.5E98407 Received: from mail-m121144.qiye.163.com (mail-m121144.qiye.163.com [115.236.121.144]) by imf22.hostedemail.com (Postfix) with SMTP id 3BCADC0201E5 for ; Fri, 18 Jun 2021 15:14:56 +0000 (UTC) DKIM-Signature: a=rsa-sha256; b=Bz0r8uYyPM98aHAe5UMPi4gZvyNYM1hyGSpqr5L/MeQ6Q3znO7eCvOwMco0C4DKvdXpdlnlArpG1HrGJy+M1SgqY9PVNjUJeJLGT6Huvwd3L3xqfD5oJkuy0Mu0MZYN2FgdDvt6K9dcBoGHJW8TNS+rc2RwNmXHJ2obC4zyK3WI=; c=relaxed/relaxed; s=default; d=vivo.com; v=1; bh=WUFv4LRD+NHrRC3a1phX1cKlBvVWd+7I1lPNQTHkgM8=; h=date:mime-version:subject:message-id:from; Received: from wanjb-KLV-WX9.. (unknown [121.229.73.16]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id 8BF8BAC0167; Fri, 18 Jun 2021 23:14:50 +0800 (CST) From: Wan Jiabing To: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: kael_w@yeah.net, Wan Jiabing Subject: [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated Date: Fri, 18 Jun 2021 23:14:36 +0800 Message-Id: <20210618151436.38217-1-wanjiabing@vivo.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGhhCHlZOSB1NGEsaHUMYQk1VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PD46Myo*Gj8LN0IdVgEaHUIY MTgKCyFVSlVKTUlPS0lCSUJKS0xIVTMWGhIXVQwaFRESGhkSFRw7DRINFFUYFBZFWVdZEgtZQVlK SUpVSUlCVUxIVUpNWVdZCAFZQUpDQkw3Bg++ X-HM-Tid: 0a7a1fb060e5b039kuuu8bf8bac0167 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3BCADC0201E5 X-Stat-Signature: xgu7zwrgut5h1pea6xyuaeh89jbbxe13 Authentication-Results: imf22.hostedemail.com; dkim=none ("invalid DKIM record") header.d=vivo.com header.s=default header.b=Bz0r8uYy; dmarc=pass (policy=none) header.from=vivo.com; spf=pass (imf22.hostedemail.com: domain of wanjiabing@vivo.com designates 115.236.121.144 as permitted sender) smtp.mailfrom=wanjiabing@vivo.com X-HE-Tag: 1624029296-962708 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001950, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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;