Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3226394pxb; Tue, 20 Apr 2021 03:37:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu3CvPIBzVHCz8XtCBCvgPbN9HFYU1HlU+e5DpgPD0A5wnHz/J7n2VgtU/0LQw26sBz74H X-Received: by 2002:a17:906:7104:: with SMTP id x4mr26899844ejj.101.1618915028146; Tue, 20 Apr 2021 03:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618915028; cv=none; d=google.com; s=arc-20160816; b=X5VCidj9VnjTxy4hfQKP6ycq8ZcmLUnpldk85Zm0zKUVct4MxrTjyA+t7KwwN7+Luk iR8cGAFcBwlMT3uls6WphSCPz5xfnKExjjxnhxb1pdUKUuhbtkc6aNP0fAzwVFcgO/Ny TnixDMBqG7lq6oGEIuSAa0v906ZerBADEoq+2l9YUAbRHJT5/todrezkBt/d9NMJP4DI /D9cqor4/4GtaUzhKuibICdmWf78Ag2sIO6jq6Ck8wrSPzyponBG/uJ2ZUDp13b/TwsZ Lrpf/eb4PyyNOXnat947lxdlaMu+K1Qff8bXetwbMu1mUQBoGcZ61oJZCRMA+N52GnLk juWQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=0++RBbqFjxMW5oxUZrNFaw40YdkOGskfl2uzmjMGybY=; b=y4gaeWWc8Fn0wdgc/TN8Ytqn7KG2jNHCf6IiqoDABeDY7mTvu45276YS5gimNjfl9z yjl26qoMxuZDHd/UZOQGJk7KQg8bHhKgmq0XQOkHOZnyiNmf8t0fv8UcBRkO+y+zux0a /qpsafRTwaoZQuEXi9pl+WKC4OzSYpvlyDM8QSSxNxLnuY63+8dzsGG3vWFfMYeAnG1c EL3J/tAufSNWiireiuqN6ptecSHYf6m4fjs4aIYLmgfEIrkV5BmrFQ2SzqkFu0NbA64Z mv+hCjWyREv+CySyPal7cE6t4eG0lUs0fSNZT+oyTJbu0U5WtwGxFAXbosibJKE0KmA1 KG8w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd23si14852790edb.598.2021.04.20.03.36.44; Tue, 20 Apr 2021 03:37:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbhDTKgM (ORCPT + 99 others); Tue, 20 Apr 2021 06:36:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:58584 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbhDTKgL (ORCPT ); Tue, 20 Apr 2021 06:36:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AE038AFC8; Tue, 20 Apr 2021 10:35:38 +0000 (UTC) Date: Tue, 20 Apr 2021 12:35:33 +0200 From: Oscar Salvador To: Muchun Song Cc: corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, mhocko@suse.com, song.bao.hua@hisilicon.com, david@redhat.com, naoya.horiguchi@nec.com, joao.m.martins@oracle.com, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v20 8/9] mm: memory_hotplug: disable memmap_on_memory when hugetlb_free_vmemmap enabled Message-ID: References: <20210415084005.25049-1-songmuchun@bytedance.com> <20210415084005.25049-9-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210415084005.25049-9-songmuchun@bytedance.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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. 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. Thanks -- Oscar Salvador SUSE L3