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 40E50C433F5 for ; Mon, 9 May 2022 08:51:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8E3A6B0071; Mon, 9 May 2022 04:51:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3E606B0073; Mon, 9 May 2022 04:51:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2CD56B0074; Mon, 9 May 2022 04:51:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 94A696B0071 for ; Mon, 9 May 2022 04:51:47 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 62E2A60F09 for ; Mon, 9 May 2022 08:51:47 +0000 (UTC) X-FDA: 79445586654.23.E555A38 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 642D820063 for ; Mon, 9 May 2022 08:51:30 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KxZbC663yzGpfG; Mon, 9 May 2022 16:48:55 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 16:51:42 +0800 Subject: Re: [PATCH v2 2/4] mm/migration: remove unneeded lock page and PageMovable check To: David Hildenbrand CC: , , , , , , , , References: <20220425132723.34824-1-linmiaohe@huawei.com> <20220425132723.34824-3-linmiaohe@huawei.com> <525298ad-5e6a-2f8d-366d-4dcb7eebd093@redhat.com> From: Miaohe Lin Message-ID: Date: Mon, 9 May 2022 16:51:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <525298ad-5e6a-2f8d-366d-4dcb7eebd093@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 642D820063 X-Stat-Signature: 5bwppooipheu4zxn9az7ub6irgm8sswo Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1652086290-704115 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 2022/4/29 18:07, David Hildenbrand wrote: > On 25.04.22 15:27, Miaohe Lin wrote: >> When non-lru movable page was freed from under us, __ClearPageMovable must >> have been done. Even if it's not done, ClearPageIsolated here won't hurt >> as page will be freed anyway. So we can thus remove unneeded lock page and >> PageMovable check here. >> >> Signed-off-by: Miaohe Lin >> Reviewed-by: Christoph Hellwig >> --- >> mm/migrate.c | 8 ++------ >> 1 file changed, 2 insertions(+), 6 deletions(-) >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index b779646665fe..0fc4651b3e39 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1093,12 +1093,8 @@ static int unmap_and_move(new_page_t get_new_page, >> /* page was freed from under us. So we are done. */ >> ClearPageActive(page); >> ClearPageUnevictable(page); >> - if (unlikely(__PageMovable(page))) { >> - lock_page(page); >> - if (!PageMovable(page)) >> - ClearPageIsolated(page); >> - unlock_page(page); >> - } >> + if (unlikely(__PageMovable(page))) >> + ClearPageIsolated(page); >> goto out; >> } > > Hm, that code+change raises a couple of questions. > > We're doing here the same as in putback_movable_pages(). So I guess the > difference here is that the caller did release the reference while the > page was isolated, while we don't assume the same in > putback_movable_pages(). Agree. > > > Shouldn't whoever owned the page have cleared that? IOW, is it even > valid that we see a movable or isolated page here (WARN/BUG?)? > > At least for balloon compaction, I remember that __PageMovable() is > properly cleared before freeing it via balloon_page_delete(). z3fold, zsmalloc will do __ClearPageMovable when the page is going to be released. So I think we shouldn't see a movable page here: void __ClearPageMovable(struct page *page) { VM_BUG_ON_PAGE(!PageMovable(page), page); /* * Clear registered address_space val with keeping PAGE_MAPPING_MOVABLE * flag so that VM can catch up released page by driver after isolation. * With it, VM migration doesn't try to put it back. */ page->mapping = (void *)((unsigned long)page->mapping & PAGE_MAPPING_MOVABLE); } But it seems there is no guarantee for PageIsolated flag. Or am I miss something? > > > Also, I am not sure how reliable that page count check is here: if we'd > have another speculative reference to the page, we might see > "page_count(page) > 1" and not take that path, although the previous > owner released the last reference. IIUC, there should not be such speculative reference. The driver should have taken care of it. Thanks! > >