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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CAB1C433EF for ; Fri, 4 Mar 2022 08:26:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E230E8D0005; Fri, 4 Mar 2022 03:26:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DABC68D0001; Fri, 4 Mar 2022 03:26:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4BD88D0005; Fri, 4 Mar 2022 03:26:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id B52A48D0001 for ; Fri, 4 Mar 2022 03:26:41 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 843D4609AC for ; Fri, 4 Mar 2022 08:26:41 +0000 (UTC) X-FDA: 79206022602.15.56B0608 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf30.hostedemail.com (Postfix) with ESMTP id C98BA80011 for ; Fri, 4 Mar 2022 08:26:40 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5492D1F384; Fri, 4 Mar 2022 08:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646382399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KCOFuAaVAY0b+QRiHm9j3INKSoRjWhgAoY5Aj0qS72k=; b=wtT15f5UUskM2rJ/gLefAZDBA7aM70gAobwaXXxYAPnzKq3enKrDiWPtpeSoan+xWYnrc/ yY+//jl/tZ+x9ZCij9HZTf6rrao7t8r4hkb5UmJvkQcLHMBEOWdCopYzoMmT5L/Fe0A3Qj lZPqAx2zxyC3eZk18WdeSHgZGTtmMZg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646382399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KCOFuAaVAY0b+QRiHm9j3INKSoRjWhgAoY5Aj0qS72k=; b=/lVPlxh+3PA0CyUEi3v5YaNiI76ndEJyKPnkw9qiQ86YO25Rtt8sgZ4wEsIfPL31852vk4 CBbwyyt76lvL1vDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 279CA13AF7; Fri, 4 Mar 2022 08:26:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uRr2CD/NIWJ/ZAAAMHmgww (envelope-from ); Fri, 04 Mar 2022 08:26:39 +0000 Message-ID: <3fdd3840-fc97-96a6-8b61-ad1c89b5b403@suse.cz> Date: Fri, 4 Mar 2022 09:26:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] mm/page_alloc: call check_new_pages() while zone spinlock is not held Content-Language: en-US To: Eric Dumazet , Andrew Morton Cc: linux-kernel , linux-mm , Eric Dumazet , Mel Gorman , Michal Hocko , Shakeel Butt , Wei Xu , Greg Thelen , Hugh Dickins , David Rientjes References: <20220304015941.1704249-1-eric.dumazet@gmail.com> From: Vlastimil Babka In-Reply-To: <20220304015941.1704249-1-eric.dumazet@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: C98BA80011 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wtT15f5U; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/lVPlxh+"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: rta48h1ikuztihuur7nr3chkegwhsip7 X-HE-Tag: 1646382400-806301 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 3/4/22 02:59, Eric Dumazet wrote: > From: Eric Dumazet > > For high order pages not using pcp, rmqueue() is currently calling > the costly check_new_pages() while zone spinlock is held. > > This is not needed, we can release the spinlock sooner to reduce > zone spinlock contention. > > Signed-off-by: Eric Dumazet > Cc: Mel Gorman > Cc: Vlastimil Babka > Cc: Michal Hocko > Cc: Shakeel Butt > Cc: Wei Xu > Cc: Greg Thelen > Cc: Hugh Dickins > Cc: David Rientjes > --- > mm/page_alloc.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) Just a quick reply from what AFAIK immediately see as a issue. > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3589febc6d31928f850ebe5a4015ddc40e0469f3..0890a65f8cc2259e82bc1f5ba95a592fb30f9fb8 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3685,7 +3685,6 @@ struct page *rmqueue(struct zone *preferred_zone, > gfp_t gfp_flags, unsigned int alloc_flags, > int migratetype) > { > - unsigned long flags; > struct page *page; > > if (likely(pcp_allowed_order(order))) { > @@ -3706,10 +3705,12 @@ struct page *rmqueue(struct zone *preferred_zone, > * allocate greater than order-1 page units with __GFP_NOFAIL. > */ > WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1)); > - spin_lock_irqsave(&zone->lock, flags); > > do { > + unsigned long flags; > + > page = NULL; > + spin_lock_irqsave(&zone->lock, flags); > /* > * order-0 request can reach here when the pcplist is skipped > * due to non-CMA allocation context. HIGHATOMIC area is > @@ -3723,13 +3724,13 @@ struct page *rmqueue(struct zone *preferred_zone, > } > if (!page) > page = __rmqueue(zone, order, migratetype, alloc_flags); > - } while (page && check_new_pages(page, order)); > - if (!page) > - goto failed; > + spin_unlock_irqrestore(&zone->lock, flags); > + if (!page) > + return NULL; > + } while (check_new_pages(page, order)); > > __mod_zone_freepage_state(zone, -(1 << order), > get_pcppage_migratetype(page)); > - spin_unlock_irqrestore(&zone->lock, flags); __mod_zone_freepage_state() outside the lock is AFAIK unsafe. > > __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); > zone_statistics(preferred_zone, zone, 1); > @@ -3743,10 +3744,6 @@ struct page *rmqueue(struct zone *preferred_zone, > > VM_BUG_ON_PAGE(page && bad_range(zone, page), page); > return page; > - > -failed: > - spin_unlock_irqrestore(&zone->lock, flags); > - return NULL; > } > > #ifdef CONFIG_FAIL_PAGE_ALLOC