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 C577FC433EF for ; Mon, 20 Jun 2022 14:15:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 690456B0073; Mon, 20 Jun 2022 10:15:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6407D6B0074; Mon, 20 Jun 2022 10:15:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 509428E0001; Mon, 20 Jun 2022 10:15:23 -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 4276B6B0073 for ; Mon, 20 Jun 2022 10:15:23 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 112C9602AF for ; Mon, 20 Jun 2022 14:15:23 +0000 (UTC) X-FDA: 79598811726.27.9772A01 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf27.hostedemail.com (Postfix) with ESMTP id C305140013 for ; Mon, 20 Jun 2022 14:15:21 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id o18so2810901plg.2 for ; Mon, 20 Jun 2022 07:15:21 -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:content-transfer-encoding:in-reply-to; bh=DmB//D/LSYNMnH2xgULemxOw5o9iappAp34jQZEddSs=; b=o8egWsj4lRXnkeqxXw5VHRYIVps5VdNa+CzcHJyE0Pb4iMGV1/XbJaRtH4lr2qAu8v xtPrFYbZ10e2h6/ilbEdyDpSY1GPoh7VhivaCg7xX0nut2tSuk2ULYxiL/2rg4/vfmH5 LCv1wbpSeTpoE4Gj/TDg9AB4Vf1pEFWUrb7tYba9ABbn28uWDjxMrH3EuooTEZAQaNjV ZSujm5/hY4PLGGhvTSRf8LVuI2j6RihtdMgattmCrta5AI2lhFRx/aUpBdKUPV+6M7lW NmcPC4CRHfdznRLNYKEI8h0KHJIgyfeCsLLsXjjpYvfZYP3r08UJulZyjyWs+rSrmLJK bkkg== 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:content-transfer-encoding :in-reply-to; bh=DmB//D/LSYNMnH2xgULemxOw5o9iappAp34jQZEddSs=; b=CH2JDWhWeRsZZwctx63EimE830CEYa33Z7sAlKU3c/7vI67Ze1TDMP7Y8VBHC8orCA W1cpVIIQyzNVDaznL4hQTa+orHb4E13Ah7wDNTmSMWtoWwwZEqEO881muStd2zBGq0Cs qm/qoNTIg+brs8aixWlNdVKV2e27/oDcgZUyTysFyDDfqLeCZ7WK7o6ZGE6bwRAnYGiD 9Tkr4vPwgNMq1SXYNmxKfoPN/Qs7g9X6v37ONezDDCqo9RQkwEi/w0mWJDjD6VMDUlxb EfyY5ZkCkR53nxH37KpM8iKPhSoJaT0YeTFN5BjIBWWnUax3QENbMl5m85WyVWnQVq6h /8VA== X-Gm-Message-State: AJIora+oA4Uyu1zhy1E+TVgvl6GARmQs6kmGGpqtg24ET0dCIzQK7ZSC IxV9uPp8KnUO14erN3rxQuE/nA== X-Google-Smtp-Source: AGRyM1ugU+bQTMidOzp4N2Fc4lbEHGZc7loK2/xuGSo+EKAp7FqeMBjuC/KX7MpamF+73pMUL1RIUA== X-Received: by 2002:a17:902:6941:b0:168:b5f7:4bce with SMTP id k1-20020a170902694100b00168b5f74bcemr24176394plt.104.1655734520698; Mon, 20 Jun 2022 07:15:20 -0700 (PDT) Received: from localhost ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id o12-20020a62f90c000000b0051be16492basm9202042pfh.195.2022.06.20.07.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 07:15:20 -0700 (PDT) Date: Mon, 20 Jun 2022 22:15:16 +0800 From: Muchun Song To: Oscar Salvador Cc: akpm@linux-foundation.org, corbet@lwn.net, david@redhat.com, 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 v5 2/2] mm: memory_hotplug: make hugetlb_optimize_vmemmap compatible with memmap_on_memory Message-ID: References: <20220620110616.12056-1-songmuchun@bytedance.com> <20220620110616.12056-3-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655734522; a=rsa-sha256; cv=none; b=SRTWa06um2nB+ynRfdeE2cP7Q5Hqr1RjmdsmAHB2ki+GM50TLnWcHK0GhrmXus/70xRQi6 vcFIKIxBhv5m4itbfbuBGLt1pUuDxTD94Ft9Rqg1va/DtqO0ItF5p8hMvY6GxfQ9V8Jorf Iw97v8toSqs0sxUFaFTvsMsvHn2nC14= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=o8egWsj4; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf27.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.180 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=1655734522; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DmB//D/LSYNMnH2xgULemxOw5o9iappAp34jQZEddSs=; b=GHk2KNOxwal+vNrbdyyYjESvrGK/9XjQQ/ROC8f8hcbRN/WpAQ8ElkAmlKWjwNPHbIdbEy Lg43KMBAYFRzcXnIPPUC1lnu/K8rNnwq9jJKldyavJ5LdD8sUaa00VrVU4vO9lBNPht0x4 S9MCWSyJdCGBMUguQ5b49PwWdq9nY7A= X-Rspamd-Server: rspam01 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=o8egWsj4; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf27.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Stat-Signature: zgkpkcwte3z5pt9ipxbyfhh9mizq4edh X-Rspamd-Queue-Id: C305140013 X-HE-Tag: 1655734521-648957 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 03:19:33PM +0200, Oscar Salvador wrote: > On Mon, Jun 20, 2022 at 07:06:16PM +0800, Muchun Song wrote: > > + /* > > + * The READ_ONCE() is used to stabilize *pmdp in a register or > > + * on the stack so that it will stop changing under the code. > > + * The only concurrent operation where it can be changed is > > + * split_vmemmap_huge_pmd() (*pmdp will be stable after this > > + * operation). > > + */ > > + pmd = READ_ONCE(*pmdp); > > + if (pmd_leaf(pmd)) > > + vmemmap_page = pmd_page(pmd) + pte_index(vaddr); > > + else > > + vmemmap_page = pte_page(*pte_offset_kernel(pmdp, vaddr)); > > I was about to suggest to get rid of the else branch because on x86_64 > we can only allocate PMD_SIZE chunks when using an alternative allocator, > meaning that anything which is not a pmd_leaf can't be a PageVmemmapSelfHosted. > You are right. However, I think relaying on this condition is fragile and not straightforward compared to the check of PageVmemmapSelfHosted(). And the else branch is not in a hot path. So I'd like to stay with it. Does this make sense for you? > But then I went to check the other platform that supports memmap_on_memory (arm64), > and in there I can see that we fallback to populate basepages with altmap should > we fail to allocate a PMD_SIZE chunk. > I think it cannot be fail for memmap_on_memory case. Thanks.