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=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 571A2C433DF for ; Wed, 12 Aug 2020 07:28:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 242C420771 for ; Wed, 12 Aug 2020 07:28:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 242C420771 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 B2D666B00AB; Wed, 12 Aug 2020 03:28:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADE0D6B00AC; Wed, 12 Aug 2020 03:28:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CE998D0001; Wed, 12 Aug 2020 03:28:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 864FF6B00AB for ; Wed, 12 Aug 2020 03:28:49 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3D4F3180AD80F for ; Wed, 12 Aug 2020 07:28:49 +0000 (UTC) X-FDA: 77141089578.14.vase78_05003fa26fe9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 15FFA18229835 for ; Wed, 12 Aug 2020 07:28:49 +0000 (UTC) X-HE-Tag: vase78_05003fa26fe9 X-Filterd-Recvd-Size: 5742 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Aug 2020 07:28:48 +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 82F8FB1EE; Wed, 12 Aug 2020 07:29:08 +0000 (UTC) Subject: Re: [PATCH v4 2/2] xen: add helpers to allocate unpopulated memory To: Roger Pau Monne , linux-kernel@vger.kernel.org Cc: Oleksandr Andrushchenko , David Airlie , Daniel Vetter , Boris Ostrovsky , Stefano Stabellini , Dan Carpenter , Wei Liu , Yan Yankovskyi , dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-mm@kvack.org, David Hildenbrand , Michal Hocko , Dan Williams References: <20200811094447.31208-1-roger.pau@citrix.com> <20200811094447.31208-3-roger.pau@citrix.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <7c9a25fa-c52c-66d2-3b03-14a59e069ab6@suse.com> Date: Wed, 12 Aug 2020 09:28:45 +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: <20200811094447.31208-3-roger.pau@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: 15FFA18229835 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 11.08.20 11:44, Roger Pau Monne wrote: > To be used in order to create foreign mappings. This is based on the > ZONE_DEVICE facility which is used by persistent memory devices in > order to create struct pages and kernel virtual mappings for the IOMEM > areas of such devices. Note that on kernels without support for > ZONE_DEVICE Xen will fallback to use ballooned pages in order to > create foreign mappings. >=20 > The newly added helpers use the same parameters as the existing > {alloc/free}_xenballooned_pages functions, which allows for in-place > replacement of the callers. Once a memory region has been added to be > used as scratch mapping space it will no longer be released, and pages > returned are kept in a linked list. This allows to have a buffer of > pages and prevents resorting to frequent additions and removals of > regions. >=20 > If enabled (because ZONE_DEVICE is supported) the usage of the new > functionality untangles Xen balloon and RAM hotplug from the usage of > unpopulated physical memory ranges to map foreign pages, which is the > correct thing to do in order to avoid mappings of foreign pages depend > on memory hotplug. >=20 > Note the driver is currently not enabled on Arm platforms because it > would interfere with the identity mapping required on some platforms. >=20 > Signed-off-by: Roger Pau Monn=C3=A9 > --- > Cc: Oleksandr Andrushchenko > Cc: David Airlie > Cc: Daniel Vetter > Cc: Boris Ostrovsky > Cc: Juergen Gross > Cc: Stefano Stabellini > Cc: Dan Carpenter > Cc: Roger Pau Monne > Cc: Wei Liu > Cc: Yan Yankovskyi > Cc: dri-devel@lists.freedesktop.org > Cc: xen-devel@lists.xenproject.org > Cc: linux-mm@kvack.org > Cc: David Hildenbrand > Cc: Michal Hocko > Cc: Dan Williams > --- > Changes since v3: > - Introduce a Kconfig option that gates the addition of the > unpopulated alloc driver. This allows to easily disable it on Arm > platforms. > - Dropped Juergen RB due to the addition of the Kconfig option. > - Switched from MEMORY_DEVICE_DEVDAX to MEMORY_DEVICE_GENERIC. >=20 > Changes since v2: > - Drop BUILD_BUG_ON regarding PVMMU page sizes. > - Use a SPDX license identifier. > - Call fill with only the minimum required number of pages. > - Include xen.h header in xen_drm_front_gem.c. > - Use less generic function names. > - Exit early from the init function if not a PV guest. > - Don't use all caps for region name. > --- > drivers/gpu/drm/xen/xen_drm_front_gem.c | 9 +- > drivers/xen/Kconfig | 4 + > drivers/xen/Makefile | 1 + > drivers/xen/balloon.c | 4 +- > drivers/xen/grant-table.c | 4 +- > drivers/xen/privcmd.c | 4 +- > drivers/xen/unpopulated-alloc.c | 185 +++++++++++++++++++++++= + > drivers/xen/xenbus/xenbus_client.c | 6 +- > drivers/xen/xlate_mmu.c | 4 +- > include/xen/xen.h | 9 ++ > 10 files changed, 215 insertions(+), 15 deletions(-) > create mode 100644 drivers/xen/unpopulated-alloc.c >=20 > diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig > index 1d339ef92422..018020b91baa 100644 > --- a/drivers/xen/Kconfig > +++ b/drivers/xen/Kconfig > @@ -327,4 +327,8 @@ config XEN_HAVE_VPMU > config XEN_FRONT_PGDIR_SHBUF > tristate > =20 > +config XEN_UNPOPULATED_ALLOC > + bool > + default y if ZONE_DEVICE && !ARM && !ARM64 There is a current effort to enable Xen on RISC-V. Do we expect this option to be usable for this architecture? If yes, I'm fine with the exclusion of Arm, otherwise I'd opt for defaulting to yes only for X86. Either way you can have my: Reviewed-by: Juergen Gross Juergen