Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1337714pxb; Wed, 10 Feb 2021 06:18:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1ivR4mYh6e2G8cP/7AVeWcm6bwrbx0fgwESfUXBn/no6pHklfEyfuJS9CODJbTC4GKtSK X-Received: by 2002:a17:906:c1c1:: with SMTP id bw1mr3225824ejb.86.1612966679832; Wed, 10 Feb 2021 06:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612966679; cv=none; d=google.com; s=arc-20160816; b=zACP7PHAdo+nut+Gth35b4a+DfQHFfhFGluGL7l9gwKS6UhSOqSBJpagq3ymq4S3v9 4UfOBIdgbsaUG0ogy0BoBYmv2gCMKKiUVNTJkX8ALkOMt24r9L1uVI0zOCgjB/Rddxgf V9anDDQjkghTqzP8Gp7qBKJvJ0xZQvKwVQGvMwz+gPbwsaZ+fdcclvIshxwPh8ThNmPY M1PPxhf9K1Ctyt08NBIQFt4yEOyT5fU9so6SnNi3PMcAg2Qnv7+jKhuSvJl64CAwTSTz BM4Dr0NCAHGZrwCJ4D/B4OmT9GOcYB/XmJaj9YD3YfV4k8pVQW/qNHIPeson7TQ3GWLf fK9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9pLTn/4GL5/gC578am6LgEu7kPuN+yRyeaLlC2bJBqE=; b=dHNIXMq9iFCdUObr+lZGSiUEcpV4iMJNbS/at+1mLiZVpk/b/qxTS4ndqVbRm6ZI0O 5kd0BxFFw/fAbxTG6wYENGnwhc7o99p7gFyyRambpUG7rSpLuwv+mGp/BTclqH0xmDOf bEJqPrTmnebnQAH8Ph0a8LaPUjmB3MpdppTYuov0bo1tVMnulx9bd35DC+ICdW5AOtln Ra8sw0VhXXc1MQOvh/Ou9hY0fJNg5DbIuAjxVbfeyQ2BjUxcaBiMqYphBis9IJZ5VhMV heZLvGbHSa86vh7LyYMP/9FF7VqPSIHLxXr2IVs3zP0c60NzFRo1QF359G5qD4/zTPzN VHJw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si1506915edz.582.2021.02.10.06.17.35; Wed, 10 Feb 2021 06:17:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhBJOQs (ORCPT + 99 others); Wed, 10 Feb 2021 09:16:48 -0500 Received: from mx2.suse.de ([195.135.220.15]:59092 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232110AbhBJOPL (ORCPT ); Wed, 10 Feb 2021 09:15:11 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7E9F1AC43; Wed, 10 Feb 2021 14:14:27 +0000 (UTC) Date: Wed, 10 Feb 2021 15:14:25 +0100 From: Oscar Salvador To: David Hildenbrand Cc: Mike Kravetz , Muchun Song , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/2] mm,page_alloc: Make alloc_contig_range handle in-use hugetlb pages Message-ID: <20210210141425.GB3636@localhost.localdomain> References: <20210208103812.32056-1-osalvador@suse.de> <20210208103812.32056-2-osalvador@suse.de> <6aa21eb3-7bee-acff-8f3c-7c13737066ba@redhat.com> <20210210140941.GA3636@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 03:11:05PM +0100, David Hildenbrand wrote: > On 10.02.21 15:09, Oscar Salvador wrote: > > On Wed, Feb 10, 2021 at 09:56:37AM +0100, David Hildenbrand wrote: > > > On 08.02.21 11:38, Oscar Salvador wrote: > > > > alloc_contig_range is not prepared to handle hugetlb pages and will > > > > fail if it ever sees one, but since they can be migrated as any other > > > > page (LRU and Movable), it makes sense to also handle them. > > > > > > > > For now, do it only when coming from alloc_contig_range. > > > > > > > > Signed-off-by: Oscar Salvador > > > > --- > > > > mm/compaction.c | 17 +++++++++++++++++ > > > > mm/vmscan.c | 5 +++-- > > > > 2 files changed, 20 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/mm/compaction.c b/mm/compaction.c > > > > index e5acb9714436..89cd2e60da29 100644 > > > > --- a/mm/compaction.c > > > > +++ b/mm/compaction.c > > > > @@ -940,6 +940,22 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > > > > goto isolate_fail; > > > > } > > > > + /* > > > > + * Handle hugetlb pages only when coming from alloc_contig > > > > + */ > > > > + if (PageHuge(page) && cc->alloc_contig) { > > > > + if (page_count(page)) { > > > > > > I wonder if we should care about races here. What if someone concurrently > > > allocates/frees? > > > > > > Note that PageHuge() succeeds on tail pages, isolate_huge_page() not, i > > > assume we'll have to handle that as well. > > > > > > I wonder if it would make sense to move some of the magic to hugetlb code > > > and handle it there with less chances for races (isolate if used, > > > alloc-and-dissolve if not). > > > > Yes, it makes sense to keep the magic in hugetlb code. > > Note, though, that removing all races might be tricky. > > > > isolate_huge_page() checks for PageHuge under hugetlb_lock, > > so there is a race between a call to PageHuge(x) and a subsequent > > call to isolate_huge_page(). > > But we should be fine as isolate_huge_page will fail in case the page is > > no longer HugeTLB. > > > > Also, since isolate_migratepages_block() gets called with ranges > > pageblock aligned, we should never be handling tail pages in the core > > of the function. E.g: the same way we handle THP: > > Gigantic pages? (spoiler: see my comments to next patch :) ) Oh, yeah, that sucks. We had the same problem in scan_movable_pages/has_unmovable_pages with such pages. Uhm, I will try to be more careful :-) -- Oscar Salvador SUSE L3