From nobody Mon Feb 9 18:47:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1593520548; cv=none; d=zohomail.com; s=zohoarc; b=aTo4lP/lYfYWrT5H7CTa6Xh6PgzhTasTPHkdKXqyIVpVrstSzbLZr81MDrdJ9yekviZWY0KhhtyR0zKDuTEINKbAPLzNIPW3TQpN44d26gXci6wq7yaHGJsv/r1kzDMVnsa3qvlbdfCfvLUuGZ/YN5OhWBV+b84gLA7szvwPtWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593520548; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=dao5HD+2BSIwqAKDC/DE9m9zyGsCrXHDlYpYzJgRh2A=; b=UIDUQCNod6Z/tuwGJK1j23vm5oXzdRu0EPhzDzF0KcmfAu95KNFnE+PmHsSqfGFRhQFaN/lq8XZWVRY4rLO9zZ3aGtcryqls+abY1Hu5rITRiGVfqJ14g7k2uEEvEoDHJYIMPMdoaIJH8GF82cDtYV7NVrewbHcomCzRMZ3zl8Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1593520548432324.817621883554; Tue, 30 Jun 2020 05:35:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jqFU5-0007yO-Bk; Tue, 30 Jun 2020 12:35:33 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jqFU4-0007rV-SN for xen-devel@lists.xenproject.org; Tue, 30 Jun 2020 12:35:32 +0000 Received: from bagnar.nask.net.pl (unknown [195.187.242.196]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2d6897e5-bace-11ea-8610-12813bfff9fa; Tue, 30 Jun 2020 12:35:29 +0000 (UTC) Received: from bagnar.nask.net.pl (unknown [172.16.9.10]) by bagnar.nask.net.pl (Postfix) with ESMTP id 5445DA37F3; Tue, 30 Jun 2020 14:35:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bagnar.nask.net.pl (Postfix) with ESMTP id 3B0B7A37FB; Tue, 30 Jun 2020 14:35:27 +0200 (CEST) Received: from bagnar.nask.net.pl ([127.0.0.1]) by localhost (bagnar.nask.net.pl [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3XChIHKLaS_2; Tue, 30 Jun 2020 14:35:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bagnar.nask.net.pl (Postfix) with ESMTP id BBF7AA37F9; Tue, 30 Jun 2020 14:35:26 +0200 (CEST) Received: from bagnar.nask.net.pl ([127.0.0.1]) by localhost (bagnar.nask.net.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8hxz5J2M2ELj; Tue, 30 Jun 2020 14:35:26 +0200 (CEST) Received: from belindir.nask.net.pl (belindir-ext.nask.net.pl [195.187.242.210]) by bagnar.nask.net.pl (Postfix) with ESMTP id 2B04DA37F3; Tue, 30 Jun 2020 14:35:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by belindir.nask.net.pl (Postfix) with ESMTP id 8F7152262A; Tue, 30 Jun 2020 14:34:45 +0200 (CEST) Received: from belindir.nask.net.pl ([127.0.0.1]) by localhost (belindir.nask.net.pl [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id OtfMRFhj4Dx2; Tue, 30 Jun 2020 14:34:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by belindir.nask.net.pl (Postfix) with ESMTP id 1DA3A22558; Tue, 30 Jun 2020 14:34:40 +0200 (CEST) Received: from belindir.nask.net.pl ([127.0.0.1]) by localhost (belindir.nask.net.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id g85ttXe7J3M0; Tue, 30 Jun 2020 14:34:40 +0200 (CEST) Received: from mq-desktop.cert.pl (unknown [195.187.238.217]) by belindir.nask.net.pl (Postfix) with ESMTPSA id E4C23223E7; Tue, 30 Jun 2020 14:34:39 +0200 (CEST) X-Inumbo-ID: 2d6897e5-bace-11ea-8610-12813bfff9fa X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Virus-Scanned: amavisd-new at bagnar.nask.net.pl X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Quarantine-ID: X-Virus-Scanned: amavisd-new at belindir.nask.net.pl X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= To: xen-devel@lists.xenproject.org Subject: [PATCH v4 06/10] memory: batch processing in acquire_resource() Date: Tue, 30 Jun 2020 14:33:49 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , Stefano Stabellini , tamas.lengyel@intel.com, Wei Liu , Andrew Cooper , Michal Leszczynski , Ian Jackson , George Dunlap , Jan Beulich , luwei.kang@intel.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michal Leszczynski Allow to acquire large resources by allowing acquire_resource() to process items in batches, using hypercall continuation. Signed-off-by: Michal Leszczynski --- xen/common/memory.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index 714077c1e5..3ab06581a2 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1046,10 +1046,12 @@ static int acquire_grant_table(struct domain *d, un= signed int id, } =20 static int acquire_resource( - XEN_GUEST_HANDLE_PARAM(xen_mem_acquire_resource_t) arg) + XEN_GUEST_HANDLE_PARAM(xen_mem_acquire_resource_t) arg, + unsigned long *start_extent) { struct domain *d, *currd =3D current->domain; xen_mem_acquire_resource_t xmar; + uint32_t total_frames; /* * The mfn_list and gfn_list (below) arrays are ok on stack for the * moment since they are small, but if they need to grow in future @@ -1077,8 +1079,17 @@ static int acquire_resource( return 0; } =20 + total_frames =3D xmar.nr_frames; + + if ( *start_extent ) + { + xmar.frame +=3D *start_extent; + xmar.nr_frames -=3D *start_extent; + guest_handle_add_offset(xmar.frame_list, *start_extent); + } + if ( xmar.nr_frames > ARRAY_SIZE(mfn_list) ) - return -E2BIG; + xmar.nr_frames =3D ARRAY_SIZE(mfn_list); =20 rc =3D rcu_lock_remote_domain_by_id(xmar.domid, &d); if ( rc ) @@ -1135,6 +1146,14 @@ static int acquire_resource( } } =20 + if ( !rc ) + { + *start_extent +=3D xmar.nr_frames; + + if ( *start_extent !=3D total_frames ) + rc =3D -ERESTART; + } + out: rcu_unlock_domain(d); =20 @@ -1600,7 +1619,14 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDL= E_PARAM(void) arg) =20 case XENMEM_acquire_resource: rc =3D acquire_resource( - guest_handle_cast(arg, xen_mem_acquire_resource_t)); + guest_handle_cast(arg, xen_mem_acquire_resource_t), + &start_extent); + + if ( rc =3D=3D -ERESTART ) + return hypercall_create_continuation( + __HYPERVISOR_memory_op, "lh", + op | (start_extent << MEMOP_EXTENT_SHIFT), arg); + break; =20 default: --=20 2.20.1