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 83DB2CCA480 for ; Mon, 20 Jun 2022 09:05:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 275C16B007B; Mon, 20 Jun 2022 05:05:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 201378E0006; Mon, 20 Jun 2022 05:05:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 077E48E0005; Mon, 20 Jun 2022 05:05:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E65936B007B for ; Mon, 20 Jun 2022 05:05:18 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9E5D5603D3 for ; Mon, 20 Jun 2022 09:05:18 +0000 (UTC) X-FDA: 79598030316.18.5091D5F Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 46ABD100084 for ; Mon, 20 Jun 2022 09:05:17 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id c205so2928867pfc.7 for ; Mon, 20 Jun 2022 02:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3UAMRgLNUKIxsrxlZlgJWjAL/qolC/AWmLK/+MOtFbU=; b=UuqARljvt2lDepH6j3+On0x8yTeDj7JkXgMOkTHBJFvzV4XNnbPVVgNM9AMphFEIhh yBH/qPyqO8aHdFOHI4K/ZlSa0iGmE3KuvqtKemXbstoFSdxwuYy0EIhdf3X5Vfp4pzb3 hDBlFnp2xqY8vtn1RXCLYHTceZ19brPP4253HFAjAJr20ijxluZ48t/vOV+dvZtKE1Ri P3Qm1MhYnhC/yr4pk2ydDPYJockJvJ8+f/vEaUzO9L7nIKDiMWV+PCNzoJnLF5LToHhZ VOc2KL+3iaNPKJN6DYGb32YS6BDhcbEf3bQtfWtYbbiWH0rGP4vl1U/Vh+LlieBvlAfK unqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3UAMRgLNUKIxsrxlZlgJWjAL/qolC/AWmLK/+MOtFbU=; b=bjzKoQVSvQykAMi9g88hmwVI7AWTxTzgNBGpd+p3S6G0GlxdKxBBDhWQH6hryOvrPk erxBvS86U9RxskzAPUnrsaGaSFzdPnKoOfu6ZaJ0h1ytAvQuFeoBzGN2MCeHut/n4p92 epOr56RnnB6CWaBc0eOpza15sECFelQYQU/xLjNuW6F9Twvt9Y3VLhxpYVG5gXO47d+q pqiPHnBOEcpeiTCCMaOVJKqLf/xBjNYVjlsg5Ykp/mxs2jCGMTBwYFoFWdIBK+tlvHVc Bv26+FnS6Rn/FkWEtLE2BeBlrVi0jg48aL7vFqHH1BTNWE4aygoRWOS6EEItUIXN5cUk M4NA== X-Gm-Message-State: AJIora8zOUdByqgJLTqkmjjQguLhz8XT7e5P2PMQg9Np2m2P8rV/0UgO hnPSpMcuiCEOLeNT9OPAOD3wkQ== X-Google-Smtp-Source: AGRyM1uFneyj/aNF0LntK4npbU3wUwEEFOJ5Gi7b2Ac3jTlxoh2hJBKVvvO6kYk72pHsKmsc5l0txQ== X-Received: by 2002:aa7:8426:0:b0:525:23bf:1b78 with SMTP id q6-20020aa78426000000b0052523bf1b78mr4184127pfn.26.1655715915994; Mon, 20 Jun 2022 02:05:15 -0700 (PDT) Received: from localhost ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id b11-20020a170902650b00b001624b1e1a7bsm8059940plk.250.2022.06.20.02.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 02:05:15 -0700 (PDT) Date: Mon, 20 Jun 2022 17:05:10 +0800 From: Muchun Song To: Oscar Salvador Cc: David Hildenbrand , akpm@linux-foundation.org, corbet@lwn.net, mike.kravetz@oracle.com, paulmck@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com Subject: Re: [PATCH v4 2/2] mm: memory_hotplug: make hugetlb_optimize_vmemmap compatible with memmap_on_memory Message-ID: References: <20220619133851.68184-1-songmuchun@bytedance.com> <20220619133851.68184-3-songmuchun@bytedance.com> <226243a9-b4f5-182e-1a5b-7b8d5c28f3b3@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655715918; a=rsa-sha256; cv=none; b=i/8gc869z8D73L+MYED27b5453Bstd3cdnOyiWu5pIA6Lv07kyO5zB7goKVrPnFgFam/aN OsCPF+a9ZmWiJvL/k6KNW+iouiAvjB56/uqv2Dr1enltTzfbJEe1wS/Cpc1+/ZOTYwifE0 QIUSMS1cXjnuBJJR47qlhrgdyZl9UPk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=UuqARljv; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655715918; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3UAMRgLNUKIxsrxlZlgJWjAL/qolC/AWmLK/+MOtFbU=; b=IP0amYb2lUS4fXMe3zF2keC4domwd26cKWjllpI3y5sUSWHl+UoYvJ3qTbmRfdcauPK4r8 bm77kHrv2fxFbUS8Nm+IiI545E48SNFvsHdDCIg6c6ZK2qpBY/gPGd2nL13eMbC8iJ6YPZ aqsRdKLv6sKgGJWqJafHBX/OVWkFCoc= X-Rspamd-Server: rspam01 X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=UuqARljv; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Stat-Signature: oqkwwhh977mus7ff1gc7eywnw9x8s71g X-Rspamd-Queue-Id: 46ABD100084 X-HE-Tag: 1655715917-415350 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 Mon, Jun 20, 2022 at 10:44:40AM +0200, Oscar Salvador wrote: > On Mon, Jun 20, 2022 at 04:29:11PM +0800, Muchun Song wrote: > > > > Although it works, I think PageVmemmapSelfHosted() check for the 1st pfn's > > > > vmemmap page is not always reliable. Since we reused PG_owner_priv_1 > > > > as PG_vmemmap_self_hosted, the test is noly reliable for vmemmap page's > > > > vmemmap page. Other non-vmemmap page can be flagged with PG_owner_priv_1. > > > > So this check can be false-positive. Maybe the following code snippet is > > > > the solution. > > > > > > How could that happen for pages used for backing a vmemmap? > > > > > > > It cannot happen for memmap_on_memory case. Howwver, it can happen for other > > cases. E.g. the 1st pfn (of boot memory block) whose vmemmap page may be flagged > > as PG_owner_priv_1 (if PG_swapcache is set). Then, the check is false-positive. > > If this can really happen, which I am not that sure tbh, maybe a way out would be I need to clarify this only can be happened by using this approach implemented in this patch. For a boot memory block, the vemmmap pages are not slef-hosted. So the 1st pfn (of this memory block) can be allocated to other users. e.g. an anonymous page with PG_swapcache set. In this patch, ALIGN_DOWN(pfn, PHYS_PFN(memory_block_size_bytes())) will located on this anonymous page, then the check is false-positive. [ boot memory block ] [ section ][...][ section ] [ usable memory ] > to just define a new page-type as we did in previous versions of memmap_on_memory. > In that way we would not for flags, but for its type. > I think we do not need to introduced a new flag, we just make sure the page passed to PageVmemmapSelfHosted() is a backing page for vmemmap. Then we cannot incur false-positive. The feasible solution is walking page tables to find a vmemmap page's backing page. Thanks. > But as I said, I am not entirely sure about the potential fallout of what you mention. > > > -- > Oscar Salvador > SUSE Labs >