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 E01CDC433EF for ; Mon, 14 Mar 2022 17:14:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44BFE6B0071; Mon, 14 Mar 2022 13:14:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FA638D0002; Mon, 14 Mar 2022 13:14:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 275CC8D0001; Mon, 14 Mar 2022 13:14:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 179E66B0071 for ; Mon, 14 Mar 2022 13:14:03 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CAE8DA1C70 for ; Mon, 14 Mar 2022 17:14:02 +0000 (UTC) X-FDA: 79243639524.29.D5C1A63 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 4C24A100004 for ; Mon, 14 Mar 2022 17:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647278041; h=from:from:reply-to:subject:subject: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=iAONPV5TRI2rOpqSpmMyMB9BD5aXa/UL7zZiN1WaZes=; b=Iv8yu3xc9cCQ+qBG50MiYFM0yD/JlfG1vuvaHCfkX9Mu5ZprzGUdgTsHrl9mT7E9RJz2cU qCYAP6F9kXTrgvNwLDAM5touw8YlCH5iCyfDKGAQ6qrUKgeAOhncM81PGbfnsumpyZ5kjJ oIPJi6pO5XKioD3BfRv5a7h1/neJK/g= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-JVF128k5Nyu70Rbb6XM6NQ-1; Mon, 14 Mar 2022 13:14:00 -0400 X-MC-Unique: JVF128k5Nyu70Rbb6XM6NQ-1 Received: by mail-wm1-f71.google.com with SMTP id j42-20020a05600c1c2a00b00381febe402eso9924562wms.0 for ; Mon, 14 Mar 2022 10:14:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=iAONPV5TRI2rOpqSpmMyMB9BD5aXa/UL7zZiN1WaZes=; b=pwHCkhIyU9mzAewpVGw4ndRCUiMPrwxrWgAkTWFLuiaWTOiTWbKUsDo6thLqRfXqyv mP0ykPlwPC3flwasPqPajX2bRTB8/maWNFfo9lCoszP/LXEkqvQ1wgszGK//cJ6iFfKj xbOIQhfZU9ervYWASifclS2oOFnlUFvJJ3rY60Wc2ZD836blRKcDpDQRacVv+Ld+p4Zi maiT7Fu0DPSVxAPkY/lpbHi3eZSC0dNFdQHJpW4dbMOlheI9CbkaERKBdhK/4jUDNzqX RCjvQ71aH3PfDZ74EuRVq2PPMrKrHptkVLbct4+VMMxP/8dy4SN1drGTn0f4Dcab5IMT 5UIw== X-Gm-Message-State: AOAM5319NoFtsq8GcOCWD+YbwBTH+tPnJEiRgC923iIK8e91B1epiX6Q vVLlmKtrEZ3LhG18pFDrHGRmAtmeROXIOvMymlIN873PVp9sgaEnPFYKHYORj4T5WJ/XCIcruSJ L5dwCnSosxM4= X-Received: by 2002:a05:600c:3509:b0:389:f7f9:7b9d with SMTP id h9-20020a05600c350900b00389f7f97b9dmr183466wmq.4.1647278039380; Mon, 14 Mar 2022 10:13:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMlXe0JZo7IsQjOotU0ZRoQURVItzZT4okfGXuvey2OHb8WQ8UwWZCgbE8CFf15963Z28pvQ== X-Received: by 2002:a05:600c:3509:b0:389:f7f9:7b9d with SMTP id h9-20020a05600c350900b00389f7f97b9dmr183453wmq.4.1647278039145; Mon, 14 Mar 2022 10:13:59 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:9a00:b2c1:8682:b807:e870? (p200300cbc7049a00b2c18682b807e870.dip0.t-ipconnect.de. [2003:cb:c704:9a00:b2c1:8682:b807:e870]) by smtp.gmail.com with ESMTPSA id s17-20020adfbc11000000b001f023d197b8sm14086221wrg.68.2022.03.14.10.13.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Mar 2022 10:13:58 -0700 (PDT) Message-ID: <1623cd68-8437-9404-f183-153741bbf84c@redhat.com> Date: Mon, 14 Mar 2022 18:13:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 To: Zi Yan , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Vlastimil Babka , Mel Gorman , Eric Ren , Mike Rapoport , Oscar Salvador , Christophe Leroy References: <20220311183656.1911811-1-zi.yan@sent.com> <20220311183656.1911811-3-zi.yan@sent.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v7 2/5] mm: page_isolation: check specified range for unmovable pages In-Reply-To: <20220311183656.1911811-3-zi.yan@sent.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4C24A100004 X-Stat-Signature: my5898nr998o8m9jhnoewoc81qwu15z7 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Iv8yu3xc; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam02 X-HE-Tag: 1647278042-404455 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 11.03.22 19:36, Zi Yan wrote: > From: Zi Yan > > Enable set_migratetype_isolate() to check specified sub-range for > unmovable pages during isolation. Page isolation is done > at max(MAX_ORDER_NR_PAEGS, pageblock_nr_pages) granularity, but not all > pages within that granularity are intended to be isolated. For example, > alloc_contig_range(), which uses page isolation, allows ranges without > alignment. This commit makes unmovable page check only look for > interesting pages, so that page isolation can succeed for any > non-overlapping ranges. > > Signed-off-by: Zi Yan > --- > include/linux/page-isolation.h | 10 ++++++++ > mm/page_alloc.c | 13 +--------- > mm/page_isolation.c | 47 +++++++++++++++++++++------------- > 3 files changed, 40 insertions(+), 30 deletions(-) > > diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h > index e14eddf6741a..eb4a208fe907 100644 > --- a/include/linux/page-isolation.h > +++ b/include/linux/page-isolation.h > @@ -15,6 +15,16 @@ static inline bool is_migrate_isolate(int migratetype) > { > return migratetype == MIGRATE_ISOLATE; > } > +static inline unsigned long pfn_max_align_down(unsigned long pfn) > +{ > + return ALIGN_DOWN(pfn, MAX_ORDER_NR_PAGES); > +} > + > +static inline unsigned long pfn_max_align_up(unsigned long pfn) > +{ > + return ALIGN(pfn, MAX_ORDER_NR_PAGES); > +} > + > #else > static inline bool has_isolate_pageblock(struct zone *zone) > { > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 6de57d058d3d..680580a40a35 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -8937,16 +8937,6 @@ void *__init alloc_large_system_hash(const char *tablename, > } > > #ifdef CONFIG_CONTIG_ALLOC > -static unsigned long pfn_max_align_down(unsigned long pfn) > -{ > - return ALIGN_DOWN(pfn, MAX_ORDER_NR_PAGES); > -} > - > -static unsigned long pfn_max_align_up(unsigned long pfn) > -{ > - return ALIGN(pfn, MAX_ORDER_NR_PAGES); > -} > - > #if defined(CONFIG_DYNAMIC_DEBUG) || \ > (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) > /* Usage: See admin-guide/dynamic-debug-howto.rst */ > @@ -9091,8 +9081,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, > * put back to page allocator so that buddy can use them. > */ > > - ret = start_isolate_page_range(pfn_max_align_down(start), > - pfn_max_align_up(end), migratetype, 0); > + ret = start_isolate_page_range(start, end, migratetype, 0); > if (ret) > return ret; > > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index b34f1310aeaa..e0afc3ee8cf9 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -16,7 +16,8 @@ > #include > > /* > - * This function checks whether pageblock includes unmovable pages or not. > + * This function checks whether pageblock within [start_pfn, end_pfn) includes > + * unmovable pages or not. > * > * PageLRU check without isolation or lru_lock could race so that > * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable > @@ -29,11 +30,14 @@ > * > */ > static struct page *has_unmovable_pages(struct zone *zone, struct page *page, > - int migratetype, int flags) > + int migratetype, int flags, > + unsigned long start_pfn, unsigned long end_pfn) > { > - unsigned long iter = 0; > - unsigned long pfn = page_to_pfn(page); > - unsigned long offset = pfn % pageblock_nr_pages; > + unsigned long first_pfn = max(page_to_pfn(page), start_pfn); > + unsigned long pfn = first_pfn; > + unsigned long last_pfn = min(ALIGN(pfn + 1, pageblock_nr_pages), end_pfn); > + > + page = pfn_to_page(pfn); I think we should get rid of the page argument completely. The caller should pass in a reasonable [start_pfn, end_pfn) range, and to any necessary fixups to the range outside of this function. The goal should be to have pfn = start_pfn and replacing last_pfn by end_pfn. Ideally we'd end up with "This function checks whether the range [start_pfn, end_pfn) contains unmovable pages or not." What would be missing to achieve that? -- Thanks, David / dhildenb