From nobody Sat Apr 20 12:48:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1574693999; cv=none; d=zohomail.com; s=zohoarc; b=Uxjje7YdgRUXUZipxPMJwRFAfuvmwZFPq4qhTQJv+x+PRJlMZIl9f+nVWKRbX3tRCycUvX45ooEaGAOxjQsxGkc+JaHhCNXRcTT3YU4epCldGCfFaLlKZasbXN4Myyqlb5BCzkQwdfQflEHssjQDiO5ThuXiC5xtc4vckhd8Sa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574693999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=aDvoVh/+xM+IJp5wPHADxdIhNZDsIdlyfdwwEPoovA0=; b=eFjMSXt7EIO1R6c8qhv6UBl+UtxhFRqCDkmDVszKWVsT6djQi9Cjv+7CVyQKdSeKXMRnq9RiheeXlb1QhP7FdHSZJIf8SC+2gdvbSaUPQNEgtIvgzHU4svM/wsdAx63l0fIksS2QybLEKKeDbthQyksjQUneg9FAOs5Mi9ko3D4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1574693999991735.4317517251562; Mon, 25 Nov 2019 06:59:59 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZFpn-0004va-8P; Mon, 25 Nov 2019 14:59:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZFpl-0004vR-Os for xen-devel@lists.xenproject.org; Mon, 25 Nov 2019 14:59:25 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 291fe920-0f94-11ea-b4d1-bc764e2007e4; Mon, 25 Nov 2019 14:59:21 +0000 (UTC) X-Inumbo-ID: 291fe920-0f94-11ea-b4d1-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1574693961; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=31toGOIu1C0n6DBNKFoxp7xVO12vWjU9h5YlxY1X7yk=; b=D4PvCYYwXn8FLdNctm7leLPmUStvpwxYVi4Kmwcde0jrnn4KrC03KQ4C ZxHHBZ9KNPu5QNjYLh5T4q7LrNx1erYCdYxhBUWlf3YkE0krqo0520x31 tYoRiRL+xmL+tzuAgi6eHIRvcdvVVF2EYd0+etLublXNgMQ7npjd9aSQ/ 4=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: YKjdRmTwaLRd2PnGnrQvzxo7/KnS9xdfNQAUYwDnN2tS1ySi6MO7jJAYBQmgY8vh2p0huybenf t8g7DsCx4zmgHBKZ6Hc++yEcnwO1fKVZSvj2Rf83wYjfiEyycGPI1UzCWv5CQnzormHHUtPGIT xjF4uZqEBMpDhcRHIJ4v/xe70nEA+nFkMR/Zdg73If4TrwkM4PnWwF1UHYncf8a2uqOY5YWJg8 LwZ/37bX+KOi9M4eQLsBgCewfejUmQ6qQRxw6RIijiJ4UNk1PMr/BFOdJNw7ivwBbsf6+8FqCd E3A= X-SBRS: 2.7 X-MesageID: 8914850 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,241,1571716800"; d="scan'208";a="8914850" From: Anthony PERARD To: Date: Mon, 25 Nov 2019 14:59:15 +0000 Message-ID: <20191125145915.106589-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v2] x86/domctl: have XEN_DOMCTL_getpageframeinfo3 preemptible X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?J=C3=BCrgen=20Gro=C3=9F?= , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Anthony PERARD , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This hypercall can take a long time to finish because it attempts to grab the `hostp2m' lock up to 1024 times. The accumulated wait for the lock can take several seconds. This can easily happen with a guest with 32 vcpus and plenty of RAM, during localhost migration. Signed-off-by: Anthony PERARD --- Notes: Changes in v2: - fix coding style. - check for translated guests. - avoid preemption on the last iteration. - add a comment in the public header. =20 Further possible improvement to the hypercall: - process several GFNs after grabbing the hostp2m lock - Remove the limit xen/arch/x86/domctl.c | 20 ++++++++++++++++++++ xen/include/public/domctl.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 43e368d63bb9..b461aadbd640 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -425,6 +425,26 @@ long arch_do_domctl( ret =3D -EFAULT; break; } + + /* + * Avoid checking for preemption when the `hostp2m' lock isn't + * involve, i.e. non-translated guest, and avoid preemption on + * the last iteration. + */ + if ( paging_mode_translate(d) && + likely((i + 1) < num) && hypercall_preempt_check() ) + { + domctl->u.getpageframeinfo3.num =3D num - i - 1; + domctl->u.getpageframeinfo3.array.p =3D + guest_handle + ((i + 1) * width); + if ( __copy_to_guest(u_domctl, domctl, 1) ) + { + ret =3D -EFAULT; + break; + } + return hypercall_create_continuation(__HYPERVISOR_domctl, + "h", u_domctl); + } } =20 break; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a03e80e5984a..1b69eb75cb20 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -163,6 +163,10 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t); #define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28) =20 /* XEN_DOMCTL_getpageframeinfo3 */ +/* + * Both value `num' and `array' are modified by the hypercall to allow + * preemption. + */ struct xen_domctl_getpageframeinfo3 { /* IN variables. */ uint64_aligned_t num; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel