Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1885743pxj; Fri, 18 Jun 2021 19:17:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/HpC1hpIWfHV9dviPunYriv6Gms/HtsYgMy0tSQ/WD9Ed9Fq6THztCa2fNCDbqRiP/bYe X-Received: by 2002:a02:c987:: with SMTP id b7mr5948146jap.129.1624069041503; Fri, 18 Jun 2021 19:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624069041; cv=none; d=google.com; s=arc-20160816; b=mHPYvX+aEh6NiiDpBPb9jGT8k9etUlUezm8NMpTfnbTQKbCWHnRbS1l/7lgvyVlWh6 CnyqB50sVxSuMSvNJzws6q28OX+VmJgmfFCaJY24+C+pAvRAp5V3axcGB9djffo1uHpZ sLSMtZM2NBtKba/1TEHppf/ZPxkxksWQVubUvn/wy+iRs3jg0jMTj79rZJhyNjDH5+2k Ww+AV1VxFaSgHcnMPZT88D+klQokWomzn8idiEfOEN/biyGaAthNLKXocBigBKPGKPpe nZK0uprDPQenHmk6Fm4+dodqn2xNJRoRdvl3KHpyQKAHCD5lMCqumBQBYSCvcVc8XFB0 tDZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=xjOKNXx7mcvWVB9xbLB4nqglFfMMl1pNP/S9NAh2kJ4=; b=lzCJ+XkeM3LPGOUYcAQiUNghJUEZfFxnuzmI+tLv3eKoyxrWbFvE7KHnfRhBACCqHu hrxXDE8cd5CcCTErPl2F2RaMLzA+9iESYuyusymKXg34AAdWgTeZLtj06Iiv3L8KJI1C uNqyIIDYGJk1WcQoIk7bhgF72nQU2g7fagrRIKaRflqar7apScZfUIkXqTl/ODlDpH6m W+SbA0zZOz3VoWksZo3I5QNFhXpR2iruqNRVKqYn2i8Gz/IF6WpXCgA7uKoumTtaddpN grUIR/CNoEm7qawyHLcmvLkmVHFROfbD+Eu076o3HGlNYRw4ZB/8wzvmkmva5LnXdO9k v26g== ARC-Authentication-Results: i=1; mx.google.com; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si9978644iok.45.2021.06.18.19.17.09; Fri, 18 Jun 2021 19:17:21 -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; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236257AbhFRSWN (ORCPT + 99 others); Fri, 18 Jun 2021 14:22:13 -0400 Received: from mail-io1-f54.google.com ([209.85.166.54]:42513 "EHLO mail-io1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhFRSWM (ORCPT ); Fri, 18 Jun 2021 14:22:12 -0400 Received: by mail-io1-f54.google.com with SMTP id v3so2228180ioq.9 for ; Fri, 18 Jun 2021 11:20:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xjOKNXx7mcvWVB9xbLB4nqglFfMMl1pNP/S9NAh2kJ4=; b=nH+FblCoFrtlskj3POK0Mz30dgNifz2kIsrUu1DvG4GT/qxyAnNFuHrBVawlnjQdz+ OyDdNocn0/b+A0aS+RUmB/nW8TFDi7fqSDZTgHS8XDgI4s4ag3X5x6GdMQtBBHVSKmlW dSZYHWn8soE9nzUBuTdtKOIb+jVTswvSwzMmgw6gKkKoEYkop5uf24ii4n3qR2zkMikp aGoXC9nh+XiNlaUNrFAdNlaYkSh3CSJDwt8A6cwkAbNQIBbVDsp0ec/uWlIW1teJubj6 xC7dGW38GGCwNYAOJco3LCx0Dopawu0f++XzwY25bvLUTAMeBNLMU6ztSxSJQ/Mm+T43 7pgg== X-Gm-Message-State: AOAM532v2RZQVgsi/strc42vZgmKBtmmwGXy5rbJ9JusojzeDz+JKp7F TCxtLyoIT/GQOQTHxWS0CzBFn/Sx4Z8= X-Received: by 2002:a6b:e018:: with SMTP id z24mr3292117iog.206.1624040403042; Fri, 18 Jun 2021 11:20:03 -0700 (PDT) Received: from google.com (243.199.238.35.bc.googleusercontent.com. [35.238.199.243]) by smtp.gmail.com with ESMTPSA id y27sm4849431iox.17.2021.06.18.11.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:20:02 -0700 (PDT) Date: Fri, 18 Jun 2021 18:20:01 +0000 From: Dennis Zhou To: Wan Jiabing Cc: Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kael_w@yeah.net Subject: Re: [PATCH] mm/percpu: Fix gfp flag in pcpu_balance_populated Message-ID: References: <20210618151436.38217-1-wanjiabing@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210618151436.38217-1-wanjiabing@vivo.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, Jun 18, 2021 at 11:14:36PM +0800, Wan Jiabing wrote: > 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 > In both places gfp flags are passed, the pcpu_lock is dropped. So I think this is an issue with coccicheck. Regardless, the fix wouldn't be to switch to GFP_ATOMIC but to make the locking correct. Thanks, Dennis