Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1621752pxj; Fri, 18 Jun 2021 11:00:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsPaRv2GeQdoA0ZEgmy16RvFR2lk2/0BG43SQvlw5JazpOxNHH1WS4661nf3eEBwa8+Iyx X-Received: by 2002:a6b:f618:: with SMTP id n24mr9064312ioh.174.1624039236516; Fri, 18 Jun 2021 11:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624039236; cv=none; d=google.com; s=arc-20160816; b=hUJ5fv+zaOQ3gIbPk9tW2/99mIQFO44R7Fr6cG9JoNcmEGWX7i88d5hmHg+bDl9DcL GqIyUQ4h+gkZ9O7AzMGL7lkEyd2CMS55i5IZ8MNpkHBWmInLu0XoyWo8yR0PJek7q2Qf 7tr5fzpVOxm5N3UYKwL/SrmOizK/2FJYYz4QcSWzbadEfLnboJ6Mut3s9fQj8ie7tZXQ E72MjmoWRZrBppVi8GohcJimKMuIN1luAklJpYtFNuy3hf+6TWpW2BMex8JyuTFwxdIC X05w9w3I6b+KVwXZsVSuyboDjZVbS+kZ0U/Sqz6/OaMwybKE/5wf3op1lxR4ERNhbRs/ hhJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WUFv4LRD+NHrRC3a1phX1cKlBvVWd+7I1lPNQTHkgM8=; b=B+Sqvu6kbHriKGt1Vnvj3K62gz5hmDWOOn1rjmas5cKbQrXO6T33SqKGc3Ocdw9scQ UOwWQVZEvuf9KL4BlOChMBWMxEC1mZ58lweBlLHPhb15r0zHD0a6s/iKupZ9Ro7FASuk c0n06eptha1CtWbt2DDT32pMyij8W3em+JubPxLsK445IDphTekcmS2fwC1mz6ypKmrR AwKAv3OGgUbGuG65IFmFYBjhDl/Cn7eATDbQoNKLH+Se690lJKrqHh4tT1US61q+KQVx A1mrYE+/IfdDEuT7bnf+qx83E0+gJXYkiP5rl701JAeyldXUpV5LpbYT7+5zftBjs7qt rJXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@vivo.com header.s=default header.b=Bz0r8uYy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si3017559iln.52.2021.06.18.11.00.23; Fri, 18 Jun 2021 11:00:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@vivo.com header.s=default header.b=Bz0r8uYy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234830AbhFRPRH (ORCPT + 99 others); Fri, 18 Jun 2021 11:17:07 -0400 Received: from mail-m121144.qiye.163.com ([115.236.121.144]:48988 "EHLO mail-m121144.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbhFRPRG (ORCPT ); Fri, 18 Jun 2021 11:17:06 -0400 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 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGhhCHlZOSB1NGEsaHUMYQk1VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PD46Myo*Gj8LN0IdVgEaHUIY MTgKCyFVSlVKTUlPS0lCSUJKS0xIVTMWGhIXVQwaFRESGhkSFRw7DRINFFUYFBZFWVdZEgtZQVlK SUpVSUlCVUxIVUpNWVdZCAFZQUpDQkw3Bg++ X-HM-Tid: 0a7a1fb060e5b039kuuu8bf8bac0167 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.30.2