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 C1FA7C021B2 for ; Tue, 25 Feb 2025 10:50:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17F586B007B; Tue, 25 Feb 2025 05:50:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 130246B0082; Tue, 25 Feb 2025 05:50:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEB396B0085; Tue, 25 Feb 2025 05:50:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D46766B007B for ; Tue, 25 Feb 2025 05:50:07 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5A4F2811C9 for ; Tue, 25 Feb 2025 10:50:07 +0000 (UTC) X-FDA: 83158147254.14.A9B1C6C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf12.hostedemail.com (Postfix) with ESMTP id D58AA40008 for ; Tue, 25 Feb 2025 10:50:04 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=sE5Qd+9i; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ap9KqqLL; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=sE5Qd+9i; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ap9KqqLL; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740480605; 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=ooEgPRdbCn4oVVE3Zoo25QbzovMbvcZ86trl0Eo+lH8=; b=bgMzYzz2uRIF5uA3pjRi+Vat+JY5fjS/2LUjPVIdk5fHp6OTx0ooGtVd7CUoAab98W8PYf ixLUiirfrUIv4U+7pICC0tsAhVf+qYfL64VM4mNqZP4B+bHKqElJwlWi17cR5CcfcJrXvh smgXVYssLWaKo87peTiiMrXOxzTxbbU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=sE5Qd+9i; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ap9KqqLL; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=sE5Qd+9i; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ap9KqqLL; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740480605; a=rsa-sha256; cv=none; b=oG6C6B0mc2avOxgboQzeBZ/4BetzAJ813SOBSbwL3ODyvZ58OMT+f7JMa6xgiJH605TUF7 XJJvS9o9m79d5LXCihHl5uSfZSofmr+5PJ1TtWegeCUP1J+0VsqER0XbQObfmdoF+0hr7X 24keqd6FdLJ6oc1Sco/rBRzpBRo/2UY= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2F9421F44F; Tue, 25 Feb 2025 10:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1740480603; 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:autocrypt:autocrypt; bh=ooEgPRdbCn4oVVE3Zoo25QbzovMbvcZ86trl0Eo+lH8=; b=sE5Qd+9ip3wwWavLaelZQr22rsvfTRWHg05T8fzq3wNLEna4u3/VNx+N0i8eS0nQaYmRBs L9J1FLuo5VC3yJjCdHhDwGDNOn49it4/H8qQAcCubFEIZraMt7LWO+V9ftPrEI+PhvcMEX yMIDgkbBTw5wqzjEeQF3tfbym7eoou8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1740480603; 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:autocrypt:autocrypt; bh=ooEgPRdbCn4oVVE3Zoo25QbzovMbvcZ86trl0Eo+lH8=; b=ap9KqqLL7gHGFcC/Hhy8OSoIomThK7gE8ibZ61OENzjDvok3+07FrNWWZf7UVGLA9cwE0G we0oJMH/3TzXg8Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1740480603; 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:autocrypt:autocrypt; bh=ooEgPRdbCn4oVVE3Zoo25QbzovMbvcZ86trl0Eo+lH8=; b=sE5Qd+9ip3wwWavLaelZQr22rsvfTRWHg05T8fzq3wNLEna4u3/VNx+N0i8eS0nQaYmRBs L9J1FLuo5VC3yJjCdHhDwGDNOn49it4/H8qQAcCubFEIZraMt7LWO+V9ftPrEI+PhvcMEX yMIDgkbBTw5wqzjEeQF3tfbym7eoou8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1740480603; 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:autocrypt:autocrypt; bh=ooEgPRdbCn4oVVE3Zoo25QbzovMbvcZ86trl0Eo+lH8=; b=ap9KqqLL7gHGFcC/Hhy8OSoIomThK7gE8ibZ61OENzjDvok3+07FrNWWZf7UVGLA9cwE0G we0oJMH/3TzXg8Cg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1EEFA13888; Tue, 25 Feb 2025 10:50:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KsoqB1ugvWfPLwAAD6G6ig (envelope-from ); Tue, 25 Feb 2025 10:50:03 +0000 Message-ID: <68ac1af7-988b-42c6-8249-8949eb7fd986@suse.cz> Date: Tue, 25 Feb 2025 11:50:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] mm: page_alloc: don't steal single pages from biggest buddy Content-Language: en-US To: Johannes Weiner , Andrew Morton Cc: Brendan Jackman , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20250225001023.1494422-1-hannes@cmpxchg.org> <20250225001023.1494422-2-hannes@cmpxchg.org> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV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R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: <20250225001023.1494422-2-hannes@cmpxchg.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: D58AA40008 X-Stat-Signature: 3jjbnqw1o7hizmpjj5fxtuh5iukk3r6b X-HE-Tag: 1740480604-403588 X-HE-Meta: U2FsdGVkX1/7D9LVRkBXQFb5x0re2ACbHy7tC3wuWPgYq7VTpY+oSPVtK0CT5HB+crOa8r/4YZV5Q5m7Kayk/KhVDuj1TGynDnjft6OQhH2XCnglls4Q9Uu8uLXnXaZXulehHLvH6uoogUVpZoKWq0LFGftiPUkhRacKb+eVeIEUKMQwnhUnYXvdB1XhySNBtEOQH5ezkLeHKfbzAqhgo2KnRHQvAlSeyplMOJGmSPNCu6q69AYvJTka8xI9V626eydD8x/sHNYAckFjcQiqGBFsivbHNpt/P2YwtH59yMOQklEvFm6HS25JQriQQO5YoAzS9ptuysxLQqqmTyaWJFAdju/JoqSoazxlDnTC/E5bKeTgkmZZNNK5Uy9zyii1cFFrtJecxi1ntTVrguOlaK8NlLIa/DnbEWCw48NAyATR6VXemSKi9E4rDPxutIMRbEslXu2cT56MNl5gNR3xUy/1EO0oCmp0NbyEhldtoQmZYG9vfXCwcctgYyY20iApITX3EtQ81OhCFiMm+SVxtgVMXYJ2pbk0iJ1Yow6xq8lUPb81uTe7MF9K2LRNMnevdmjleGqkULMwUjwFk0kx27coYRYTmIm7Yx9TnwjZ7Eazqx04wgdVeFJobgVfxiZp7H06aUUNQPlklCHIwR36NFYH//v74K2GzEMRBykcrfvUlo/YOyHwCJR0JjAYTjEQTbkQPFbk+CDIx6Ho9+74Qs1LAaEgBFqZbCB1CsE2t9E2mr53F6/dNCU1u2x4alURBtN1mgwMZT984bF1NrPpt3bwBTJdBKn0tk2WAzFvoHa7G5l0Zx5AyrrJiAIEmA+WRct5JovkwJMTXiZ7T6GgkiHkG0aKzGTylkREUPpy74EL+TV2gvVCcsE4xhTRtpmIDeb2v+lPLtiw4u4JJsQIdt6vGoE/DBFCejm4BkljVdsw/SZ7nytN6O2/6esh2GnWrA160/uW+zz5d3PJq6a VQsFKE9S Fb+jlolh3EMNGypH+DRPnJs6MGrEoUQFTqzNDlfvqY4vUGfTJuNVlKuNgY7pFw/O1e8AO6/3Z3XVKVW/TAPQH7Z6faICSEr40MF6TkSgt4AwNYJs22nPvi8TntPVeyXRkuogXGLN4N3OgwitT6cBSLrdDDVnRQInrlsvMnKkaPGji1UeNj3vk6wVs/QX7+B/DnWWRfDoqeXkr+eVe4CE1oL44HAazZOXDkSckC9/cxL9kCiLOmiZk5cJaR6GrGASVG/02rMF73QMB64Sezp1M25c2HKHW34/6IJW8eT/E8c2+3uhJIACbSNlRKNrJfzBgO84LIN+qRuAq3Dp18OS4Ur3EyNG4RH7omVAB2BH9sSvJiA4Qzkoum/np2jqwRgKr3VB9xPN+LORW3mw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001758, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2/25/25 01:08, Johannes Weiner wrote: > The fallback code searches for the biggest buddy first in an attempt > to steal the whole block and encourage type grouping down the line. > > The approach used to be this: > > - Non-movable requests will split the largest buddy and steal the > remainder. This splits up contiguity, but it allows subsequent > requests of this type to fall back into adjacent space. > > - Movable requests go and look for the smallest buddy instead. The > thinking is that movable requests can be compacted, so grouping is > less important than retaining contiguity. > > c0cd6f557b90 ("mm: page_alloc: fix freelist movement during block > conversion") enforces freelist type hygiene, which restricts stealing > to either claiming the whole block or just taking the requested chunk; > no additional pages or buddy remainders can be stolen any more. > > The patch mishandled when to switch to finding the smallest buddy in > that new reality. As a result, it may steal the exact request size, > but from the biggest buddy. This causes fracturing for no good reason. > > Fix this by committing to the new behavior: either steal the whole > block, or fall back to the smallest buddy. > > Remove single-page stealing from steal_suitable_fallback(). Rename it > to try_to_steal_block() to make the intentions clear. If this fails, > always fall back to the smallest buddy. > > The following is from 4 runs of mmtest's thpchallenge. "Pollute" is > single page fallback, "steal" is conversion of a partially used block. > The numbers for free block conversions (omitted) are comparable. > > vanilla patched > > @pollute[unmovable from reclaimable]: 27 106 > @pollute[unmovable from movable]: 82 46 > @pollute[reclaimable from unmovable]: 256 83 > @pollute[reclaimable from movable]: 46 8 > @pollute[movable from unmovable]: 4841 868 > @pollute[movable from reclaimable]: 5278 12568 > > @steal[unmovable from reclaimable]: 11 12 > @steal[unmovable from movable]: 113 49 > @steal[reclaimable from unmovable]: 19 34 > @steal[reclaimable from movable]: 47 21 > @steal[movable from unmovable]: 250 183 > @steal[movable from reclaimable]: 81 93 > > The allocator appears to do a better job at keeping stealing and > polluting to the first fallback preference. As a result, the numbers > for "from movable" - the least preferred fallback option, and most > detrimental to compactability - are down across the board. > > Fixes: c0cd6f557b90 ("mm: page_alloc: fix freelist movement during block conversion") > Suggested-by: Vlastimil Babka > Signed-off-by: Johannes Weiner Reviewed-by: Vlastimil Babka Thanks!