From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 409CAEB64DA for ; Thu, 20 Jul 2023 23:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbjGTXoK (ORCPT ); Thu, 20 Jul 2023 19:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbjGTXoI (ORCPT ); Thu, 20 Jul 2023 19:44:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C94E410A for ; Thu, 20 Jul 2023 16:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689896600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qcWYhPUx1OxTKdJoZ4TFTmi7V95A65ppmXd4UUqPNwI=; b=XSvOUbA0ErvGTvPgdt6xPAlBhZie8oLEtiWo9mfSQsVr7L+XQKwA8M5318IdrqY2xTxxqS SrJhHQe4/Mnt8R9HVdaRZyoSl1S1t7AfHrwIZWI6QJ2vOY+WKqmFIu2DG6WLdBGrf74LtT 52TFThyatOhExqCB45DX2SJyrKBN5og= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-352-ApuzmyMUNXaSyBW43ZtX4w-1; Thu, 20 Jul 2023 19:43:15 -0400 X-MC-Unique: ApuzmyMUNXaSyBW43ZtX4w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EDCFD2800E83; Thu, 20 Jul 2023 23:43:13 +0000 (UTC) Received: from localhost (ovpn-12-18.pek2.redhat.com [10.72.12.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E899F40C206F; Thu, 20 Jul 2023 23:43:12 +0000 (UTC) Date: Fri, 21 Jul 2023 07:43:09 +0800 From: Baoquan He To: Andrew Morton Cc: sunran001@208suo.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC Message-ID: References: <20230718063328.16140-1-xujianghui@cdjrlc.com> <7aa3a1cee63518cb13906d11ea130c9c@208suo.com> <20230718101735.aa31791899e2f9e19e8e0a75@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230718101735.aa31791899e2f9e19e8e0a75@linux-foundation.org> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/18/23 at 10:17am, Andrew Morton wrote: > On Tue, 18 Jul 2023 14:35:11 +0800 sunran001@208suo.com wrote: > > > ERROR: function pcpu_balance_populated called on line 2238 inside lock > > on line 2234 but uses GFP_KERNEL > > > > Generated by: scripts/coccinelle/locks/call_kern.cocci > > > > ... > > > > --- a/mm/percpu.c > > +++ b/mm/percpu.c > > @@ -2033,7 +2033,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; > > I don't believe this warning is correct. Yeah, the warning is false positive. It releases the lock when requesting memory allocation, then take the lock again. > > spin_unlock_irq(&pcpu_lock); > ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp); > cond_resched(); > spin_lock_irq(&pcpu_lock); >