Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp309142pxv; Wed, 14 Jul 2021 04:37:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkl9i9KXBoAjLrEPqTQOI+Om23XL7Ve3gA4TrgGmnmsGFFtA87BCfuvPDgkZ35+5NgwkKX X-Received: by 2002:a05:6e02:de6:: with SMTP id m6mr6477289ilj.203.1626262678078; Wed, 14 Jul 2021 04:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626262678; cv=none; d=google.com; s=arc-20160816; b=xQkeiAqimAIYeNeAyOLv9ZD4vKvUYQ1U6S5RFdrr2rqUX9n3TvbB+pa9Vel4u28XsL 4Yed56lKelp3gIhlN5MgSJGlcJ7azpvMMzuw1GC1Q8vJ3NLJR5Wi4Ga8b+L1owq3YHVe 9gwrbXCGZrPdnuEY5kZMAfKgaAFC47WGnvRziLutMhzuQFDZDv1FkOiKSkrxJ/d/KAwt ivY2KxMR39EUwgx2h6i52nFF0YfHZLTgpU36qVM2N2QR8t6HVHYm/BsW3UMfamA38WH7 OnMLEa1Mq99FK7bBLwDMcUMqiV8PsPD3mjbXGv+sKLwh8OvmctDcKrfgb4lPzTic3Q/j V01Q== 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=rv35vi3UeUeoWhd1dBZjSgMALpVuTYUT3mNEcORvGLE=; b=Q6XcZ8QeRG3YGAIKbBQDlG4mzK7xHAw9RgTrXLb4ohyXFOtjIzDhQZEJI2Ogkzg1Gx B/WVBzJ9uxP+Bq36t1bRyK8M9BUMB38mD6neT+rZwbnOmG28kTvFE4Lg86GECRytkIeH sNtFCuzA4Gi9U87F/25hnTtUDE+h0FROEe17UDVptHpMfE3NCMc5xXXH3QpI7HiOks+G L2MLMuVJgQh5xn8eAirfGq33N63Ol7+Jvw/q81uugeGN0txjpNtI+TEvCiDNvKm8l0ym VJAsRNmj9KMycwoNm4bqxStGBaMqdwpJcSBvUz6nbcY2bsj0ZxzWZZh0gZrP8Dwm6OBb 9yIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si2389790jaq.119.2021.07.14.04.37.33; Wed, 14 Jul 2021 04:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230405AbhGNLjw (ORCPT + 99 others); Wed, 14 Jul 2021 07:39:52 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:11276 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbhGNLjw (ORCPT ); Wed, 14 Jul 2021 07:39:52 -0400 Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4GPwLd0rQxz1CJld; Wed, 14 Jul 2021 19:31:21 +0800 (CST) Received: from [10.174.178.125] (10.174.178.125) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 14 Jul 2021 19:36:58 +0800 Subject: Re: [PATCH 1/5] mm/vmscan: put the redirtied MADV_FREE pages back to anonymous LRU list To: Matthew Wilcox , Michal Hocko , Yu Zhao CC: , , , , , , , , , , , , References: <20210710100329.49174-1-linmiaohe@huawei.com> <20210710100329.49174-2-linmiaohe@huawei.com> <9409189e-44f7-2608-68af-851629b6d453@huawei.com> From: Miaohe Lin Message-ID: Date: Wed, 14 Jul 2021 19:36:57 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/7/13 21:34, Matthew Wilcox wrote: > On Tue, Jul 13, 2021 at 09:13:51PM +0800, Miaohe Lin wrote: >>>> When the MADV_FREE pages are redirtied before they could be reclaimed, the pages >>>> should be put back to anonymous LRU list by setting SwapBacked flag, thus the >>>> pages will be reclaimed in normal swapout way. >>> >>> Agreed. But the question is why this needs an explicit handling here >>> when we already do handle this case when trying to unmap the page. >> >> This makes me think more. It seems even the page_ref_freeze call is guaranteed to >> success as no one can grab the page refcnt after the page is successfully unmapped. > > NO! This is wrong. Every page can have its refcount speculatively raised > (and then lowered). The two prime candidates for this are lockless GUP > and page cache lookups, but there can be others too. > Many thanks for pointing this out. My overlook! Sorry! So, it seems lockless GUP can redirty the MADV_FREE page. But is it ok to just release a redirtied MADV_FREE pages? Because we hold the last reference here and the page will be freed anyway... > . >