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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C991C433DB for ; Wed, 10 Feb 2021 14:14:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5136B64E7D for ; Wed, 10 Feb 2021 14:14:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5136B64E7D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D29E76B0006; Wed, 10 Feb 2021 09:14:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CDAFC6B0071; Wed, 10 Feb 2021 09:14:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEFAA6B0075; Wed, 10 Feb 2021 09:14:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id A88906B0006 for ; Wed, 10 Feb 2021 09:14:29 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 681C482B86FD for ; Wed, 10 Feb 2021 14:14:29 +0000 (UTC) X-FDA: 77802553458.01.humor19_3c115bf27610 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 47A461019E8F1 for ; Wed, 10 Feb 2021 14:14:29 +0000 (UTC) X-HE-Tag: humor19_3c115bf27610 X-Filterd-Recvd-Size: 3844 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 14:14:28 +0000 (UTC) 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: 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 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