Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4510175rwl; Mon, 3 Apr 2023 06:08:14 -0700 (PDT) X-Google-Smtp-Source: AKy350aQ5+HrJIVibdAaH+j9oG0xMigSOn76okisD9eqyRkpGTtKqv+ZbHeJkSLAwndiTQYda+73 X-Received: by 2002:a62:79d5:0:b0:627:f837:2f5b with SMTP id u204-20020a6279d5000000b00627f8372f5bmr35483306pfc.11.1680527294081; Mon, 03 Apr 2023 06:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680527294; cv=none; d=google.com; s=arc-20160816; b=lMZzQ7fWtkt1N32kBuMg5hj3ij/Y+GHAozRewHqd3K2jFX5OOmYNWgZ0GstP72+h4/ MxqwOsKncRrQQZZQdon0dMmGZ6Q4pVar9RzHuYZrZldRuadj+fQx61YIkav4AYfsO75N BO4D3iXvp38/rS7s+Lx+ChZGdCV4DztZaRKZL1K21diPegBJrPPFvRCMBuzeGPY39f4B 0A9A0dcDq43ma/bdEtc/zS1b17oJxtp9EwgtAED5nnI7z1ImtHWAvxE8yThCn1tuRzRy T6BmN45nZ/5JghZTviOqFbDxOWSy4jKFdb29ixrmKMDIWlhl6JhRvveWGLvJDpBhn1la KUxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=HSoJPiNm6YLdrvyBCRNcHzBUr7oKAdacKl0GHdUtJXA=; b=us28y18s8RGnKO/artbTr87qBm6rCrk4H2XD5BmXBh3ZSSsvV0YWer+i19r1CB0Ta0 +7bWsbFJfVQCccNs0Od491cNOpKdMQOp2MAa86Lm4gAaSLBF//lJhObDkYK475U8M5SF 42NooqPu5iAxJAPna911BXm6kLbRHRWC1g0ofGAlE/Bem+oq/r6SWr8ulFUGlprKfAky o+c+rTeLtAVXgYh8LZL+RhBegEgX919tQBGFJ3da9Y9jX7JHcGrNSvMIaDpyuf4ao3rH en/uq7fv6Us/Qo17hY+I7Q6qf+Sb3KK5F/DQqewj7hdEKj0NgZ7M4iWCVNG4MkYNkALH tW8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=VWqebsGW; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w123-20020a626281000000b0062a56e86099si8109764pfb.270.2023.04.03.06.08.00; Mon, 03 Apr 2023 06:08:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=VWqebsGW; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232090AbjDCNHi (ORCPT + 99 others); Mon, 3 Apr 2023 09:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbjDCNHh (ORCPT ); Mon, 3 Apr 2023 09:07:37 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A2211F; Mon, 3 Apr 2023 06:07:36 -0700 (PDT) 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 AD36E1FF6E; Mon, 3 Apr 2023 13:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1680527254; 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=HSoJPiNm6YLdrvyBCRNcHzBUr7oKAdacKl0GHdUtJXA=; b=VWqebsGWD8RAUsjZeeaP7K5SjdgTlp5fwMlBEgdMdHT4jVR3zeZ2tQhOESTQ3eQ0KKwUfe 6LqMQ1DTNheF5SqznhydptvbvXLXMBajFHSA6zry0wxZqbEJ8wjaJCDQTXeVSxmKPTsUSy 4nJLJVkcm4u7gVWb/VXyAdsRyAhfv8g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1680527254; 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=HSoJPiNm6YLdrvyBCRNcHzBUr7oKAdacKl0GHdUtJXA=; b=h5q3i5np2j574eqECbyNVp3f1IFao5UeZNBpPDfBsYuTt2l+15XRQsVsYhXLolIoF85mlX ouTblE3ueplUupCA== 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 23B561331A; Mon, 3 Apr 2023 13:07:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id adnlB5bPKmS5YwAAMHmgww (envelope-from ); Mon, 03 Apr 2023 13:07:34 +0000 Message-ID: <2a8278cf-d282-ada6-0161-3b9c6adcb12e@suse.cz> Date: Mon, 3 Apr 2023 15:07:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCHv9 02/14] mm: Add support for unaccepted memory Content-Language: en-US To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Dave Hansen , Mike Rapoport , David Hildenbrand , Mel Gorman , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport References: <20230330114956.20342-1-kirill.shutemov@linux.intel.com> <20230330114956.20342-3-kirill.shutemov@linux.intel.com> <43234108-fa4f-7583-e3b4-2daa2de89fb0@suse.cz> <20230403100244.4sre7ki4ccusiiul@box> From: Vlastimil Babka In-Reply-To: <20230403100244.4sre7ki4ccusiiul@box> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/3/23 12:02, Kirill A. Shutemov wrote: > On Mon, Apr 03, 2023 at 11:26:53AM +0200, Vlastimil Babka wrote: >> > Signed-off-by: Kirill A. Shutemov >> > Acked-by: Mike Rapoport # memblock >> >> Reviewed-by: Vlastimil Babka > > Thanks! > >> Just a small suggestion below: >> >> > + >> > +static bool try_to_accept_memory(struct zone *zone, unsigned int order) >> > +{ >> > + long to_accept; >> > + int ret = false; >> > + >> > + if (!static_branch_unlikely(&zones_with_unaccepted_pages)) >> > + return false; >> >> >> This potentially (depends on what compiler decides) means we'll call this >> function just to skip the static branch. OTOH forcing it as inline would be >> wasteful too. So I'd split that away and make the callers do that static >> branch check inline. Just as deferred_pages_enabled() is used. > > Like this? Yep. > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 07e16e9b49c4..80fe5e4b6cca 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -390,6 +390,7 @@ EXPORT_SYMBOL(nr_online_nodes); > static bool page_contains_unaccepted(struct page *page, unsigned int order); > static void accept_page(struct page *page, unsigned int order); > static bool try_to_accept_memory(struct zone *zone, unsigned int order); > +static inline bool has_unaccepted_memory(void); > static bool __free_unaccepted(struct page *page); > > int page_group_by_mobility_disabled __read_mostly; > @@ -3464,8 +3465,10 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, > gfp_mask)) { > int ret; > > - if (try_to_accept_memory(zone, order)) > - goto try_this_zone; > + if (has_unaccepted_memory()) { > + if (try_to_accept_memory(zone, order)) > + goto try_this_zone; > + } > > #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT > /* > @@ -3519,8 +3522,10 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, > > return page; > } else { > - if (try_to_accept_memory(zone, order)) > - goto try_this_zone; > + if (has_unaccepted_memory()) { > + if (try_to_accept_memory(zone, order)) > + goto try_this_zone; > + } > > #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT > /* Try again if zone has deferred pages */ > @@ -7302,9 +7307,6 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order) > long to_accept; > int ret = false; > > - if (!static_branch_unlikely(&zones_with_unaccepted_pages)) > - return false; > - > /* How much to accept to get to high watermark? */ > to_accept = high_wmark_pages(zone) - > (zone_page_state(zone, NR_FREE_PAGES) - > @@ -7321,6 +7323,11 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order) > return ret; > } > > +static inline bool has_unaccepted_memory(void) > +{ > + return static_branch_unlikely(&zones_with_unaccepted_pages); > +} > + > static bool __free_unaccepted(struct page *page) > { > struct zone *zone = page_zone(page); > @@ -7398,6 +7405,11 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order) > return false; > } > > +static inline bool has_unaccepted_memory(void) > +{ > + return false; > +} > + > static bool __free_unaccepted(struct page *page) > { > BUILD_BUG();