Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3165085rdb; Wed, 13 Sep 2023 04:19:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdc0R+fHGErdnf9wBVUVTAFCh5kzLtOdVnqtT/3GP+03CIqkOtOW1R1WAnLTianmM+/PK2 X-Received: by 2002:a17:902:c40a:b0:1c3:b0c7:38bf with SMTP id k10-20020a170902c40a00b001c3b0c738bfmr7795018plk.12.1694603961518; Wed, 13 Sep 2023 04:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694603961; cv=none; d=google.com; s=arc-20160816; b=M4jA13Dat0t6iypbb9WfMkAGtd5ta1fwdVpT7ymuhvHngXmASXhK4Ngh/ble/5TMbO z+EC+EWIP7BZUSU2RDNAuc7tzJ0mtbPMLtRZ//r5z7EQM2NN665BGZZr0EGyqO0ZS5Oe mIXbJRVJ82cbbAd7sygLR64BnFcYNwykNPzMkg+pNUV7hklMS2fiOQajj5RY3mg2Oyoa ii1haXMbkgspmktuAumPTLmfmFJVTqWxG4/LxcFt6MSdZsjPuyOrJrn7Lt6oaOC2aEo1 EO7APOeiCHcPDD/No6t6oYXF+qhp4hnFXVsWLkMOUYbQa1TWD1gnT8FrMacFXvSG7XbK lVcg== 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=TLF6GZwuLdJAYewv2K0H7ivS3KZGBykkISQrVkKlD0c=; fh=hq15/A2Tslw9YA2204Su5Ecu43xpuzUCtL6/M8x+dIs=; b=grgilPyKq+/HYWXGL5UiBy09SIyZIE7xJqlJKoSnyOK0GF0GHg3lg8rsNOqrw3C9Zu iKdlQAFuD45+ULtRFSys5zq7HKtegFThnlT3s6AlveSdrdvQVHoA9S0fVCNcxLif6agu Bk0MLid2aKzmy9ownUZ/yLGa1Gm1HEmEegWgHpTlCtMOmHx87YBxGTmAEIRlAYZvTzgR ROdzP2yP2laPVxw06ImgkpwRPZii1AMdQMWtdJmB0dTOukrXavJhhG7OVOF26A03vuQS CHtDicQ2NTSPfPtZthp6akmnnoy2YvcFybbjkIPKTs0hOwFBUY7F/103a6lnDTGycPry fIPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=hStFLr33; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z13-20020a170903408d00b001bf223c315bsi9457606plc.60.2023.09.13.04.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 04:19:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=hStFLr33; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8697D8062370; Wed, 13 Sep 2023 02:52:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239525AbjIMJwZ (ORCPT + 99 others); Wed, 13 Sep 2023 05:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239500AbjIMJwM (ORCPT ); Wed, 13 Sep 2023 05:52:12 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B974819B6 for ; Wed, 13 Sep 2023 02:52:08 -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-out1.suse.de (Postfix) with ESMTPS id 7427C21886; Wed, 13 Sep 2023 09:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1694598727; 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=TLF6GZwuLdJAYewv2K0H7ivS3KZGBykkISQrVkKlD0c=; b=hStFLr33s9zHIjhsYNxqafNInd6wpqArRszU0xS0nKPvzhnB/j+9WNFSywlw6II7CgAqL2 /YsNDTghRTb7mkR3ARpjBv4iTIE+XEu4YR63O4gntyONvs3kNKiT0kLlDOkylYQMdE5IBk JtqZ+kFK44Mty1mPIqfzJwf3yrFQbnc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1694598727; 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=TLF6GZwuLdJAYewv2K0H7ivS3KZGBykkISQrVkKlD0c=; b=hZ+qFD8APWzAAl/cEAe3jFyMAI33bNaz0/65aTq24WsCbXZB1nsepSJwt18bd7G2e4sz32 dEbYbZY/0DNDHUDA== 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 596F113582; Wed, 13 Sep 2023 09:52:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HCxBFUeGAWV+UQAAMHmgww (envelope-from ); Wed, 13 Sep 2023 09:52:07 +0000 Message-ID: <65752939-3fc6-200e-24ba-0df9aee7c521@suse.cz> Date: Wed, 13 Sep 2023 11:52:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH 2/6] mm: page_alloc: fix up block types when merging compatible blocks Content-Language: en-US To: Johannes Weiner , Andrew Morton Cc: Mel Gorman , Miaohe Lin , Kefeng Wang , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230911195023.247694-1-hannes@cmpxchg.org> <20230911195023.247694-3-hannes@cmpxchg.org> From: Vlastimil Babka In-Reply-To: <20230911195023.247694-3-hannes@cmpxchg.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:39 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email On 9/11/23 21:41, Johannes Weiner wrote: > The buddy allocator coalesces compatible blocks during freeing, but it > doesn't update the types of the subblocks to match. When an allocation > later breaks the chunk down again, its pieces will be put on freelists > of the wrong type. This encourages incompatible page mixing (ask for > one type, get another), and thus long-term fragmentation. Yeah why not. Sould be pretty rare as this only affects >=pageblock_order, but then also the overhead in the otherwise hot function is limited to its colder part. > Update the subblocks when merging a larger chunk, such that a later > expand() will maintain freelist type hygiene. > > v2: > - remove spurious change_pageblock_range() move (Zi Yan) > > Signed-off-by: Johannes Weiner Reviewed-by: Vlastimil Babka > --- > mm/page_alloc.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index e3f1c777feed..3db405414174 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -783,10 +783,17 @@ static inline void __free_one_page(struct page *page, > */ > int buddy_mt = get_pfnblock_migratetype(buddy, buddy_pfn); > > - if (migratetype != buddy_mt > - && (!migratetype_is_mergeable(migratetype) || > - !migratetype_is_mergeable(buddy_mt))) > - goto done_merging; > + if (migratetype != buddy_mt) { > + if (!migratetype_is_mergeable(migratetype) || > + !migratetype_is_mergeable(buddy_mt)) > + goto done_merging; > + /* > + * Match buddy type. This ensures that > + * an expand() down the line puts the > + * sub-blocks on the right freelists. > + */ > + set_pageblock_migratetype(buddy, migratetype); > + } > } > > /*