Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4487013pxb; Tue, 25 Jan 2022 11:22:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwILMdpfyjuRxnoa2ujaAsS76lj1xsIh5HFD2aw38tUgkA02/G8DM234c1IDW/PYsqP0dqF X-Received: by 2002:a17:907:9495:: with SMTP id dm21mr16837511ejc.728.1643138525668; Tue, 25 Jan 2022 11:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643138525; cv=none; d=google.com; s=arc-20160816; b=cLIFw1bbaZCD/hbzh8SrUBpPB0us9DJPyjAnvxP5cvqlnIm5JE9nDzBWNOF9n77L6w +kiSonlCbXhlKAr/iD1tESi6x5sijDHk2RFYwIH+BNhN96QygLHN+IaT1OKBi/iyE2I7 Tu5Q9gihDD8Z7+vrQIDQlXBiF1sY0Nj0qVxkMQcFhvqFe3tDakJLD3NnpLB/imXvKlBm oDE8O3M5YBI5dzlfYwtsp/u1uNg6VB47JGAe4OBtuxPIBi+m9rupv7Bk+SrzckXUOqSf rTcG2+8kBYHph5jVPD7xMi0Saw0x8mQGycuwIj5jKGEwveQ9yI02dxQWVjStXQCAsLoD t6wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=W7ugEwGd8z1ciGcssO9NOuo6Y70kmTmAuz+RVBNhgQo=; b=ayq5wYS9Y4+dICwARO7cPUHUGpEn2BHg6YP8Zf9uwYtfdJNe+dmaavsW6vVcyNhoSk ds1UOvN+yI3oMfIKDT+IYyDpwAoxDh30SPdocTCEvs4+U1mQTiuiX81700fpMWv64diV 1vt3b8zyow2oVYFSPjSob2NdRXWYQOTcZItfwFA2WhV+33lPKRLVdyVz6WHEu0Z7bQTo bI0O/SOIRhqas8t9IgBhoRdpicun3L9bNiSMthAkXMsONqOxIqXo5TepWS5rgUOH5g7K vguMYM1yjxGsFzD+WxGEc0LFBcRxGjPReP3NsORLIqixL7BK/k6pyVdVd/NmQ3WbbXCF c2FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OAQFnCJ9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si6627760eds.244.2022.01.25.11.21.37; Tue, 25 Jan 2022 11:22:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OAQFnCJ9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1576705AbiAYNZd (ORCPT + 99 others); Tue, 25 Jan 2022 08:25:33 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:37748 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1576139AbiAYNUC (ORCPT ); Tue, 25 Jan 2022 08:20:02 -0500 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 Content-Transfer-Encoding: 8bit In-Reply-To: <6AEF32AC-4E0D-41E0-8850-33B8BD955920@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > “Page isolation is done at least on max(MAX_ORDER_NR_PAEGS, > pageblock_nr_pages) granularity.” > > memory_hotplug uses PAGES_PER_SECTION. It is greater than that. Or just specify that the max(MAX_ORDER_NR_PAGES, pageblock_nr_pages) granurality only comes from alloc_contig_range at the moment. Other callers might want to work in other granularity (e.g: memory-hotplug) although ultimately the range has to be aligned to something. > > True is that start_isolate_page_range() expects the range to be pageblock aligned and works in pageblock_nr_pages chunks, but I do not think that is what you meant to say here. > > Actually, start_isolate_page_range() should expect max(MAX_ORDER_NR_PAEGS, > pageblock_nr_pages) alignment instead of pageblock alignment. It seems to > be an uncovered bug in the current code, since all callers uses at least > max(MAX_ORDER_NR_PAEGS, pageblock_nr_pages) alignment. > > The reason is that if start_isolate_page_range() is only pageblock aligned > 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_ISOLATE > accounting error. To avoid it, start_isolate_page_range() needs to isolate > 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 biggest 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(), this will mark either pageblock#0 or pageblock#1 as isolated, but the whole page will be put in the MIGRATE_ISOLATE freelist by move_freepages_block()->move_freepages(). Meaning, we wil effectively have two pageblocks isolated, but only one marked as such? Did I get it right or did I miss something? I know that this has been discussed previously, and the cover-letter already mentions it, but I think it would be great to have some sort of information about the problem in the commit message as well, so people do not have to go and find it somewhere else. -- Oscar Salvador SUSE Labs