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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01065C433ED for ; Tue, 20 Apr 2021 10:35:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 35FAA610CC for ; Tue, 20 Apr 2021 10:35:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35FAA610CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 976856B0070; Tue, 20 Apr 2021 06:35:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FF3F6B0071; Tue, 20 Apr 2021 06:35:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C7706B0072; Tue, 20 Apr 2021 06:35:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 5FC536B0070 for ; Tue, 20 Apr 2021 06:35:42 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0D4143638 for ; Tue, 20 Apr 2021 10:35:42 +0000 (UTC) X-FDA: 78052389324.25.2B142F1 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf17.hostedemail.com (Postfix) with ESMTP id C435640002C6 for ; Tue, 20 Apr 2021 10:35:38 +0000 (UTC) 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> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C435640002C6 X-Stat-Signature: oaxut6rgbn6mjw9pxxgt4fw9j5jdz41i Received-SPF: none (suse.de>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1618914938-455284 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 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