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,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 B5E66C433F5 for ; Tue, 14 Sep 2021 11:45:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5971660FDA for ; Tue, 14 Sep 2021 11:45:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5971660FDA 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 EE5076B0071; Tue, 14 Sep 2021 07:45:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E6D1C6B0072; Tue, 14 Sep 2021 07:45:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0E9C900002; Tue, 14 Sep 2021 07:45:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id BE15C6B0071 for ; Tue, 14 Sep 2021 07:45:25 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6DE361802EC3F for ; Tue, 14 Sep 2021 11:45:25 +0000 (UTC) X-FDA: 78585998610.12.C7A4270 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 0BFDDF000090 for ; Tue, 14 Sep 2021 11:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631619924; 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=q9fG0GXTgfPaaKu4Yvjr2ry2QvBYCQiNNCWSY5wy0Vc=; b=in6b71WYCISDo5ak5Paspm0R+EOI7qUn1SACVswQLbimC9zj2QYR9lZY0I43J01FYI0S1o OldF8ox0Bp3kKBeVzTjW+7gNsDEJe+M9a/A77vg049apXDYexbjG7yi6/esLxbTQRva9Y5 17WFioeF+iwL/X9YSG3iDDzvJUVza08= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-pUurhLX4OPO6tzNL3ruSNw-1; Tue, 14 Sep 2021 07:45:23 -0400 X-MC-Unique: pUurhLX4OPO6tzNL3ruSNw-1 Received: by mail-wr1-f69.google.com with SMTP id m1-20020a056000180100b0015e1ec30ac3so568789wrh.8 for ; Tue, 14 Sep 2021 04:45:23 -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=q9fG0GXTgfPaaKu4Yvjr2ry2QvBYCQiNNCWSY5wy0Vc=; b=0tLkWoXVv6yIz/zFBENI2ApojBmv47Z6yzc0f+KUotPEmHnOOFZkcRJe5G47m7MlFT iIieG8DK12FB3FJElkrPws6zw6ZED+3QGd3emGR14X2NV8aDNlqxa3haxcefQcANfCmx w7vp3x8qQINwx3TwzRqzeyDcXlBRrepE/tL2hhH156eA/8dr928fLZ930pTgJTrrR2IL 2/Pyst1aF+YDkyIvHsuek4GsG5bYiPhQVcZBhyijNq6+6HxhVyXZL/wwfEYzk4r5ZxEQ 02NJqwpRwqoV6dag9am2tdIa0UAAIybmMyo7Asz7aA2hS50XCg2LZ+OhSbznGnddO/YU swZg== X-Gm-Message-State: AOAM532HCBGtaYuxeAiltGVIVOv8Cvwjb/7fejI0XOVuTBlbQFGpFVHw xaVjU/MfcjnUzGI/xx++7TzWje8elzPdE1Svn/ztievrctXP7ZrhrzMlGq4j5dwpmWmjp64PIhp cfUflfNMNrgQ= X-Received: by 2002:a1c:9d4e:: with SMTP id g75mr1727742wme.20.1631619922303; Tue, 14 Sep 2021 04:45:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0iinYgdQWF9r67eyUWiGOMAvKPAWDXoHcww68hjmRs5mA5wnoVHW0Itc4/2Gg0Mv94hNwMg== X-Received: by 2002:a1c:9d4e:: with SMTP id g75mr1727717wme.20.1631619922019; Tue, 14 Sep 2021 04:45:22 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6041.dip0.t-ipconnect.de. [91.12.96.65]) by smtp.gmail.com with ESMTPSA id n26sm839749wmi.43.2021.09.14.04.45.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Sep 2021 04:45:21 -0700 (PDT) Subject: Re: [PATCH v3] mm/page_isolation: guard against possible putback unisolated page To: Miaohe Lin , akpm@linux-foundation.org Cc: jhubbard@nvidia.com, vbabka@suse.cz, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210914114508.23725-1-linmiaohe@huawei.com> From: David Hildenbrand Organization: Red Hat Message-ID: <54ceacde-e36e-f0f7-6c8c-59a792ca252a@redhat.com> Date: Tue, 14 Sep 2021 13:45:20 +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: <20210914114508.23725-1-linmiaohe@huawei.com> 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: z7yc8zi1s3yuew7r8nmksjwahexys39a Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=in6b71WY; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.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: rspam03 X-Rspamd-Queue-Id: 0BFDDF000090 X-HE-Tag: 1631619924-156414 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 14.09.21 13:45, Miaohe Lin wrote: > Isolating a free page in an isolated pageblock is expected to always work > as watermarks don't apply here. But if __isolate_free_page() failed, due > to condition changes, the page will be left on the free list. And the page > will be put back to free list again via __putback_isolated_page(). This may > trigger VM_BUG_ON_PAGE() on page->flags checking in __free_one_page() if > PageReported is set. Or we will corrupt the free list because list_add() > will be called for pages already on another list. Add a VM_WARN_ON() to > complain about this change. > > Signed-off-by: Miaohe Lin > --- > v1->v2: > Add VM_WARN_ON to catch unexpected isolating failure. > v2->v3: > Change the patch description+subject and remove Fixes. > --- > mm/page_isolation.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index f93cc63d8fa1..f67c4c70f17f 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -94,8 +94,13 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype) > buddy = page + (buddy_pfn - pfn); > > if (!is_migrate_isolate_page(buddy)) { > - __isolate_free_page(page, order); > - isolated_page = true; > + isolated_page = !!__isolate_free_page(page, order); > + /* > + * Isolating a free page in an isolated pageblock > + * is expected to always work as watermarks don't > + * apply here. > + */ > + VM_WARN_ON(!isolated_page); > } > } > } > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb