Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp68167pxy; Tue, 20 Apr 2021 20:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys6caYzZlkWuDHxFnmmF8Or/u28hvCa5kuBPtCExjnvRXKdpBD/IqU83lTnrfDxDXnf7VT X-Received: by 2002:a17:90a:3e43:: with SMTP id t3mr9038353pjm.216.1618977081044; Tue, 20 Apr 2021 20:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618977081; cv=none; d=google.com; s=arc-20160816; b=WpQ//sEBLduIwHzcZsSy2eE2UhPnFkH1OJV61WOcPOhFJfX9Z2i7qNBI2Jm5GpRXX5 LSIXqfXQRoS18FWAvLBu/K+TaUCBSgVi2M92S6cXdY/EQeYUnnwPzUJpR9hpFpFLWTW3 LMaD+Xpv12IwGJ83eGgZUU6fd9ttFY2FT5KPy4Dmc9jnzuDuup2jDvuKW+jehzAHFCAV 8HEavEkNt0EXaudMPnZ+nG3cNq6lOzW1pet1UcaMj532Zzp/2rhqFAQU3cPk53tL4zkz t6mnXE1OPUq6e/FrdcRBnwrkqqxw7XOvc/p8trFcL9h/s5MpPUPCpj6I6A90JXl0FjR7 wUfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dUmL888r4a+LpYSIBfs7CscY/g54lCVXYOagGpbPjVM=; b=hcXNRzCiLwWXx8UcDo/DKB+fg0kzgC4SR4+/99vuU40Kd/lh69MJziZCNY0+uTAkS7 drc21zz+37asGa/RTQGSKvvmXuDFsBEvpf+LdXkAxScafjGtJCnkJDjDX5mOo0S9dFX3 skXgc65+/F+48IM9uK0QFn4AVmENTdEJ1785NwZOGgA3rE+aV3WDZAatKoAZMJ2qCVrV 0gIaLtxKOiieNFZKfg6VU7WHxlV8MHuagMXfOBfd26267BCrzUgELFCPwU67GkMfCd8c Jg/HC5kX3WoMq3wUr9GSdFv+3IO/yUzBmVyaTDvtJoSU1LiPWWuTW2E7e4i+iIS4t88P ICbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=Dc4Xe0xB; 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=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si1123037plh.12.2021.04.20.20.50.50; Tue, 20 Apr 2021 20:51:21 -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; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=Dc4Xe0xB; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234845AbhDUDml (ORCPT + 99 others); Tue, 20 Apr 2021 23:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233874AbhDUDmg (ORCPT ); Tue, 20 Apr 2021 23:42:36 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 598A7C06138B for ; Tue, 20 Apr 2021 20:42:02 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id h11so9734286pfn.0 for ; Tue, 20 Apr 2021 20:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dUmL888r4a+LpYSIBfs7CscY/g54lCVXYOagGpbPjVM=; b=Dc4Xe0xBbbGif9Gf3Rrn0GjZTgrU4YJB9/diduYpGSilOKnqXHUVIOuVuCYmz6C7Ly C0RiXXAJt+u5gtoqTx1oRhtMkru/P9kG8F6hfQLPSo/j99da+9NRQVokSgPt2wgSp/nL Qq9zRfpS2wQDKLkJDGc7lSUbJnQeb9EB7iv6Jj1+Gc6Vo3+gWw2rkNrn6gsiADQWDK7D tDmGYbpcgm71y32RH9mKhFwkr1L/K3Tlumc2K5RszcAm+wDKB3A+1LWpE99Zm6+fhlUH LVeFXy/tytc7OclmyaEAt9IppxoIQtfjlmcKJhrj6Ceu1GDwBNzriQTD/n3DWUBdnszo VhYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dUmL888r4a+LpYSIBfs7CscY/g54lCVXYOagGpbPjVM=; b=BdlbHjNUlRDtYz/cH2xi3vW6zgVf0/TNnPJfjBoywoPOuUuf/K26Qli1W+LG5W55Pz jWtSsE7jXhbquaGt6+FqYtryElVxNqORZ1ox2bskUcAO+amvUw2s2h/44Juozyc6ofos cv1q2GJdipAzPQ4rzpf6UFBz47erWL57/1ZKKGkQBQL7LlqodegGW9WYxnk73V14iKxp BczKnl5VlDWce+PAMOpL6O+MutBQpQp2usmK712SyvFLc8ncq0xFavDmfV7T/vLwyJIs ZQppO1W2ggKCLWQ+sMUAPV21PpqNhX8i8ptc/0IeqCv0d6pdRU/+AWnsLJZbnq760g2B pcdg== X-Gm-Message-State: AOAM531uUaMhCGi4hzGzFByovpmKIJZHyzmrg3LBa9CtkNebNsHmzzY9 nSXLj7zbK14zaaeaA1g0cXAuvrY5U9kVrfhoVM5xzQ== X-Received: by 2002:aa7:9af7:0:b029:264:b19e:ac9c with SMTP id y23-20020aa79af70000b0290264b19eac9cmr4284965pfp.59.1618976521815; Tue, 20 Apr 2021 20:42:01 -0700 (PDT) MIME-Version: 1.0 References: <20210415084005.25049-1-songmuchun@bytedance.com> <20210415084005.25049-9-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Wed, 21 Apr 2021 11:41:24 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v20 8/9] mm: memory_hotplug: disable memmap_on_memory when hugetlb_free_vmemmap enabled To: Oscar Salvador Cc: Jonathan Corbet , Mike Kravetz , Thomas Gleixner , Ingo Molnar , bp@alien8.de, X86 ML , hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , Alexander Viro , Andrew Morton , paulmck@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, Mina Almasry , David Rientjes , Matthew Wilcox , Michal Hocko , "Song Bao Hua (Barry Song)" , David Hildenbrand , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Joao Martins , Xiongchun duan , fam.zheng@bytedance.com, linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 20, 2021 at 6:35 PM Oscar Salvador wrote: > > On Thu, Apr 15, 2021 at 04:40:04PM +0800, Muchun Song wrote: > > bool mhp_supports_memmap_on_memory(unsigned long size) > > { > > + bool supported; > > unsigned long nr_vmemmap_pages = size / PAGE_SIZE; > > unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); > > unsigned long remaining_size = size - vmemmap_size; > > @@ -1011,11 +1012,18 @@ bool mhp_supports_memmap_on_memory(unsigned long size) > > * altmap as an alternative source of memory, and we do not exactly > > * populate a single PMD. > > */ > > - return memmap_on_memory && > > - IS_ENABLED(CONFIG_MHP_MEMMAP_ON_MEMORY) && > > - size == memory_block_size_bytes() && > > - IS_ALIGNED(vmemmap_size, PMD_SIZE) && > > - IS_ALIGNED(remaining_size, pageblock_nr_pages << PAGE_SHIFT); > > + supported = memmap_on_memory && > > + IS_ENABLED(CONFIG_MHP_MEMMAP_ON_MEMORY) && > > + size == memory_block_size_bytes() && > > + IS_ALIGNED(vmemmap_size, PMD_SIZE) && > > + IS_ALIGNED(remaining_size, pageblock_nr_pages << PAGE_SHIFT); > > + > > + if (supported && is_hugetlb_free_vmemmap_enabled()) { > > + pr_info("Cannot enable memory_hotplug.memmap_on_memory, it is not compatible with hugetlb_free_vmemmap\n"); > > + supported = false; > > + } > > I would not print anything and rather have > > return memmap_on_memory && > !is_hugetlb_free_vmemmap_enabled && > IS_ENABLED(CONFIG_MHP_MEMMAP_ON_MEMORY) && > size == memory_block_size_bytes() && > IS_ALIGNED(vmemmap_size, PMD_SIZE) && > IS_ALIGNED(remaining_size, pageblock_nr_pages << PAGE_SHIFT); OK. Will do. > > Documentation/admin-guide/kernel-parameters.txt already provides an > explanation on memory_hotplug.memmap_on_memory parameter that states > that the feature cannot be enabled when using hugetlb-vmemmap > optimization. > > Users can always check whether the feature is enabled via > /sys/modules/memory_hotplug/parameters/memmap_on_memory. If memory_hotplug.memmap_on_memory is enabled $ cat /sys/module/memory_hotplug/parameters/memmap_on_memory $ Y If memory_hotplug.memmap_on_memory is disabled $ cat /sys/module/memory_hotplug/parameters/memmap_on_memory $ N > > Also, I did not check if it is, but if not, the fact about hugetlb-vmemmmap vs > hotplug-vmemmap should also be called out in the hugetlb-vmemmap kernel > parameter. Make sense. I will update the doc. Thanks. > > Thanks > > -- > Oscar Salvador > SUSE L3