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 90AD1CA5531 for ; Wed, 13 Sep 2023 09:52:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1FC86B0175; Wed, 13 Sep 2023 05:52:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C2E256B0177; Wed, 13 Sep 2023 05:52:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A818A6B0178; Wed, 13 Sep 2023 05:52:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8BE856B0175 for ; Wed, 13 Sep 2023 05:52:11 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4772E160267 for ; Wed, 13 Sep 2023 09:52:11 +0000 (UTC) X-FDA: 81231108462.26.9955E4B Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf07.hostedemail.com (Postfix) with ESMTP id 4AC9E40013 for ; Wed, 13 Sep 2023 09:52:09 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=hStFLr33; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=hZ+qFD8A; dmarc=none; spf=pass (imf07.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694598729; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=TLF6GZwuLdJAYewv2K0H7ivS3KZGBykkISQrVkKlD0c=; b=rXs0bNgLKwzxsP2qWCbcVSF/HxDt3rMG535jHZfqVB1AOah2k/niMfsoLDMdlqM+infEZI kMPQ4MHHcW19I/20XADTeWnqQQygs/A5ApEvB5xU5daiFgbUkd6LCjNzkLPOdEdqVxOkAH 3MEg6yFjOMsXJFldKnAeWOWnGzs8a3k= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=hStFLr33; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=hZ+qFD8A; dmarc=none; spf=pass (imf07.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598729; a=rsa-sha256; cv=none; b=SzNNpJhzKweeXr1yibYOjKinRMrBiaa51e5Id5gTvtCmCNXYRAAPZxEHxsSHzYFfGRClzm b2DVXXf7mOKdZQ9A/MXnpaLRyd5E29Ui5ccK3DPyAJeUilJBmbJqxt67GtvZ9BKMckIuE2 FHd0b/P7cHV0EIXT2PKlz/mxMP9F3k4= 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 X-Rspamd-Queue-Id: 4AC9E40013 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xjxsgggrdr3xn1mkbbk99ryc6ssb1185 X-HE-Tag: 1694598729-679675 X-HE-Meta: U2FsdGVkX1+HdeAXj/v0Zk9oFqU0h+o6BYSwEOCbudaC7Q9G3tMLy3c6H9V2Z1qalJkncoozHv74pxPDfV/jbWBy3hwNmDS1hmXkvTTmitk9fHWGHQPb8NvBgOIIfbCpdyMnb4tqhH1qy8wQfQVaftcf2Q0ujkQAB1IdcVIXUnZs9f8Rz4VoV1KKbEsA9CK7akWnQZ/fFTR23h8xA6EEhHHX3HRmEQE9XX0fX9oYwWxJxPxXh6KU5SOISo+RdA8kPs8sSwzT1Q1JpCxWLvgk8CuWPQj88NFTbxcVMCDw/sJTwAyMFzkmEoA4ZrEUJiq1Qwlnhym99QAtibX2bTFBfqOqrrOFiqIyd7CDrjARJ8Y7W1BM5keXjO2mlqlN1yRaYK1iJVFGY1EVaNL3T42iHyELwY2PtjULBEYVJJj6JoPrCHA2wMfPZ2L1fpTvDZpxsWXOmm4cAt6pEPRTL76RlHIqvam7NPZOSvkS0t8tmHzXIQxHUHjmnWHYJjFCEJA2ofxT8BYX6t0xdlmvx4sIDdG3JjEJD8qw/5FRsoZjbo/tZ1P2U+owX1GaVwq42sWsvPhAx/2I5b0mlGJc2Q11/4uMU6RsPUZzaf6cNQxOe33laTx/QlsuXygQen5ATqmFfvXdhPgYUk+g5Z+QK7X9BBuNanjDyXI+1PZTYd3CD6x1Ne14PpJK3k+QBzEcCvbGJqxeTyHvu0bEpyCSBQ11WJfzcXQEPcaERI/6IAUd0aR8bsO785+ZL/P0Nk1BXbRDywshRadjF/6cuUIVASaeORp+TW+Adse2YCXWtKYpFK+F4EWMQSPYjLrPjtV7i9Z1tFrOhBjtYMoe61/TAHXQWTLDPWK72b7fRzqQ4vCBj3Lsuwr6aWcNfcLvsX4y1s249aevr1uLvrl4tu5oZ2zsxLMN7wJyptB2y/lPEoEPCKz9+FrE6CVPzFrVD+vDXntBII0yvTEJHALcSexJf82 A+y4GPbO bxmsM7UYWPkJUNfV1xxb3A0Ky3NwiyYYv7f7WXvSxg7qq3plLc4aHSSLMW+4BTRP1c0Z3toXzlxk8i0hoMDJ3wn2aWclC/1NGrFx7MazG8sgwEkbH0JDEBkMdYBnEr/EEhTGw2SqoakhWHLn2lRiKaeYfMtnv/TShyRNkTbtx1DRTe1g16lXp2SXdqMagf5su1AQh4sc2ysZoO5q4Uo/LSVUDdHrRZyc50UYowNL1Z38KZVySPj98hL1jW98JTnMjVHllEqt7N1D07ebCn/z1HGIw8ALxucUOTB5pIpPxsD1xR2w= 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 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); > + } > } > > /*