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=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 9B09FC433DB for ; Wed, 17 Mar 2021 14:59:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04FEE64E81 for ; Wed, 17 Mar 2021 14:59:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04FEE64E81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6C4606B007B; Wed, 17 Mar 2021 10:59:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69CA76B007D; Wed, 17 Mar 2021 10:59:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 516846B007E; Wed, 17 Mar 2021 10:59:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 35E8E6B007B for ; Wed, 17 Mar 2021 10:59:14 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E4484181AF5E1 for ; Wed, 17 Mar 2021 14:59:13 +0000 (UTC) X-FDA: 77929674186.17.F1676B0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 88D02A1BE44D for ; Wed, 17 Mar 2021 14:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615991748; h=from:from: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; bh=gmIgP4UWwJgCHils66nz5G9rnZUX+iOdxhYSZqPnsE8=; b=HXKDZo5jeYdHDUpbYOMeBBDvy5Nl28WAyvGbND8I00xHqA8e6P8Gz9slE9qgyC1XoBsJgy ryEdG8ROmFKgTq1oYF6HLJxbr4YzLGU5t5fQAyijN8py5tqyNBpc5Us6Z1EpwO6uyNZG9Y eh304f8GfyWJnYt+N7KZ/BWwHLfWlww= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-aqXzifotNNaEf8RYfHpfkw-1; Wed, 17 Mar 2021 10:35:46 -0400 X-MC-Unique: aqXzifotNNaEf8RYfHpfkw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46C51108BD07; Wed, 17 Mar 2021 14:35:44 +0000 (UTC) Received: from [10.36.112.124] (ovpn-112-124.ams2.redhat.com [10.36.112.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 151FC1001281; Wed, 17 Mar 2021 14:35:41 +0000 (UTC) Subject: Re: [PATCH v4 1/5] mm,memory_hotplug: Allocate memmap from the added memory range To: Oscar Salvador Cc: Andrew Morton , Michal Hocko , Anshuman Khandual , Vlastimil Babka , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210309175546.5877-1-osalvador@suse.de> <20210309175546.5877-2-osalvador@suse.de> <20210315102224.GA24699@linux> <20210317140847.GA20407@linux> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Wed, 17 Mar 2021 15:35:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210317140847.GA20407@linux> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Stat-Signature: bmofyspj37fwiaj8ogjyy3tcrqjkoo1t X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 88D02A1BE44D Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615991748-864765 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 17.03.21 15:08, Oscar Salvador wrote: > On Tue, Mar 16, 2021 at 06:45:17PM +0100, David Hildenbrand wrote: >>> I find that cross reference to vmemmap code a little hard to digest. >>> I would have assume that we don't have to care about PMDs in this >>> code here at all. The vmemmap population code should handle that. >>> >>> I think I already mentioned that somewhere, I think it should be like this: >>> >>> a) vmemmap code should *never* populate more memory than requested for >>> a single memory section when we are populating from the altmap. >>> If that cannot be guaranteed for PMDs, then we have to fallback >>> to populating base pages. Populating PMDs from an altmap with >>> sizeof(struct page) == 64 is highly dangerous. > > I guess you meant sizeof(struct page) != 64 > Yes! > But other usecases of using altmap (ZONE_DEVICE stuff) might not care whether > they have sub-populated PMDs when populating sections from altmap? Just assume you have two ranges [ ZONE_DEVICE 0 ][ ZONE_DEVICE 1] If the vmemmap of ZONE_DEVICE 1 could be taken from the altmap of ZONE_DEVICE 0, we could be in trouble, as both parts can be removed/repurposed independently ... > > Current vmemmap code populates PMD with PMD_SIZE if empty, and with basepages > if there are still holes. > >>> Assume we have sizeof(struct page) == 56. A 128 MiB section >>> spans 32768 pages - we need 32768 * sizeof(struct page) >>> space for the vmemmap. >>> With 64k pages we *can* use exactly one PMD. With 56k pages >>> we need 448 individual (full!) pages for the vmemmap. >>> >>> IOW, we don't care how vmemmap code will do the mapping. >>> vmemmap code has to get it right. IMHO, asserting it in >>> this code is wrong. >>> >>> >>> b) In this code, we really should only care about what >>> memory onlining/offlining code can or can't do. >>> We really only care that >>> >>> 1) size == memory_block_size_bytes() >>> 2) remaining_size >>> 3) IS_ALIGNED(remaining_size, pageblock_size); > > I agree with the above, but see below: > >>> Okay, please document the statement about single sections, that's >>> important to understand what's happening. >>> >>> My take would be >>> >>> bool mhp_supports_memmap_on_memory(unsigned long size) >>> { >>> /* >>> * Note: We calculate for a single memory section. The calculation >>> */ >>> unsigned long nr_vmemmap_pages = SECTION_SIZE / PAGE_SIZE; >>> unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); >>> unsigned long remaining_size = size - vmemmap_size; > > While it might be true that we need to back off from populating with altmap in > case PMDs are not going to be fully populated because of the size of the struct > page (I am not still not sure though as I said above, other usecases might not > care at all), I would go __for now__ with placing vmemmap_size == PMD_SIZE in > the check below as well. > > If the check comes true, we know that we fully populate PMDs when populating > sections, so the feature can be used. > > Then I commit to have a look whether we need to back off in vmemmap-populating > code in case altmap && !NOT_FULLY_POPULATED_PMDS. > > What do you think? If we check for IS_ALIGNED(nr_vmemmap_pages, PMD_SIZE), please add a proper TODO comment that this is most probably the wrong place to take care of this. -- Thanks, David / dhildenb