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 0D923EB64D9 for ; Thu, 6 Jul 2023 12:59:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48E0F6B0071; Thu, 6 Jul 2023 08:59:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 414FF6B0072; Thu, 6 Jul 2023 08:59:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28F3F8D0001; Thu, 6 Jul 2023 08:59:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 153F76B0071 for ; Thu, 6 Jul 2023 08:59:24 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 90AF6AFD5A for ; Thu, 6 Jul 2023 12:59:23 +0000 (UTC) X-FDA: 80981193006.12.E48DBE1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id BDB494000E for ; Thu, 6 Jul 2023 12:59:20 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DGLd9JQq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1688648360; 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=wlvbOLsD2Ke5G2QGVtKNYNTugeQY+Twg0zjBwi69P3g=; b=eN1fMSBz2owfZ9gCbS+KEzGlWO+5rbA9hwGkQedbwlPrDDgatw+5sI+9dpqCQhi8rh9Ii+ BSc3NxS2U6dQjT8Nv4wXa9ZBwVHcFlqslytp64oOqnpDNsVooFYIgdtgZhUm8MYMNdcNC5 ooBigyDVIFgRc8YDdtyFxNn1dHBgSc8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DGLd9JQq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1688648360; a=rsa-sha256; cv=none; b=Z4mdn7tZRsjkcJvZVUF5t2vixXayTaTvZ8pJjY+SDsCsQhEsQt5vRpwRGTWdARB0auwT1P Cpf356wdt6XTZ3j0ylMjmLQySbxb9Vfk/LsYkizqbTL7bSTQM1nULFbC0jdVu39EFuR8MA Hy1yzh1dx/Ju0DYqcskVlwgET9I9Jg4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688648359; 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=wlvbOLsD2Ke5G2QGVtKNYNTugeQY+Twg0zjBwi69P3g=; b=DGLd9JQq92SBvI1E/OjjpMNyQiWQc9x+xk9KKyCnd4MJong6EXEnfx2B0HKZWGx1V5F/Tf FmeIIMKhnoy7FLt159SVpHO2yTClzbzMYpCjPtUKC1dAExeEhzXPCXY3ZNEIWCx8UHTNHC HPcVhwN+Fph+cUhU2m6E9OwQUBwVfdg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-vA9ToS_lPPWXjXGVgkLOSA-1; Thu, 06 Jul 2023 08:59:18 -0400 X-MC-Unique: vA9ToS_lPPWXjXGVgkLOSA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f5df65f9f4so4066835e9.2 for ; Thu, 06 Jul 2023 05:59:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688648357; x=1691240357; 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=wlvbOLsD2Ke5G2QGVtKNYNTugeQY+Twg0zjBwi69P3g=; b=WqyA6P2OJjfnk3H3dl/so+V94iFiAkoFXtH1evQcO0LSfSpcCem9a1d76B0cMIX90C PU0OazWMhL6INOvOa2DNlH1O7j8Jpa7DaPZjqlgpYASKVuhcpDVXW3tStCBSbrK25ON9 f4dLwLoinbZqOhShtQkGHMBycC7A5fCBCGzCBU9UG47qNWDeKaimjZEnu9o3g5QPWvl7 zhu191zcGX1sIsC8DhqcyklMdNaUInxwz/X/MV27JwYwwgjseDqpgd7yZJem/zFsBFNy sBozwNOGHVx6ojsvbIEBAxr5YDXBIBeX7cR6W3rAyxWzVRM0iq5bGhagQcs84kKR/sR9 1x0w== X-Gm-Message-State: ABy/qLZ4ovrZy7xV4NMopAwfnqRil0VIuVRWDp2NirAxgrMVLzDJf6mK 0g+bExsxSjSFgNELfOnIWPN0QCopIgxKNQPt/NLMduKZbPKwC4+o8IUoRxa4QsbXA5RD/Wi7HRb xXi0sgGXngRM= X-Received: by 2002:a1c:7410:0:b0:3f7:3699:c294 with SMTP id p16-20020a1c7410000000b003f73699c294mr1356200wmc.29.1688648357428; Thu, 06 Jul 2023 05:59:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlEyKu727UsEqrmzpqu0iRg6TTkG6pBIpaeV4FZ5WWoAR+u1BpyUeV3Y7MLcJrozliOYt23XfA== X-Received: by 2002:a1c:7410:0:b0:3f7:3699:c294 with SMTP id p16-20020a1c7410000000b003f73699c294mr1356179wmc.29.1688648356999; Thu, 06 Jul 2023 05:59:16 -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 v19-20020a1cf713000000b003fbb00599e4sm5114363wmh.2.2023.07.06.05.59.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 05:59:16 -0700 (PDT) Message-ID: <256bd2f0-1b77-26dc-6393-b26dd363912f@redhat.com> Date: Thu, 6 Jul 2023 14:59:15 +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> <9ca978e7-5c09-6d92-7983-03a731549b25@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: <9ca978e7-5c09-6d92-7983-03a731549b25@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-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2R3MM3wZh8LfOCjjb/iDyEVJmFwAAHXKhr6W1 PXQLwHte qi42NUzJqnSPUgWicxXFyUACy/a+dLHR+SbVgusJsgN5cchyqacXWLmr7bVKaiaif7E0OhhbDEMuUT4NJGB9yeX4vvxr1WbS/I8JeHd/1Ttc/nfZnQMJgkkCGnGtiTq/NNMCWAaNjj+xAMyQTkWXtT1l4grs3zgWq5nPFvMB8QGMZwX1Z8frgBgSgLo8g0lugrDqeh0ta8TUoqEnch5hyqLexjfL95Kkzdk8figsuuZ+h3Cz9QnATGDHof0zkpHTB7f85XztY7GrCg5yXXhd55ciCxrXLrh/f0ypyTTneWX1OCtFJG0OXCEf39EGWMD50MjVpqyrH9D63XxF7kspOgDnFprOAyN91CsPMJQBMNNQdfs0= 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 14:32, Aneesh Kumar K V wrote: > On 7/6/23 4:44 PM, David Hildenbrand wrote: >> 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. >> > > But that part of vmemmap_free is common for both dax,dax kmem and the new memmap on memory feature. ie, ppc64 vmemmap_free have checks which require > a full altmap structure with all the details in. So for memmap on memmory to work on ppc64 we do require similar altmap struct. Hence the idea > of adding vmemmap_altmap to struct memory_block I'd suggest making sure that for the memmap_on_memory case your really *always* allocate from the altmap (that's what the feature is about after all), and otherwise block the feature (i.e., arch_mhp_supports_... should reject it). Then, you can reconstruct the altmap layout trivially base_pfn: start of the range to unplug end_pfn: base_pfn + nr_vmemmap_pages and pass that to the removal code, which will do the right thing, no? Sure, remembering the altmap might be a potential cleanup (eventually?), but the basic reasoning why this is required as patch #1 IMHO is wrong: if you say you support memmap_on_memory for a configuration, then you should also properly support it (allocate from the hotplugged memory), not silently fall back to something else. -- Cheers, David / dhildenb