Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp143626lqe; Wed, 27 Mar 2024 01:06:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNG7ki5fXqvfuQYdUpMwa4Mtz6YN1n6mJQs07Vg5yUoFyLxmhKOcbMw3bPYj7/HmSlwxT4CAtbMsK3SQg+HrxOKweiKDT4KTMW/JPD8Q== X-Google-Smtp-Source: AGHT+IGF0ZeSpf+zTdOzNEaznVIdIf/xWdIhILTNawIgZD8CMA6EEs30V6xqbpLNRY+VdnQ8l82U X-Received: by 2002:a05:622a:14a:b0:431:2813:88d4 with SMTP id v10-20020a05622a014a00b00431281388d4mr5301350qtw.3.1711526807587; Wed, 27 Mar 2024 01:06:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711526807; cv=pass; d=google.com; s=arc-20160816; b=yyEaHwgRevNyfsClgW42Y2/OXmCl698Dw9SCzLftJ8QNptdRJdxMhYncLuhECrlW4z e6eyYS6LBgXLCb5Yicb94KBnb94fD5j/HdjCLowKqlVnRw4712T30E+etUjXVBFplDU8 gDq0Z46dRCZsbkLxxG69iySX0n6ERuqgTgt9UTmGH/2a3gO/cVI5ZzBLhQGFavbGZomp hG37/etpyPdriirpmftKTv7ihAn8d1NTzVkY+6N2r1ow/874/GQ60KTVlDZQmwieQPa9 SNswxN1RFiuaPKQ/fGfzGaQr/6IZSaCqnSHqItLuAk4heiOLWD5lj1vVNyE2Uf7oCrJt 0uLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=vUYGU3NEIN9vfbTpc5QK6zxczRpH5cZaM9EFD/D7o+I=; fh=9vOKXHL6fO/AF8FXvDu9yXhNS2K6dIUKa5pMm3jPSHM=; b=TJxEE01M9RQxpWzJc4zjAVkTTJQfzsD2kqS6+7EI52vi2ifWLd3ZwcOpaQ/AVWg1xC +4eaoNi2exRgN328xsvOBnH8eN1HzzombNMdC5HYGpNoKpl6AKBkjHIA78rNv5bEnWMO uQG0t2Wcos6sZpHC6Jt25m/UZACOQgazGhLmu/TciuLWs/rUQ1cAt0R8YoPIAvsnYk5/ lFRWnVb/Zg7xfOPomNGFSj7b4T0sa8RVQzx9PJfd9SUTSViMXCI6fJXFi+BSWQxboBo7 P/sm6ioc88UqEilD9XtYq1j+9Y9Fl4UZt0TW+khX7BSl/htd+xxqwjzqqJP78uaPevpO 56/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SWMgrUe0; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SWMgrUe0; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=tb6KkLnb; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-120495-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120495-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 2-20020ac85942000000b004316cdf7b4bsi3129802qtz.24.2024.03.27.01.06.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 01:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120495-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SWMgrUe0; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SWMgrUe0; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=tb6KkLnb; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-120495-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120495-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 138481C20A0A for ; Wed, 27 Mar 2024 08:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1A5E2C6AF; Wed, 27 Mar 2024 08:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="SWMgrUe0"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="tb6KkLnb"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="SWMgrUe0"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="tb6KkLnb" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A8E41CAAF for ; Wed, 27 Mar 2024 08:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711526800; cv=none; b=JPdT8CHOr8oQ3WCy0mAYuM62CGFzC4VCRcRUtptGMR3U8h/OPZr6yY0657RBYok06T41+InW/83fBjVsit/I/GyW1lmujEgn7IPY7nhUo4ErlBrDCZttOamSEocXewCymRNzeo5NF58KCGXC/XlyuUITT9TmSuCwo+bAKwbtGHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711526800; c=relaxed/simple; bh=BRYtL9VGgWS00XBNCQ/ZnOHDdP8AkBM62WVQ5Nj+mmQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FyMJRSQj67TgYHjskJxiJLgzJFb/qTg3RV1EC/NlN1NFa7++FeiFf0COqLawc8XWUsxXIS6+hAWigfKFHuxd1XooRso8arnJYbDi+IvmJ4XsqJoGFJ6GVwOpk4RxV6ttdrE7RC7zDSA6nHffROI5qHR2Z8/gzmvtrsb0sXiYBE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=SWMgrUe0; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=tb6KkLnb; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=SWMgrUe0; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=tb6KkLnb; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 2B0BF60071; Wed, 27 Mar 2024 08:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711526794; 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=vUYGU3NEIN9vfbTpc5QK6zxczRpH5cZaM9EFD/D7o+I=; b=SWMgrUe0rVobFstorj0qemCViLTqQvMZ3NT4aeBCF6X6ptvJxKKAYUk36j2xeppHTDjCKP AIkths8wXl14AMnzYkey6vU+UZlIJrZiZTzOFDFXu5Jg3eQ38bSRtsUGCibPopNRCDZZVH Ea+NkZVOlvkz6vm31Q0ToZSb409LfTo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711526794; 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=vUYGU3NEIN9vfbTpc5QK6zxczRpH5cZaM9EFD/D7o+I=; b=tb6KkLnbGFwiwIcR7r2R+UBjpcD19aWhPP1tGdn8r7vTTwBqr8tnveYJav4svZijzAPUAK C42BX3fDs0DJKCAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711526794; 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=vUYGU3NEIN9vfbTpc5QK6zxczRpH5cZaM9EFD/D7o+I=; b=SWMgrUe0rVobFstorj0qemCViLTqQvMZ3NT4aeBCF6X6ptvJxKKAYUk36j2xeppHTDjCKP AIkths8wXl14AMnzYkey6vU+UZlIJrZiZTzOFDFXu5Jg3eQ38bSRtsUGCibPopNRCDZZVH Ea+NkZVOlvkz6vm31Q0ToZSb409LfTo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711526794; 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=vUYGU3NEIN9vfbTpc5QK6zxczRpH5cZaM9EFD/D7o+I=; b=tb6KkLnbGFwiwIcR7r2R+UBjpcD19aWhPP1tGdn8r7vTTwBqr8tnveYJav4svZijzAPUAK C42BX3fDs0DJKCAg== 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 16F561369F; Wed, 27 Mar 2024 08:06:34 +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 nGAbBYrTA2aJBAAAD6G6ig (envelope-from ); Wed, 27 Mar 2024 08:06:34 +0000 Message-ID: Date: Wed, 27 Mar 2024 09:06:33 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 09/10] mm: page_isolation: prepare for hygienic freelists To: Johannes Weiner , Andrew Morton Cc: Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-10-hannes@cmpxchg.org> Content-Language: en-US From: Vlastimil Babka In-Reply-To: <20240320180429.678181-10-hannes@cmpxchg.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Level: Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=SWMgrUe0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tb6KkLnb X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.50 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-0.00)[22.77%]; MIME_GOOD(-0.10)[text/plain]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Score: -1.50 X-Rspamd-Queue-Id: 2B0BF60071 X-Spam-Flag: NO On 3/20/24 7:02 PM, Johannes Weiner wrote: > Page isolation currently sets MIGRATE_ISOLATE on a block, then drops > zone->lock and scans the block for straddling buddies to split > up. Because this happens non-atomically wrt the page allocator, it's > possible for allocations to get a buddy whose first block is a regular > pcp migratetype but whose tail is isolated. This means that in certain > cases memory can still be allocated after isolation. It will also > trigger the freelist type hygiene warnings in subsequent patches. > > start_isolate_page_range() > isolate_single_pageblock() > set_migratetype_isolate(tail) > lock zone->lock > move_freepages_block(tail) // nop > set_pageblock_migratetype(tail) > unlock zone->lock > __rmqueue_smallest() > del_page_from_freelist(head) > expand(head, head_mt) > WARN(head_mt != tail_mt) > start_pfn = ALIGN_DOWN(MAX_ORDER_NR_PAGES) > for (pfn = start_pfn, pfn < end_pfn) > if (PageBuddy()) > split_free_page(head) > > Introduce a variant of move_freepages_block() provided by the > allocator specifically for page isolation; it moves free pages, > converts the block, and handles the splitting of straddling buddies > while holding zone->lock. > > The allocator knows that pageblocks and buddies are always naturally > aligned, which means that buddies can only straddle blocks if they're > actually >pageblock_order. This means the search-and-split part can be > simplified compared to what page isolation used to do. > > Also tighten up the page isolation code around the expectations of > which pages can be large, and how they are freed. > > Based on extensive discussions with and invaluable input from Zi Yan. > > Signed-off-by: Johannes Weiner Nice cleanup of hairy code as well! Reviewed-by: Vlastimil Babka