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 C224EC5AD4C for ; Mon, 20 Nov 2023 14:49:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 596AB6B035D; Mon, 20 Nov 2023 09:49:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 546A26B035E; Mon, 20 Nov 2023 09:49:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E7BD6B035F; Mon, 20 Nov 2023 09:49:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2ACE46B035D for ; Mon, 20 Nov 2023 09:49:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F32BEB58BB for ; Mon, 20 Nov 2023 14:49:31 +0000 (UTC) X-FDA: 81478616142.20.3860DAF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id A0A57C000C for ; Mon, 20 Nov 2023 14:49:29 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V3QP1pOL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1700491769; 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=h09dJptIUW8lShCqB/JHJlG4YuuHK6xGW6edJE77rvw=; b=7ZWg9UBqAzPmuL57XEXvxoIsxplCzpQN2DgYDkc+IhXn2zGfsUOqowe7/BkDOObmhnWVwv TOyaiVAikk4F8PHyyD3+oy+wjz+vjvciFOxzTT87RzG5eqhaJipspI/Bi4FuageRUORfC8 PuOepNQlINbVO/vn7fx1uhIuVW1f0QQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V3QP1pOL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1700491769; a=rsa-sha256; cv=none; b=1TrXO1rkOXIjAnl3wdyqddhjcOJJqoM+Wud9y8oCuTwqDJKpN724Jgk+QaapIG3RebtXXT VRaKhIavSx69+tDuFZ28Fvd1qUefrizWCmPZbZdD20dvWqBmN0y8KI9ClPQasOVe6oA4tR utpir4vCUi9R3xEbW1QdjIA85vzhEmg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700491769; 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=h09dJptIUW8lShCqB/JHJlG4YuuHK6xGW6edJE77rvw=; b=V3QP1pOL9kJ0htFmHxzaP2sGzdILCLPSl+KC3ZJ0Zw222XtlzrV4StmI7yLL7BhCqjKvjL SumuL3SXoTT5J0Vc4yyJLAsdVa4DE01wxHOqNJZMlDBpS1+bZUkuuRw5p6iE2mBvpNMaAp AGQvZ8nbDZrkn7AmZQUHg6eZCcxq/7A= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-EbGASF6qMnO2x364JtkMmA-1; Mon, 20 Nov 2023 09:49:25 -0500 X-MC-Unique: EbGASF6qMnO2x364JtkMmA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-408597a1ae3so13794055e9.0 for ; Mon, 20 Nov 2023 06:49:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700491764; x=1701096564; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h09dJptIUW8lShCqB/JHJlG4YuuHK6xGW6edJE77rvw=; b=Qhe+VrbaIcWetU0esdUy8S6XhDmHotS0FkVVqGQqKJ2K0W8cHvhGvbGAPwBgJ07W1+ 47umfNbj+bWZ4njZP64MgOCqXRbXznR4pzAsTBlEIo2s/dwvg6qH3Gpu/LuuNxVCtYTa 7BRTPUPq5P1jiF6SfXHjrRY//mjD6u+/95Faku1AF2pCWAz6CGvuu1TxZKFc3nlByehs XO9JQOleCPNUD/txuxvpqLSBjvb/SU/j1hx8SF5T7ebg34miOk8ZIXRJv2xdEo2bDUQZ epK7w0u00vHqjLKS6HhGpaU9B/ot1pt4xXiYoGHKv+tHiUD+zedC/2Bj/mqzerzqiUHH P3+g== X-Gm-Message-State: AOJu0Yw8+I5qh+hQ8domXvLRthaBxHp+94N6kNYi7B7ZXLOrzsjn1nYC GMEDV7PN25WcZUpWsk2+LmnlK5LD/IRaQwabnVM+PyY1tu3gTgU4y5wPF/Jqn4ugrPd2JCZVZmA j5aPWRWXQxZg= X-Received: by 2002:a05:600c:4e87:b0:401:bcd9:4871 with SMTP id f7-20020a05600c4e8700b00401bcd94871mr5958571wmq.21.1700491764187; Mon, 20 Nov 2023 06:49:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IG85nbFpD5ft0UYna49OAK/ZEF1DumwHwbLRWtGtKaMckmofBaZdhjGE83lMdVAczBnGY9MUw== X-Received: by 2002:a05:600c:4e87:b0:401:bcd9:4871 with SMTP id f7-20020a05600c4e8700b00401bcd94871mr5958556wmq.21.1700491763721; Mon, 20 Nov 2023 06:49:23 -0800 (PST) Received: from ?IPV6:2003:cb:c746:7700:9885:6589:b1e3:f74c? (p200300cbc746770098856589b1e3f74c.dip0.t-ipconnect.de. [2003:cb:c746:7700:9885:6589:b1e3:f74c]) by smtp.gmail.com with ESMTPSA id k21-20020a7bc415000000b004042dbb8925sm17830675wmi.38.2023.11.20.06.49.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Nov 2023 06:49:23 -0800 (PST) Message-ID: <8e2f3e24-e2b9-42ee-a401-6c4b681b9ad3@redhat.com> Date: Mon, 20 Nov 2023 15:49:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 6/8] s390/mm: implement MEM_PHYS_ONLINE MEM_PHYS_OFFLINE memory notifiers To: Gerald Schaefer Cc: Sumanth Korikkar , linux-mm , Andrew Morton , Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML References: <20231114180238.1522782-1-sumanthk@linux.ibm.com> <20231114180238.1522782-7-sumanthk@linux.ibm.com> <458da84d-3838-4c5d-abda-1aebba676186@redhat.com> <20231117140027.00866eab@thinkpad-T15> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacP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N/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/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: <20231117140027.00866eab@thinkpad-T15> 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: 7bit X-Rspam-User: X-Stat-Signature: o618yqxej58aadtf1sow7xpqmm4nq9qh X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A0A57C000C X-HE-Tag: 1700491769-148574 X-HE-Meta: U2FsdGVkX1/VECOxHhvlW4jY8KJMIuLRUo8/Y/SfFMHVh/nveGuiLq+bhqUTaLlBmy1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qjUlm7vqc3c430yiD6AyJexrV5X0Wew7cwsvJIVaTsgDfZy99OU4FkRyhH4tMjfTKyojpUMrhfB5ZI8nqsFzn4WYeRzPAAAQTSxfibijWNSWrUNNMsVbJ1x9YlwJswugrnlfSNorNAFj/gSjn+C7SB+ew3bkwktae+1gz47PPoCZspC260KE0bmyLk/29vO8+vJRFHxAxBISzWq1DpFKuVGA3S+kosflmaB+vrXWmOVL+68M2M9NCZOYyTnHomz44mm9LiqBqlk4r+Pe2ircP6MgQwbXSa5vTcouU+QFamnBKXCB+rV3a+Tv+C1gv+63ljfuU2cw== 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: List-Subscribe: List-Unsubscribe: [catching up on mails] >>> This new approach has the advantage that we do not need to allocate any >>> additional memory during online phase, neither for direct mapping page >>> tables nor struct pages, so that memory hotplug can never fail. >> >> Right, just like any other architecture that (triggered by whatever >> mechanism) ends up calling add_memory() and friends. > > Just for better understanding, are page tables for identity and also > vmemmap mapping not allocated from system memory on other archs? I.e. > no altmap support for that, only for struct pages (so far)? Yes, only the actual "memmap ("struct page")" comes from altmap space, everything else comes from the buddy during memory hotplug. > >> >>> >>> The old approach (without altmap) is already a hack, because we add >>> the memmap / struct pages, but for memory that is not really accessible. >> >> Yes, it's disgusting. And you still allocate other things like memory >> block devices or the identify map. > > I would say it is special :-). And again, for understanding, all other :) > things apart from struct pages, still would need to be allocated from > system memory on other archs? Yes! > > Of course, struct pages would be by far the biggest part, so having > altmap support for that helps a lot. Doing the other allocations also > via altmap would feel natural, but it is not possible yet, or did we > miss something? The tricky part is making sure ahead of time that that we set aside the required number of pageblocks, to properly control during memory onlining what to set aside and what to expose to the buddy. See mhp_supports_memmap_on_memory() / memory_block_memmap_on_memory_pages() for the dirty details :) > >> >>> And with all the disadvantage of pre-allocating struct pages from system >>> memory. >> >> Jep. It never should have been done like that. > > At that time, it gave the benefit over all others, that we do not need > to allocate struct pages from system memory, at the time of memory online, > when memory pressure might be high and such allocations might fail. Agreed. Having the memmap already around can be helpful. But not for all standby memory, that's just pure waste. ... but as memory onlining is triggered by user space, it's likely that that user space cannot even make progress (e.g., start a process to set memory online) to actually trigger memory onlining in serious low-memory situations. > > I guess you can say that it should have been done "right" at that time, > e.g. by already adding something like altmap support, instead of our own > hack. Probably yes. IMHO, relying on the existing memory block interface was the low hanging fruit. Now, s390x is just special. > >> >>> >>> The new approach allows to better integrate s390 to the existing >>> interface, and also make use of altmap support, which would eliminate >>> the major disadvantage of the old behaviour. So from s390 perspective, >>> this new mechanism would be preferred, provided that there is no >>> functional issue with the "added memory blocks without a memmap" >>> approach. >> >> It achieves that by s390x specific hacks in common code :) Instead of >> everybody else that simply uses add_memory() and friends. >> >>> >>> Do you see any functional issues, e.g. conflict with common >>> code? >> >> I don't see functional issues right now, just the way it is done to >> implement support for a new feature is a hack IMHO. Replacing hack #1 by >> hack #2 is not really something reasonable. Let's try to remove hacks. > > Ok, sounds reasonable, let's try that. Introducing some new s390-specific > interface also feels a bit hacky, or ugly, but we'll see if we find a > way so that it is only "special" :-) As proposed in my other mail, I think there are ways to make s390x happy first and look into a cleaner approach long-term. > Reminds me a bit of that "probe" attribute, that also was an arch-specific > hack initially, IIRC, and is now to be deprecated... Yeah, that was for interfaces where the kernel has absolutely no clue where/what/how memory gets hotplugged. ARM64 without ACPI. s390x is completely different though: you know exactly which standby memory exists, where it resides, in which granularity in can be enabled/disabled, ... you don't have to play dangerous "I'm pretty sure there is memory out there although nobody can check so I crash the kernel" games. -- Cheers, David / dhildenb