Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp734719iob; Thu, 12 May 2022 03:37:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWIV/kXiC3PmLtGje0A8bEuUhfpMH6IXTkWdk37W5L9sRDqcBks+18N0gPRmyweLKOVezt X-Received: by 2002:aa7:d9d9:0:b0:425:fcc7:d132 with SMTP id v25-20020aa7d9d9000000b00425fcc7d132mr33834628eds.89.1652351841345; Thu, 12 May 2022 03:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652351841; cv=none; d=google.com; s=arc-20160816; b=oJdqIb7+3TfnqnmDd5CnZL9TprvzdOyq//xyR0ANfEqh8stPO/+Ke8/z2DofvsokbN uI5WOark2t+vz62wk7sRS5xBofgQ170J1iRwtoKWThAM8TWBMdZ+cSE2HQriDbfPc7Y2 Hk5fvjW3m9I6z4LNQhfNMSD//i62VGotaTv6TLXbpyc7dhCX9mT7UsPpZ5HcArde1AL5 aIonqtRZGQ5zCfHO4K2gGqTAFgw76ywtmwapEiM6S8Vs+Wciievs4YifbEdsO8rgA7To dcp13Qwwf9tEm0ewgDcLWnt/iHkzedxTX4EgKYBIDWCGV6OTro9mtiPsSY707jCjPb3X E4cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=9io/eYNwoy0koBsloEDBfL7z//LSmoz9cLFW8NCxFkI=; b=Es0BgeLCcpNYh10dGPVYV96h8iVNhZzXZfynhSs39oA3lXQ3dbwnVWJ9EWznHTBY3J XBAkNYMaUR7xc6vYxtT/BrS2lXtPsD+1yctM03P7wAcvW5DV/uHrQZvvZgNbv8wsJasd eJeHNdYuhxTlsg3BykRaO4LB01cZJYa2yNb04kJYe6+BW1E92WnqDvGmq0TYA+3w40v5 DR3rLfpiG58KVE4DNZY+1ZaNLIIgtPR5wyyZWxQ5ZQQRA1X2401aFcMBMGX/T2bVX+2Y 5ZDVYqDZRvMfVrhbv2BqCUxmRPpQ5Q58106MPpkTA/VSLwOi6TE1UHM36LxiqICc8kxj eY3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb6-20020a170907160600b006e87fcf4cc5si7333172ejc.734.2022.05.12.03.36.54; Thu, 12 May 2022 03:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240497AbiELCZu (ORCPT + 99 others); Wed, 11 May 2022 22:25:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbiELCZs (ORCPT ); Wed, 11 May 2022 22:25:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39EB7F0E for ; Wed, 11 May 2022 19:25:41 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KzFx30hdSzgYxB; Thu, 12 May 2022 10:25:11 +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; Thu, 12 May 2022 10:25:39 +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> <4cf144a9-fff5-d993-4fcb-7f2dfa6e71bb@redhat.com> From: Miaohe Lin Message-ID: <924de987-202b-a97e-e6d2-6bdab530f190@huawei.com> Date: Thu, 12 May 2022 10:25:39 +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: <4cf144a9-fff5-d993-4fcb-7f2dfa6e71bb@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: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/5/11 23:23, David Hildenbrand wrote: > On 09.05.22 10:51, Miaohe Lin wrote: >> On 2022/4/29 18:07, David Hildenbrand wrote: snip >> >> 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? > > At least the code we have now: > > if (unlikely(__PageMovable(page))) > ClearPageIsolated(page); > > Should be dead code. So PG_isolated could remain set. > > If PG_isolated is still set, it will get cleared in the buddy when > freeing the page via > > page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; Yes, check_free_page only complains about flags belonging to PAGE_FLAGS_CHECK_AT_FREE and PG_isolated will be cleared in the buddy when freeing the page. But it might not be a good idea to reply on this ? IMHO, it should be better to clear the PG_isolated explicitly ourselves. > >> >>> >>> >>> 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. > > How can you prevent any kind of speculative references? > > See isolate_movable_page() as an example, which grabs a speculative > reference to then find out that the page is already isolated by someone > else, to then back off. You're right. isolate_movable_page will be an speculative references case. But the page count check here is just an optimization. If we encounter speculative references, it still works with useless effort of migrating to be released page. Thanks! >