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 DAD3AC433EF for ; Tue, 25 Jan 2022 13:19:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 532AF6B007B; Tue, 25 Jan 2022 08:19:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E1F26B007D; Tue, 25 Jan 2022 08:19:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383B36B0080; Tue, 25 Jan 2022 08:19:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 28EFF6B007B for ; Tue, 25 Jan 2022 08:19:53 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E021A182945CC for ; Tue, 25 Jan 2022 13:19:52 +0000 (UTC) X-FDA: 79068867024.20.77ADB3D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf27.hostedemail.com (Postfix) with ESMTP id 6B90740029 for ; Tue, 25 Jan 2022 13:19:50 +0000 (UTC) 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 C010621129; Tue, 25 Jan 2022 13:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1643116788; 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=W7ugEwGd8z1ciGcssO9NOuo6Y70kmTmAuz+RVBNhgQo=; b=OAQFnCJ9fJXwRf+XqgaH8z+GcXVjo9HxXhbpGWNi3xMFKm4awPudNVTJaJaXXs1dSxQj1I /htMCb/jE9Jo8zsCT8DVooqvtd6XAyQmf3X5bQaNYmHaXyRhOYiGujXcl4ae/nW4gqHHZG iIctFqchskLEpoSkcCX/nH6b9I06d44= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1643116788; 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=W7ugEwGd8z1ciGcssO9NOuo6Y70kmTmAuz+RVBNhgQo=; b=URWUxsOGxCPGESRThyQ7b2f2CoH5apJnVqlsxfRb5qW9qyCiYDfA7/lidO7XlY8xzuv09P oqD7gCa//062VVAA== 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 F330613DE5; Tue, 25 Jan 2022 13:19:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TzS6OPP472GbRwAAMHmgww (envelope-from ); Tue, 25 Jan 2022 13:19:47 +0000 Date: Tue, 25 Jan 2022 14:19:46 +0100 From: Oscar Salvador To: Zi Yan Cc: David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michael Ellerman , Christoph Hellwig , Marek Szyprowski , Robin Murphy , linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, iommu@lists.linux-foundation.org, Vlastimil Babka , Mel Gorman , Eric Ren Subject: Re: [PATCH v4 3/7] mm: page_isolation: check specified range for unmovable pages Message-ID: <20220125131943.GA5609@linux> References: <20220119190623.1029355-1-zi.yan@sent.com> <20220119190623.1029355-4-zi.yan@sent.com> <6AEF32AC-4E0D-41E0-8850-33B8BD955920@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6AEF32AC-4E0D-41E0-8850-33B8BD955920@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6B90740029 X-Stat-Signature: fx78emitas75fdn8334bd6doq3ws3ckk Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=OAQFnCJ9; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=URWUxsOG; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf27.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de X-HE-Tag: 1643116790-500271 Content-Transfer-Encoding: quoted-printable 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 Mon, Jan 24, 2022 at 12:17:23PM -0500, Zi Yan wrote: > You are right. Sorry for the confusion. I think it should be > =E2=80=9CPage isolation is done at least on max(MAX_ORDER_NR_PAEGS, > pageblock_nr_pages) granularity.=E2=80=9D >=20 > memory_hotplug uses PAGES_PER_SECTION. It is greater than that. Or just specify that the max(MAX_ORDER_NR_PAGES, pageblock_nr_pages) gran= urality only comes from alloc_contig_range at the moment. Other callers might wan= t to work in other granularity (e.g: memory-hotplug) although ultimately th= e range has to be aligned to something. > > True is that start_isolate_page_range() expects the range to be pageb= lock aligned and works in pageblock_nr_pages chunks, but I do not think t= hat is what you meant to say here. >=20 > Actually, start_isolate_page_range() should expect max(MAX_ORDER_NR_PAE= GS, > pageblock_nr_pages) alignment instead of pageblock alignment. It seems = to > be an uncovered bug in the current code, since all callers uses at leas= t > max(MAX_ORDER_NR_PAEGS, pageblock_nr_pages) alignment. >=20 > The reason is that if start_isolate_page_range() is only pageblock alig= ned > and a caller wants to isolate one pageblock from a MAX_ORDER-1 > (2 pageblocks on x84_64 systems) free page, this will lead to MIGRATE_I= SOLATE > accounting error. To avoid it, start_isolate_page_range() needs to isol= ate > the max(MAX_ORDER_NR_PAEGS, pageblock_nr_pages) aligned range. So, let me see if I get this straight: You are saying that, currently, alloc_contig_ranges() works on the bigges= t alignment otherwise we might have this scenario: [ MAX_ORDER-1 ] [pageblock#0][pageblock#1] We only want to isolate pageblock#1, so we pass a pageblock-aligned range= to start_isolate_page_range(), but the page belonging to pageblock#1 spans pageblock#0 and pageblock#1 because it is a MAX_ORDER-1 page. So when we call set_migratetype_isolate()->set_pageblock_migratetype(), t= his will mark either pageblock#0 or pageblock#1 as isolated, but the whole page wi= ll be put in the MIGRATE_ISOLATE freelist by move_freepages_block()->move_freepages= (). Meaning, we wil effectively have two pageblocks isolated, but only one ma= rked as such? Did I get it right or did I miss something? I know that this has been discussed previously, and the cover-letter alre= ady mentions it, but I think it would be great to have some sort of informati= on about the problem in the commit message as well, so people do not have to go an= d find it somewhere else. --=20 Oscar Salvador SUSE Labs