Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp445945ybg; Tue, 28 Jul 2020 09:50:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/Z1e2H/+AA/qXQ6ZgcaoDN5nn1FAi2r64nk9ZWBSy8+7fvp7RyXrWYfrIZ5cV9nVXwBRI X-Received: by 2002:a05:6402:1c07:: with SMTP id ck7mr27335650edb.297.1595955009488; Tue, 28 Jul 2020 09:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595955009; cv=none; d=google.com; s=arc-20160816; b=0zCSsCRoR+w8mpTqz5ilejIj7Ue54sC2RKF2J/jl8j/iLtLoWDmnehu8wmfPwJpht9 C2Chbj9lmEZFbF+tLclXUYDmAeUTA1daMJcTJYH7gJF/cDvcVDIdo+hnzbVJAOK6u2cZ 2oCkMNgZx9VXzKDwAYCcudOzRbn24FRL9Q+EqDoIKBEvToqfr5vjgc7aigDk7JTAe5Gr pWG7/NmLTO7puku1vLxAsMrnGQY47AsB44Ifzbnp9oZqUbnHX/L2mjFJLOzUTfesLMF7 X91dUd6R/yg2Sg9q3InWYLNC2pOV4jpF/ujDVAT/RPa1CBVPONBsBGPoF0gtNEnSVMtQ pCow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=W/q3EC2xp/1uSlfzKWEodtbt8+Hkh9fk7Ot5gVkNxDI=; b=NSwPOfhN58M5gVuRRb3NQSMpEmSLDH/en0O6VYb2OaKjJ29SLN6VZIGq33fhk0nc9j LI8AgCDm4sR62MPWzuJQoE7UlYoWZmxSSD1s+G0THXe7IkzeNp54FShn94GUGp4Iu5NW xbR9V3e2ZPSshFmbnsjbbvOvHHuZ0/tqmJ1FYeWAMTg4cQi61OmGdxg4Gx7vzlLrDcgo qi57Q8ackWNNGaYmE5lTJKXUYmJyzv6tSx+vHbgJ+AqyGLzmX0WOOtbgSqT6d6oCAGUd RLHuZklt3Wshzo5wPGyctJFYJuypaveRrMObuzP8u1Wkb+RJReJTUilla2I3kiViiNKS A2vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@xen.org header.s=20200302mail header.b=0EjygVLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si5830400edh.258.2020.07.28.09.49.46; Tue, 28 Jul 2020 09:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@xen.org header.s=20200302mail header.b=0EjygVLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731540AbgG1Qsi (ORCPT + 99 others); Tue, 28 Jul 2020 12:48:38 -0400 Received: from mail.xenproject.org ([104.130.215.37]:46960 "EHLO mail.xenproject.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731268AbgG1Qsi (ORCPT ); Tue, 28 Jul 2020 12:48:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=W/q3EC2xp/1uSlfzKWEodtbt8+Hkh9fk7Ot5gVkNxDI=; b=0EjygVLrDEeM7fxzEKp2ZCZfyW cCJP1O+If5bhP4xNNzbCXDP+PxlwyNtosVREbzqftCtJMDJxbBiLcvc4YspOaTvnKcrrHu2hK0nTJ 1oEy0V5ch4ZjpSEb84qfhoA5KsAiF8/udmsoizbh1NJwVVwacNWHhuOak4ho4Awlprt8=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k0SmB-00059l-9Z; Tue, 28 Jul 2020 16:48:27 +0000 Received: from 54-240-197-239.amazon.com ([54.240.197.239] helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k0SmA-0007yB-V2; Tue, 28 Jul 2020 16:48:27 +0000 Subject: Re: [PATCH v3 4/4] xen: add helpers to allocate unpopulated memory To: Roger Pau Monne , linux-kernel@vger.kernel.org Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Oleksandr Andrushchenko , David Airlie , Yan Yankovskyi , David Hildenbrand , dri-devel@lists.freedesktop.org, Michal Hocko , linux-mm@kvack.org, Daniel Vetter , xen-devel@lists.xenproject.org, Boris Ostrovsky , Dan Williams , Dan Carpenter References: <20200727091342.52325-1-roger.pau@citrix.com> <20200727091342.52325-5-roger.pau@citrix.com> From: Julien Grall Message-ID: Date: Tue, 28 Jul 2020 17:48:23 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200727091342.52325-5-roger.pau@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 27/07/2020 10:13, 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. > > 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. > > 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. I think this is going to break Dom0 on Arm if the kernel has been built with hotplug. This is because you may end up to re-use region that will be used for the 1:1 mapping of a foreign map. Note that I don't know whether hotplug has been tested on Xen on Arm yet. So it might be possible to be already broken. Meanwhile, my suggestion would be to make the use of hotplug in the balloon code conditional (maybe using CONFIG_ARM64 and CONFIG_ARM)? Cheers, -- Julien Grall