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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D328CC27C44 for ; Fri, 31 May 2024 09:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IlmF+eqKv8NhoQnOgXhryyfeT+zlhGKwDMZuYf576wE=; b=e/NIv3OzXk4e90 SZdqaZQFefdWSkj+Ipt//76FbM4nJ3te6EYb4P9KndMSnj/Eg5p9AWyZA9lAOSz5uFWyd5KJrRdf+ 8xke+X/V9+mx5P/+qSnjAY9gpoH2+58q7jpjLb/uW8iKIaIiyiXh8AFczrrQ/7/XJiLlM0ZJFNtF7 FDmffGnK7N4+jCueQ9sQp4sCT9SZ0vZKx+Pg5tMhtSC1oHCufCX8li/Nt1ipy3RPtXHCpnAy9F5bs 4HZV0DGaA71FySyTwOG4OH3AL9ZPikmKz1fRWdePPHT/V6x3WJ4u2Bje0Zbe0o7sgBAZxTt3EweDy vV/DrnAPNYGC9wZd7NTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCyyu-00000009rkb-2SEC; Fri, 31 May 2024 09:55:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCyym-00000009ri2-2bLl for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 09:55:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717149313; 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:autocrypt:autocrypt; bh=n0X3AjZ12x1/Mcs1Z4Sjp/H7xN03mP51ZGWklROZHwc=; b=Q+6CdeIiV5gQ7smy6ledsJyXtatEbDkg3E3YsqMH2w5Lhw+WglR4xmH1oCskyh4GLrIa/L taQIWN0whHfBeO7eOR4+6CHeXgvohgTK0oesXI2Yv4EFMjxi4LLllksFpyYAUJ7AFKpXF7 EyFkXGDTwBDEa1HrY3SnMUv8oFvLe2c= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-OavtW5shMLez73V-7KRuyQ-1; Fri, 31 May 2024 05:55:11 -0400 X-MC-Unique: OavtW5shMLez73V-7KRuyQ-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ea93c06e3cso5783761fa.2 for ; Fri, 31 May 2024 02:55:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717149310; x=1717754110; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=n0X3AjZ12x1/Mcs1Z4Sjp/H7xN03mP51ZGWklROZHwc=; b=iNOV9/cvbXr81g9E2m/H8Cvu94MG/qT1qhAhA1nNHvLbXfLIqCatxjXIX8U5VF9HFI 9HpBw8t88qR1vcW/94RF36zYlUYh/azp4eo54LvCQt2HDNlezfvegEVHyHsnEw0BMuNS u9P036R2Mx0eND5yOZ706ITxCRAjHOmHDpRmt9G/3KSeeuog4cp3nZPQ6GkFKLEjzZJn rG+diWt6OmRMhliEpI9TGNY3OIOr5TCfDXhHanYZygpdBbxFJwTZFWZHzb3LKTB5RBRd 1i8FEx8sT8wIM/lT8VMRHssjEaiO65Qv40wxGwdEpEh7Rctq/CIaeTbPvD8ifyCaj8sJ MB6w== X-Forwarded-Encrypted: i=1; AJvYcCXv0onnSR3/ltVv8v/Xf/kdKLwfA1LShW2UvLb8KcP591YHDUP7wVvAdhzGbPNpwSaVC7Mn1J5wWAn2+snEQje5D4A/cGQJ2aRfIodGETqs1Ytrh3o= X-Gm-Message-State: AOJu0YxhRSEneZwTV6wpUdQcNBDv7LgKXjC1xoq/pXJ+X3yYPSBwwWVD /IfMNall/O0oCipl4FPvHb3kIgbsuveL6krLpa71HhAcjvqFBe6yzTVvpNTbuWrmhyOEFh1zCML S+zCa/R43Y3fuKzvIM3ZfkjLFb3iUnx5x9qiS6W2tpYugOXL0o+0Q9Otz5J+SOHtTvk+bcTvH X-Received: by 2002:a2e:9788:0:b0:2ea:82c7:bf6b with SMTP id 38308e7fff4ca-2ea951d6785mr9287431fa.49.1717149310361; Fri, 31 May 2024 02:55:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPYeYdU/A2TS42add9j01Yf3CcHxljRjCcMxn+uKUnR6lcUFaR5DzAvUXG5371qKUh5zYsBw== X-Received: by 2002:a2e:9788:0:b0:2ea:82c7:bf6b with SMTP id 38308e7fff4ca-2ea951d6785mr9287211fa.49.1717149309777; Fri, 31 May 2024 02:55:09 -0700 (PDT) Received: from ?IPV6:2003:cb:c717:a000:d4df:4b8f:37d4:59e4? (p200300cbc717a000d4df4b8f37d459e4.dip0.t-ipconnect.de. [2003:cb:c717:a000:d4df:4b8f:37d4:59e4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b84ba40sm19914915e9.19.2024.05.31.02.55.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 May 2024 02:55:09 -0700 (PDT) Message-ID: <4f734ec7-6277-4f5e-b291-6186f1eb5ecd@redhat.com> Date: Fri, 31 May 2024 11:55:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 8/8] HACK: mm: memory_hotplug: Drop memblock_phys_free() call in try_remove_memory() To: Jonathan Cameron Cc: Dan Williams , linux-cxl@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla , Andrew Morton , Will Deacon , Jia He , Mike Rapoport , linuxarm@huawei.com, catalin.marinas@arm.com, Anshuman.Khandual@arm.com, Yuquan Wang , Oscar Salvador , Lorenzo Pieralisi , James Morse References: <20240529171236.32002-1-Jonathan.Cameron@huawei.com> <20240529171236.32002-9-Jonathan.Cameron@huawei.com> <20240531104848.00006a95@Huawei.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4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59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20240531104848.00006a95@Huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_025524_536400_2DA565BC X-CRM114-Status: GOOD ( 34.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 31.05.24 11:48, Jonathan Cameron wrote: > On Fri, 31 May 2024 09:49:32 +0200 > David Hildenbrand wrote: > >> On 29.05.24 19:12, Jonathan Cameron wrote: >>> I'm not sure what this is balancing, but it if is necessary then the reserved >>> memblock approach can't be used to stash NUMA node assignments as after the >>> first add / remove cycle the entry is dropped so not available if memory is >>> re-added at the same HPA. >>> >>> This patch is here to hopefully spur comments on what this is there for! >>> >>> Signed-off-by: Jonathan Cameron >>> --- >>> mm/memory_hotplug.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >>> index 431b1f6753c0..3d8dd4749dfc 100644 >>> --- a/mm/memory_hotplug.c >>> +++ b/mm/memory_hotplug.c >>> @@ -2284,7 +2284,7 @@ static int __ref try_remove_memory(u64 start, u64 size) >>> } >>> >>> if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) { >>> - memblock_phys_free(start, size); >>> + // memblock_phys_free(start, size); >>> memblock_remove(start, size); >>> } >> >> memblock_phys_free() works on memblock.reserved, memblock_remove() works >> on memblock.memory. >> >> If you take a look at the doc at the top of memblock.c: >> >> memblock.memory: physical memory available to the system >> memblock.reserved: regions that were allocated [during boot] >> >> >> memblock.memory is supposed to be a superset of memblock.reserved. Your >> "hack" here indicates that you somehow would be relying on the opposite >> being true, which indicates that you are doing the wrong thing. >> >> >> memblock_remove() indeed balances against memblock_add_node() for >> hotplugged memory [add_memory_resource()]. There seem to a case where we >> would succeed in hotunplugging memory that was part of "memblock.reserved". >> >> But how could that happen? I think the following way: >> >> Once the buddy is up and running, memory allocated during early boot is >> not freed back to memblock, but usually we simply go via something like >> free_reserved_page(), not memblock_free() [because the buddy took over]. >> So one could end up unplugging memory that still resides in >> memblock.reserved set. >> >> So with memblock_phys_free(), we are enforcing the invariant that >> memblock.memory is a superset of memblock.reserved. >> >> Likely, arm64 should store that node assignment elsewhere from where it >> can be queried. Or it should be using something like >> CONFIG_HAVE_MEMBLOCK_PHYS_MAP for these static windows. >> > > Hi David, > > Thanks for the explanation and pointers. I'd rather avoid inventing a parallel > infrastructure for this (like x86 has for other reasons, but which is also used > for this purpose). Yes, although memblock feels a bit wrong, because it is targeted at managing actual present memory, not properties about memory that could become present later. > From a quick look CONFIG_HAVE_MEMBLOCK_PHYS_MAP is documented in a fashion that > makes me think it's not directly appropriate (this isn't actual physical memory > available during boot) but the general approach of just adding another memblock > collection seems like it will work. Yes. As an alternative, modify the description of CONFIG_HAVE_MEMBLOCK_PHYS_MAP. > > Hardest problem might be naming it. physmem_possible perhaps? > Fill that with anything found in SRAT or CEDT should work for ACPI, but I'm not > sure on whether we can fill it when neither of those is present. Maybe we just > don't bother as for today's usecase CEDT needs to be present. You likely only want something for these special windows, with these special semantics. That makes it hard. "physmem_possible" is a bit too generic for my taste, promising semantics that might not hold true (we don't want all hotpluggable areas to show up there). > > Maybe physmem_known_possible is the way to go. I'll give this approach a spin > and see how it goes. Goes into a better direction, or really "physmem_fixed_windows". Because also "physmem_known_possible" as a wrong smell to it. -- Cheers, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel