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.2 required=3.0 tests=BAYES_00, 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 BB92BC433EC for ; Thu, 23 Jul 2020 13:53:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 89627207BB for ; Thu, 23 Jul 2020 13:53:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89627207BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 113B96B000D; Thu, 23 Jul 2020 09:53:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09CD96B000E; Thu, 23 Jul 2020 09:53:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA77A8D0002; Thu, 23 Jul 2020 09:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id D5C096B000D for ; Thu, 23 Jul 2020 09:53:15 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7DF7C8248047 for ; Thu, 23 Jul 2020 13:53:15 +0000 (UTC) X-FDA: 77069482350.18.top98_610f20526f3f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 4B4B6100ED3A0 for ; Thu, 23 Jul 2020 13:53:15 +0000 (UTC) X-HE-Tag: top98_610f20526f3f X-Filterd-Recvd-Size: 5307 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Jul 2020 13:53:11 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 66E13AB3D; Thu, 23 Jul 2020 13:53:18 +0000 (UTC) Subject: Re: [PATCH 3/3] memory: introduce an option to force onlining of hotplug memory To: David Hildenbrand , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: linux-kernel@vger.kernel.org, Boris Ostrovsky , Stefano Stabellini , Andrew Morton , xen-devel@lists.xenproject.org, linux-mm@kvack.org References: <20200723084523.42109-1-roger.pau@citrix.com> <20200723084523.42109-4-roger.pau@citrix.com> <21490d49-b2cf-a398-0609-8010bdb0b004@redhat.com> <20200723122300.GD7191@Air-de-Roger> <429c2889-93c2-23b3-ba1e-da56e3a76ba4@redhat.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: Date: Thu, 23 Jul 2020 15:53:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <429c2889-93c2-23b3-ba1e-da56e3a76ba4@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: 4B4B6100ED3A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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 23.07.20 15:47, David Hildenbrand wrote: > On 23.07.20 15:22, David Hildenbrand wrote: >> On 23.07.20 14:23, Roger Pau Monn=C3=A9 wrote: >>> On Thu, Jul 23, 2020 at 01:37:03PM +0200, David Hildenbrand wrote: >>>> On 23.07.20 10:45, Roger Pau Monne wrote: >>>>> Add an extra option to add_memory_resource that overrides the memor= y >>>>> hotplug online behavior in order to force onlining of memory from >>>>> add_memory_resource unconditionally. >>>>> >>>>> This is required for the Xen balloon driver, that must run the >>>>> online page callback in order to correctly process the newly added >>>>> memory region, note this is an unpopulated region that is used by L= inux >>>>> to either hotplug RAM or to map foreign pages from other domains, a= nd >>>>> hence memory hotplug when running on Xen can be used even without t= he >>>>> user explicitly requesting it, as part of the normal operations of = the >>>>> OS when attempting to map memory from a different domain. >>>>> >>>>> Setting a different default value of memhp_default_online_type when >>>>> attaching the balloon driver is not a robust solution, as the user = (or >>>>> distro init scripts) could still change it and thus break the Xen >>>>> balloon driver. >>>> >>>> I think we discussed this a couple of times before (even triggered b= y my >>>> request), and this is responsibility of user space to configure. Usu= ally >>>> distros have udev rules to online memory automatically. Especially, = user >>>> space should eb able to configure *how* to online memory. >>> >>> Note (as per the commit message) that in the specific case I'm >>> referring to the memory hotplugged by the Xen balloon driver will be >>> an unpopulated range to be used internally by certain Xen subsystems, >>> like the xen-blkback or the privcmd drivers. The addition of such >>> blocks of (unpopulated) memory can happen without the user explicitly >>> requesting it, and hence not even aware such hotplug process is takin= g >>> place. To be clear: no actual RAM will be added to the system. >> >> Okay, but there is also the case where XEN will actually hotplug memor= y >> using this same handler IIRC (at least I've read papers about it). Bot= h >> are using the same handler, correct? >> >>> >>>> It's the admin/distro responsibility to configure this properly. In = case >>>> this doesn't happen (or as you say, users change it), bad luck. >>>> >>>> E.g., virtio-mem takes care to not add more memory in case it is not >>>> getting onlined. I remember hyper-v has similar code to at least wai= t a >>>> bit for memory to get onlined. >>> >>> I don't think VirtIO or Hyper-V use the hotplug system in the same wa= y >>> as Xen, as said this is done to add unpopulated memory regions that >>> will be used to map foreign memory (from other domains) by Xen driver= s >>> on the system. >> >> Indeed, if the memory is never exposed to the buddy (and all you need = is >> struct pages + a kernel virtual mapping), I wonder if >> memremap/ZONE_DEVICE is what you want? Then you won't have user-visibl= e >> memory blocks created with unclear online semantics, partially involvi= ng >> the buddy. >=20 > And just a note that there is also DCSS on s390x / z/VM which allows to > map segments into the VM physical address space (e.g., you can share > segments between VMs). They don't need any memmap (struct page) for tha= t > memory, though. All they do is create the identity mapping in the kerne= l > virtual address space manually. Not sure what the exact requirements on > the XEN side are. I assume you need a memmap for this memory. We need to be able to do I/O with that memory via normal drivers and we need to be able to map it, both from user land and from the kernel. Juergen