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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 5ACF2C433F5 for ; Mon, 13 Sep 2021 12:20:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 09FED60F58 for ; Mon, 13 Sep 2021 12:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 09FED60F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 972F1900002; Mon, 13 Sep 2021 08:20:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 922B66B0072; Mon, 13 Sep 2021 08:20:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EA14900002; Mon, 13 Sep 2021 08:20:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 6CAC66B0071 for ; Mon, 13 Sep 2021 08:20:31 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 302FB16961 for ; Mon, 13 Sep 2021 12:20:31 +0000 (UTC) X-FDA: 78582458262.24.672AD27 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf27.hostedemail.com (Postfix) with ESMTP id CE278700009E for ; Mon, 13 Sep 2021 12:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631535630; 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=dc6ekLOLHMsMtYs2HMXfatsRC2o+NJYfkVB406jRynY=; b=C8nlkjVV0ZodijDwrH9cO7pQ90ZqJZk7gXn3GLyHmO/0r2uBQR8MGA5cFqwb9vTbCGWETd Ce8ni/TlSeJpLnxZgLCe7J/eSY1LzQW1qXGjOtHSqLIP1sbcDiL0NYgDYgWv7R903GyRRd l2WA0cgNSXkiH11SH74DyANVAPIk4z8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-fdAlQH9qMzOHA0m8ayMEUA-1; Mon, 13 Sep 2021 08:20:28 -0400 X-MC-Unique: fdAlQH9qMzOHA0m8ayMEUA-1 Received: by mail-wr1-f72.google.com with SMTP id x7-20020a5d6507000000b0015dada209b1so1673154wru.15 for ; Mon, 13 Sep 2021 05:20:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=dc6ekLOLHMsMtYs2HMXfatsRC2o+NJYfkVB406jRynY=; b=2C6EA9DUrIsLTmcdk6IICaIrGsq8RJxqJ4v3kviwupj956YtR7t9Zo7KoJP5ELSWWZ Xn7vYpG10csJFI1T/Q6YGAH7qgzjvcN73x074CZmrQV7FuvrAUaob/1DqPr1de8Yqfnv 55BJOYKhJj2x+jDLVfn3CWEDxdI62mIBglaQdp0Xji6yUw5hX3NE5x+S7O4r6rSEouGq db0kCPSevWHtz0LbYr7Ru0sgv1Yqg8ZuhsQ8imZ/yyNnp8VmSlWl+mwXflFXUKNLxO2m vuEjv1m9SDG041YmdSqMdsfl7Nyx3theVEZ5bBXmJrW2haPjpqmF1aKnmN7ZDwIeQr7s ZAvw== X-Gm-Message-State: AOAM5306PxpmQYt9VCnZR0To+lRGg0RWiAXrYCadPVoOFQyvI/HmMPpB X/AXFtMaQlZnx0BNL9G+MSZKHw5A78tPiUksBq2EgH1MMYQ952ORlEvS/40zMzFfe+/NbRhiCqA uDz55k5C5ECU= X-Received: by 2002:adf:80eb:: with SMTP id 98mr12140643wrl.348.1631535627740; Mon, 13 Sep 2021 05:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqACPVeVpqdGbdZKyYWRSwo6XFlp8j0+JXG9OX6JdRQ4wyJBLWvBTheHOQ1up66bOZp7bZ0g== X-Received: by 2002:adf:80eb:: with SMTP id 98mr12140621wrl.348.1631535627518; Mon, 13 Sep 2021 05:20:27 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6576.dip0.t-ipconnect.de. [91.12.101.118]) by smtp.gmail.com with ESMTPSA id i18sm3635059wrn.64.2021.09.13.05.20.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Sep 2021 05:20:27 -0700 (PDT) Subject: Re: [PATCH v2] mm/page_isolation: fix potential missing call to unset_migratetype_isolate() To: Michal Hocko , Miaohe Lin Cc: akpm@linux-foundation.org, vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210913115125.33617-1-linmiaohe@huawei.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Mon, 13 Sep 2021 14:20:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Stat-Signature: 87544cb6nrwis5a14qitiyyi1bwqyzxp Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C8nlkjVV; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf27.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CE278700009E X-HE-Tag: 1631535630-298843 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 13.09.21 14:12, Michal Hocko wrote: > On Mon 13-09-21 19:51:25, Miaohe Lin wrote: >> In start_isolate_page_range() undo path, pfn_to_online_page() just checks >> the first pfn in a pageblock while __first_valid_page() will traverse the >> pageblock until the first online pfn is found. So we may miss the call to >> unset_migratetype_isolate() in undo path and pages will remain isolated >> unexpectedly. Fix this by calling undo_isolate_page_range() and this will >> also help to simplify the code further. > > I like the clean up part but is this a real problem that requires CC > stable? Have you ever seen this to be a real problem? It looks like > something based on reading the code. We discussed that it isn't an issue anymore (we never call it on memory holes), but might have been an issue on older kernels, back when we didn't have the "memory holes" check in the memory offlining path in place. Agreed, these details belong into this description. > >> Fixes: 2ce13640b3f4 ("mm: __first_valid_page skip over offline pages") >> Signed-off-by: Miaohe Lin >> Cc: >> --- >> v1->v2: >> Simplify the code further per David Hildenbrand. >> --- >> mm/page_isolation.c | 20 +++----------------- >> 1 file changed, 3 insertions(+), 17 deletions(-) >> >> diff --git a/mm/page_isolation.c b/mm/page_isolation.c >> index a95c2c6562d0..f93cc63d8fa1 100644 >> --- a/mm/page_isolation.c >> +++ b/mm/page_isolation.c >> @@ -183,7 +183,6 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, >> unsigned migratetype, int flags) >> { >> unsigned long pfn; >> - unsigned long undo_pfn; >> struct page *page; >> >> BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages)); >> @@ -193,25 +192,12 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, >> pfn < end_pfn; >> pfn += pageblock_nr_pages) { >> page = __first_valid_page(pfn, pageblock_nr_pages); >> - if (page) { >> - if (set_migratetype_isolate(page, migratetype, flags)) { >> - undo_pfn = pfn; >> - goto undo; >> - } >> + if (page && set_migratetype_isolate(page, migratetype, flags)) { >> + undo_isolate_page_range(start_pfn, pfn, migratetype); >> + return -EBUSY; >> } >> } >> return 0; >> -undo: >> - for (pfn = start_pfn; >> - pfn < undo_pfn; >> - pfn += pageblock_nr_pages) { >> - struct page *page = pfn_to_online_page(pfn); >> - if (!page) >> - continue; >> - unset_migratetype_isolate(page, migratetype); >> - } >> - >> - return -EBUSY; >> } >> >> /* >> -- >> 2.23.0 > -- Thanks, David / dhildenb