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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 239C9EB64D9 for ; Thu, 6 Jul 2023 11:14:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2906D8D0002; Thu, 6 Jul 2023 07:14:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 219638D0001; Thu, 6 Jul 2023 07:14:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 094288D0002; Thu, 6 Jul 2023 07:14:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EB3678D0001 for ; Thu, 6 Jul 2023 07:14:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B4DD4140BDD for ; Thu, 6 Jul 2023 11:14:21 +0000 (UTC) X-FDA: 80980928322.04.6BF6795 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 7A33F40005 for ; Thu, 6 Jul 2023 11:14:18 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CJJRBVdL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688642058; h=from:from:sender: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:dkim-signature; bh=H8Pt2EKetP/aheWWVzGc8UrAuWjlf8RIxXM/qMLtVAo=; b=e1aG2Qs18vj9bI+dzEm8tWYHKNuUeky9mHWd5fWCYAqm1zshWAcpSa0JcQOtrTdzadOe74 nNZiFw+uf9EUeHoNArplZPuq23iWmqS/bbwl7s6FiWVNJFF2u4MSm9VJDjdoaQUhKveq3Y WPwOgXP9SqALBXRoQ66/D/eLowCskz0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CJJRBVdL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688642058; a=rsa-sha256; cv=none; b=z2nGsdg3OPFrDDbDQuAx0KbuhkcppJbp1jFxIssUZC5xJGnkoA2rMWryhkTBo0YSLGo6g3 44q/h173sSKeHUKGyGp8L/aGn4ElW2Qc8v2ErNGND0XEUo3TDaK2yrjOUrsxFu5adtt2hO yAv/AhRjrgt2ZDFNH8QXG0HJVz9sVvs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688642057; 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=H8Pt2EKetP/aheWWVzGc8UrAuWjlf8RIxXM/qMLtVAo=; b=CJJRBVdLxQgWcYAnYtxB3O+/LAUTh6MYBaARYg03yO/QdMGDlnV2NU4+T85Y2OI644YyHn Q6k8XvGeiejWEGL9C9y7LUs5Qdi65E5bbOi6TJfe2CqR/CnRFzT9JbSSXUWqEGV443HSkK UMa8Cdq7luGx8g881FTgj1pp7JTLw7c= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-GobdW7dzN9mCLMd1L7B-EA-1; Thu, 06 Jul 2023 07:14:16 -0400 X-MC-Unique: GobdW7dzN9mCLMd1L7B-EA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fa8db49267so3507025e9.3 for ; Thu, 06 Jul 2023 04:14:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688642055; x=1691234055; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H8Pt2EKetP/aheWWVzGc8UrAuWjlf8RIxXM/qMLtVAo=; b=IowZRlahzljob+ZgDsRa7wKbx8u7cudBTfHfDUU4V1GtwDj21+F9ZA8YcaagfzvY85 tHCXuNnflftr5A4DPDegOHzFFU8PKd3mvtSIvWftbGX4Bk5h3AZqzbEX2Or1o5hc9KU7 tOoKi0NSfWIaSEPKSbEMH8778W48k7OtlLcbG0olQNOGvHyIjiE8tUFhP45SHOihZh8Q /09cqTG+wTXrxAm+vNkFsy0nCnyM9L5Ph9Ub8dzfpxHf8VHmBtgK1ih6RXSxJctM440J aVfX0Wb9X+Ft1U2xFzxWSZPThVQcMbsDSDgFXU9yUHj79yxtqg1kZfxwItaQEKHWbTzP iSGg== X-Gm-Message-State: ABy/qLZ6caiF/vDeEDSPMtvfzC89/aXKoDgLVZl7OIxdm0inC8A5HKjQ 8lNEqvP8fZdKyixEYAEfUw4jGUC+WuiMhEZFkQVWOVXRhA99HsGd3uYRCCfjOVVqhn8jMLMwI5y FGCQa/4peve8= X-Received: by 2002:a1c:e909:0:b0:3fa:993f:acc1 with SMTP id q9-20020a1ce909000000b003fa993facc1mr1118488wmc.2.1688642055551; Thu, 06 Jul 2023 04:14:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVkHXGSeygh/G74BlvHOFNUx/DGIjm7xiAThEmiefEKNUvieIKgTiYIC/FTuqx5jlT4FxgTQ== X-Received: by 2002:a1c:e909:0:b0:3fa:993f:acc1 with SMTP id q9-20020a1ce909000000b003fa993facc1mr1118467wmc.2.1688642055143; Thu, 06 Jul 2023 04:14:15 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id f21-20020a7bcd15000000b003fa95890484sm1783225wmj.20.2023.07.06.04.14.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 04:14:14 -0700 (PDT) Message-ID: Date: Thu, 6 Jul 2023 13:14:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: Aneesh Kumar K V , linux-mm@kvack.org, akpm@linux-foundation.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: Oscar Salvador , Michal Hocko , Vishal Verma References: <20230706085041.826340-1-aneesh.kumar@linux.ibm.com> <20230706085041.826340-2-aneesh.kumar@linux.ibm.com> <72488b8a-8f1e-c652-ab48-47e38290441f@redhat.com> <996e226a-2835-5b53-2255-2005c6335f98@linux.ibm.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v2 1/5] mm/hotplug: Embed vmem_altmap details in memory block In-Reply-To: <996e226a-2835-5b53-2255-2005c6335f98@linux.ibm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7A33F40005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 165b99e8ktx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uaAt5bu1dmP1ZVNmyF4jOx1RMY1oJgg7RCIWrnAx6zDb+I7AxcuBjijdvTijBoxCxY5PZ/yY2S6uZrJXL4HoATORCvW4nQJwg321C1gM1j9XrncdSXQAFHBCUTu+hxC1BmM2LOvZAUSLHtRtdDtkgZ4NuBBaHMwuNa9eaZq5Uvf+o1i/+ifgBu8w3m0zOR9puQGAlEUdRTgoFeLKWfk4O6dt1XyLKDo59/7D2eGU7w+EL2EknyfOUD4fvpdveIKeQJSZJRNn9CBQ/1NZEjO0pDtl5CYzG1kae5bzFohy3yG37M9iGdhHqEK7RUp/NURMt2nFyiHdH2GEALsehUWsdgywezGdaUu852aIfcc/+AEwucEHcHOxoGMEV06rJrwwRfxOS3S9G3d6d/sCRtRRz3HsvU= 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 06.07.23 11:36, Aneesh Kumar K V wrote: > On 7/6/23 2:48 PM, David Hildenbrand wrote: >> On 06.07.23 10:50, Aneesh Kumar K.V wrote: >>> With memmap on memory, some architecture needs more details w.r.t altmap >>> such as base_pfn, end_pfn, etc to unmap vmemmap memory. >> >> Can you elaborate why ppc64 needs that and x86-64 + aarch64 don't? >> >> IOW, why can't ppc64 simply allocate the vmemmap from the start of the memblock (-> base_pfn) and use the stored number of vmemmap pages to calculate the end_pfn? >> >> To rephrase: if the vmemmap is not at the beginning and doesn't cover full apgeblocks, memory onlining/offlining would be broken. >> >> [...] > > > With ppc64 and 64K pagesize and different memory block sizes, we can end up allocating vmemmap backing memory from outside altmap because > a single page vmemmap can cover 1024 pages (64 *1024/sizeof(struct page)). and that can point to pages outside the dev_pagemap range. > So on free we check So you end up with a mixture of altmap and ordinarily-allocated vmemmap pages? That sound wrong (and is counter-intuitive to the feature in general, where we *don't* want to allocate the vmemmap from outside the altmap). (64 * 1024) / sizeof(struct page) -> 1024 pages 1024 pages * 64k = 64 MiB. What's the memory block size on these systems? If it's >= 64 MiB the vmemmap of a single memory block fits into a single page and we should be fine. Smells like you want to disable the feature on a 64k system. > > vmemmap_free() { > ... > if (altmap) { > alt_start = altmap->base_pfn; > alt_end = altmap->base_pfn + altmap->reserve + > altmap->free + altmap->alloc + altmap->align; > } > > ... > if (base_pfn >= alt_start && base_pfn < alt_end) { > vmem_altmap_free(altmap, nr_pages); > > to see whether we did use altmap for the vmemmap allocation. > >> >>>   +/** >>> + * struct vmem_altmap - pre-allocated storage for vmemmap_populate >>> + * @base_pfn: base of the entire dev_pagemap mapping >>> + * @reserve: pages mapped, but reserved for driver use (relative to @base) >>> + * @free: free pages set aside in the mapping for memmap storage >>> + * @align: pages reserved to meet allocation alignments >>> + * @alloc: track pages consumed, private to vmemmap_populate() >>> + */ >>> +struct vmem_altmap { >>> +    unsigned long base_pfn; >>> +    const unsigned long end_pfn; >>> +    const unsigned long reserve; >>> +    unsigned long free; >>> +    unsigned long align; >>> +    unsigned long alloc; >>> +}; >> >> Instead of embedding that, what about conditionally allocating it and store a pointer to it in the "struct memory_block"? >> >> In the general case as of today, we don't have an altmap. >> > > Sure but with memmap on memory option it is essentially adding that right?. At least on x86_64 and aarch64 only for 128 MiB DIMMs (and especially, not memory added by hv-balloon, virtio-mem, xen-balloon). So in the general case it's not that frequently used. Maybe on ppc64 once wired up. Is the concern related to the increase in the size of > struct memory_block ? Partially. It looks cleaner to have !mem->altmap if there is no altmap. -- Cheers, David / dhildenb