Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2986420iog; Mon, 20 Jun 2022 08:49:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vei9A9Rhrzbby0di0bspDZpxkHX+cGaYEGj0C7TTpQEdMRq/5yOxkWBTb+YPqF8kWBAzhJ X-Received: by 2002:a50:fb13:0:b0:435:90d1:19ca with SMTP id d19-20020a50fb13000000b0043590d119camr1300954edq.159.1655740154689; Mon, 20 Jun 2022 08:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655740154; cv=none; d=google.com; s=arc-20160816; b=ddeFQdxOm0OzqqRsPeHrZRiR7umAFbzyecFX94CYWJG2qUgobU0Q0HtrVQB0NSiZJM Y+Ji10zhPHAAHoaF71oNKrInnAqf7GyGuhIt9+31WB95soGUAfAlVMf5cfq/Ir7NuXJA 5mgTGO0xf16ySwcnMUcQwwYDKPl5whNW0srHUKpXIj7owXyVwAlP083bSUXY7UPfkwJb APmcEI0Sz/eks8F3SIjDHQRzSbnspSBKhSXtLZJPJpCbKiy7zasdBes5adYc+K2vazIi YtFhy4iLYUygYthmCrtWiXrt7eWhmWzlheGakEnbUKKDyCIdfYjiCFVc4LQhsqaYSc+o v8yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DmB//D/LSYNMnH2xgULemxOw5o9iappAp34jQZEddSs=; b=rDvIfB7of9JSjHXmI7aSHDc6h4+9lBXh+6TLWPulIPMnY+QTrc/Ng3NUQbjOHjtbZE ZHaV0BWGodbaw6MjEL0+FsnM/4lp5dSWTfT+RVFPbWPF25IJ1RjXeUnL2WnlggWTXSNr +jPqQ3JRTVwRz/LQVWtZz7Dp6IwwVHldBQpAngobTZiwfLmYAMmhD9EYW+qhJdlnn3Px OwDA+gEAuEu+xB8BmDUBS26yg8imQLLFxInzZ/+vHD86pb/ca6ovqyB5hNrleskQdPZT 5Yr6GJYxzi5LPNcqesL4eLflFXBkv3lA4SFCrcJxoU8y1CSGedzHm54fT1ViOPjd7oRT l0Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=o8egWsj4; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z27-20020a17090674db00b00711f5909130si12492573ejl.383.2022.06.20.08.48.48; Mon, 20 Jun 2022 08:49:14 -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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=o8egWsj4; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236809AbiFTO5X (ORCPT + 99 others); Mon, 20 Jun 2022 10:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbiFTO4b (ORCPT ); Mon, 20 Jun 2022 10:56:31 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3100F3F8B5 for ; Mon, 20 Jun 2022 07:15:21 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id 73-20020a17090a0fcf00b001eaee69f600so10439000pjz.1 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=FxtL9KnVCJ9m80Vse3LVgcR0iMHuDXqOaQE4MBx97c4mpR1EuPsZ+8wD5orBbD4y+A ErYj+uSKIErL8IO+cvbOhTsJNL6B4pJ9c+BLRFM7bQiigYm2cT5Ltyf0stzu56a97+OI SU2bogl3eme4Jj2G4AJ0keVQghBrNSgwoxP4gKxy1anCbswVZpSqP4vsIrQQTmZiAkzo Cm1YirQc4+g70ziuQmknlnF+oAe1r7cIPjj9iojPKIqI2Jf9lFofqo4NZ4pxu+0qBhMU dtU6ReD8mqNV1jlA2S4I8Lvv3RN2Jc4Wft+AsXe4fN0a8heaMvPwbDCwAuquO7S41vG3 z+cA== X-Gm-Message-State: AJIora9mS+J4NRnG2I2AKA6ih6seGwL7SoGAgnZLpDUqQTlrjOFGER+u zxDIsdPvrkmSpmJqTj4FahL2Gg== 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: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 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.