From nobody Mon Apr 29 19:16:11 2024 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; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1636653542; cv=none; d=zohomail.com; s=zohoarc; b=OWFAKgdrGpVxywJZGgWf3yauqUZ/L8P8/UuXJEns62M3ndt4RWmxPi5SP0PkfQAVI8u5IQJw0XHYghVNH2GeXZmYaL7AieddPQrmWUXYqRORn/3nbKM6+22uN2b/MYQUBirJyN8NqApcL2KhEykcTlmTwk80RpQ58FNY+K14Ezs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636653542; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wm9d9ZgwbHz/NwuCqvOLxqcGZQyOCpCB5+yCEjUDaLQ=; b=K+ny/qqjPZCk4bBKDrFUaWt8cUTyYaichPw/eb3B14A1EgFR4sJGM+MhCGPe1Vvr3VJWcvF437gbBSAfl30yB9EwkbdZcoyNLRm8uqJtRIJl+CNbWmhrDgn1b12MAXWGcEXPklHe2t9OIOVtL2vQ5m+qMiUQdxw5uYZO3bhtkYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636653542462284.71799896679295; Thu, 11 Nov 2021 09:59:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.224834.388394 (Exim 4.92) (envelope-from ) id 1mlEL0-00073h-CY; Thu, 11 Nov 2021 17:58:14 +0000 Received: by outflank-mailman (output) from mailman id 224834.388394; Thu, 11 Nov 2021 17:58:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEL0-00072m-5q; Thu, 11 Nov 2021 17:58:14 +0000 Received: by outflank-mailman (input) for mailman id 224834; Thu, 11 Nov 2021 17:58:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKx-00061G-Ut for xen-devel@lists.xenproject.org; Thu, 11 Nov 2021 17:58:12 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ec20702c-4318-11ec-a9d2-d9f7a1cc8784; Thu, 11 Nov 2021 18:58:08 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ec20702c-4318-11ec-a9d2-d9f7a1cc8784 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1636653488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UseM21AlpwIdIYpcz0wWiPK9lJhAurz+UGmlCCgsSLI=; b=CiAIqznbOa0vgEDcQkNmkoDvyWKtpt7VCklZbsRTfzpan02CwbqrHgJP iQL+1b7hf4wSOh/HV5nqxM+vK3oJmoAeCPUQDzwoMTQfcygTS2/bLkuA1 TiPS262EuSu0ppAP1dvJHSFGBfkTWAgxpaI1i6+MfXL4g1Saf969KbdOc w=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: O5cljdHxD0EbVogHANza/oxZjDbxM4fy7LfQCYIAaijg10mYW5GmwoYevNWdMP4Lb5NlAmTh5v +BoL8Vl0CGrmcXuEx2/KbJXMYStmkkklS8FsWP/ytfi04rOl/o1wSpV+Ome5ihoG78RsMTtwsK nn8EOceEvF0+v7aS+noc+r/WQkh32KcMqgDMV6oaAPhTiW7KKCqB78kMDfkxMeea9JOMIDInh9 zSGgczuzv+N1x1MdaAGSEprP6Kq/AEKcnGKBEDvQorhbn7fcqcmI3Yszq/Lb00nON0VfPm9KeW N5bkThVJcw8uNxMzNC84hyPT X-SBRS: 5.1 X-MesageID: 57591434 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:jD3AhaNdOhXLNBfvrR0GkMFynXyQoLVcMsEvi/4bfWQNrUoghTdRx mUeWWGOMvuJMGKhfY8lb462oR4PvsWBzNI2HAto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6bUsxNbVU8En540Es6w7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYozuSpI5Jz t5IjsO9FwJ3LpLFsbtDWQYNRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YsBqit4uM4/AO4QHt2s75TrYEewnUdbIRKCiCdpwgWht15kSRqq2i 8wxOB1vTCieekF1HFIyOdEuv/+KoXTwfGgNwL6SjfVuuD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Aakgs5gbBq7tixYqlQ4eMcCNVHeu7cHdcchIP2krP iSQ1fjLiLlrz0bfd2Y+SCrW1u1HiJVS4B1HwTfu/bhSdgYpUhPv4CBszA== IronPort-HdrOrdr: A9a23:aaT6HqA0WIiTD+blHemU55DYdb4zR+YMi2TC1yhKJyC9Ffbo7v xG/c5rsyMc5wxwZJhNo7y90ey7MBbhHP1OkO4s1NWZLWrbUQKTRekIh+bfKn/baknDH4ZmpN 9dmsNFaeEYY2IUsS+D2njbL+od X-IronPort-AV: E=Sophos;i="5.87,226,1631592000"; d="scan'208";a="57591434" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [PATCH 1/5] xen/domain: Remove function pointers from domain pause helpers Date: Thu, 11 Nov 2021 17:57:36 +0000 Message-ID: <20211111175740.23480-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211111175740.23480-1-andrew.cooper3@citrix.com> References: <20211111175740.23480-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1636653543793100001 Retpolines are expensive, and all these do are select between the sync and nosync helpers. Pass a boolean instead, and use direct calls everywhere. Pause/unpause operations on behalf of dom0 are not fastpaths, so avoid exposing the __domain_pause_by_systemcontroller() internal. This actually compiles smaller than before: $ ../scripts/bloat-o-meter xen-syms-before xen-syms-after add/remove: 3/1 grow/shrink: 0/5 up/down: 250/-273 (-23) Function old new delta _domain_pause - 115 +115 domain_pause_by_systemcontroller - 69 +69 domain_pause_by_systemcontroller_nosync - 66 +66 domain_kill 426 398 -28 domain_resume 246 214 -32 domain_pause_except_self 189 141 -48 domain_pause 59 10 -49 domain_pause_nosync 59 7 -52 __domain_pause_by_systemcontroller 64 - -64 despite GCC's best efforts. The new _domain_pause_by_systemcontroller() really should not be inlined, considering that the difference is only the setup of the sync boolean to pass to _domain_pause(), and there are plenty = of registers to spare. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis --- xen/common/domain.c | 31 ++++++++++++++++++++++--------- xen/include/xen/sched.h | 15 +++++---------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 56d47dd66478..562872cdf87a 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1234,15 +1234,18 @@ int vcpu_unpause_by_systemcontroller(struct vcpu *v) return 0; } =20 -static void do_domain_pause(struct domain *d, - void (*sleep_fn)(struct vcpu *v)) +static void _domain_pause(struct domain *d, bool sync /* or nosync */) { struct vcpu *v; =20 atomic_inc(&d->pause_count); =20 - for_each_vcpu( d, v ) - sleep_fn(v); + if ( sync ) + for_each_vcpu ( d, v ) + vcpu_sleep_sync(v); + else + for_each_vcpu ( d, v ) + vcpu_sleep_nosync(v); =20 arch_domain_pause(d); } @@ -1250,12 +1253,12 @@ static void do_domain_pause(struct domain *d, void domain_pause(struct domain *d) { ASSERT(d !=3D current->domain); - do_domain_pause(d, vcpu_sleep_sync); + _domain_pause(d, true /* sync */); } =20 void domain_pause_nosync(struct domain *d) { - do_domain_pause(d, vcpu_sleep_nosync); + _domain_pause(d, false /* nosync */); } =20 void domain_unpause(struct domain *d) @@ -1269,8 +1272,8 @@ void domain_unpause(struct domain *d) vcpu_wake(v); } =20 -int __domain_pause_by_systemcontroller(struct domain *d, - void (*pause_fn)(struct domain *d)) +static int _domain_pause_by_systemcontroller( + struct domain *d, bool sync /* or nosync */) { int old, new, prev =3D d->controller_pause_count; =20 @@ -1289,11 +1292,21 @@ int __domain_pause_by_systemcontroller(struct domai= n *d, prev =3D cmpxchg(&d->controller_pause_count, old, new); } while ( prev !=3D old ); =20 - pause_fn(d); + _domain_pause(d, sync); =20 return 0; } =20 +int domain_pause_by_systemcontroller(struct domain *d) +{ + return _domain_pause_by_systemcontroller(d, true /* sync */); +} + +int domain_pause_by_systemcontroller_nosync(struct domain *d) +{ + return _domain_pause_by_systemcontroller(d, false /* nosync */); +} + int domain_unpause_by_systemcontroller(struct domain *d) { int old, new, prev =3D d->controller_pause_count; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 28146ee404e6..37f78cc4c4c9 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -920,26 +920,21 @@ static inline bool vcpu_cpu_dirty(const struct vcpu *= v) =20 void vcpu_block(void); void vcpu_unblock(struct vcpu *v); + void vcpu_pause(struct vcpu *v); void vcpu_pause_nosync(struct vcpu *v); void vcpu_unpause(struct vcpu *v); + int vcpu_pause_by_systemcontroller(struct vcpu *v); int vcpu_unpause_by_systemcontroller(struct vcpu *v); =20 void domain_pause(struct domain *d); void domain_pause_nosync(struct domain *d); void domain_unpause(struct domain *d); + +int domain_pause_by_systemcontroller(struct domain *d); +int domain_pause_by_systemcontroller_nosync(struct domain *d); int domain_unpause_by_systemcontroller(struct domain *d); -int __domain_pause_by_systemcontroller(struct domain *d, - void (*pause_fn)(struct domain *d)); -static inline int domain_pause_by_systemcontroller(struct domain *d) -{ - return __domain_pause_by_systemcontroller(d, domain_pause); -} -static inline int domain_pause_by_systemcontroller_nosync(struct domain *d) -{ - return __domain_pause_by_systemcontroller(d, domain_pause_nosync); -} =20 /* domain_pause() but safe against trying to pause current. */ int __must_check domain_pause_except_self(struct domain *d); --=20 2.11.0 From nobody Mon Apr 29 19:16:11 2024 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; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1636653531; cv=none; d=zohomail.com; s=zohoarc; b=BmZBy3aVolQRzFMzyOdCD/FaWWgxTXl/2GYu+m+hYQTiLlx8nlMBEGcyJC1pc7NJRPpGJsKVgWgd8QbdVJaA0Y2daJrEuVQbeoEuxd5rOhWRosugYRWqGf4Z1nrTD3CMfnSmGlxKI1riUVDHXEpgIIyXNrPAxouElWSbfmbdMKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636653531; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HUXJkYxmECnHQuQ7NcQnPmNOMcKnGvOZ0Hui0qGDmyc=; b=oEudEMGCbbg9tgnBs7l83DrxuZWr1WcnSF170gt+28/Q2k+P2+8hKjFTBAoRUnjrxuySvt2dEaXTTvETBR9ZttE/gwVuupT1Iwn7SUMdjNiA+KNaKSAASlE8flrBoyozTAfuTCiT4Nt+CuJ0RrkkrUW1CvykFgajfsAFgWDp3gQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636653531502567.0216049802965; Thu, 11 Nov 2021 09:58:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.224831.388361 (Exim 4.92) (envelope-from ) id 1mlEKx-0006IT-Rg; Thu, 11 Nov 2021 17:58:11 +0000 Received: by outflank-mailman (output) from mailman id 224831.388361; Thu, 11 Nov 2021 17:58:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKx-0006IK-ON; Thu, 11 Nov 2021 17:58:11 +0000 Received: by outflank-mailman (input) for mailman id 224831; Thu, 11 Nov 2021 17:58:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKw-00061G-5V for xen-devel@lists.xenproject.org; Thu, 11 Nov 2021 17:58:10 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ec2a8953-4318-11ec-a9d2-d9f7a1cc8784; Thu, 11 Nov 2021 18:58:07 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ec2a8953-4318-11ec-a9d2-d9f7a1cc8784 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1636653488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q5M5rcMoU8akU3ihfSLxmIL46Dy+ECH9/kCBIHplY3E=; b=OytE1qHlpiMydDCtFeFan2b8VzRr61p/mBCjNT0biynru1hjh1zvxM9R K8XCLa5rugzds5qxpWkje4D40jwUzQENPBaCx7ANYy8p2PE2lZJ0DsA3t +UebRuun1rUBRrxR8Ug9bcivW2mfj2r04wZLz6Kt3MzYx254ORxLuP2nd c=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: /5QAJWGpTY9N2d1Jfoqx3UvI3Cet8f1whoEibQW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beu67skDTtV00zEX/kB9WHVpmszxra 6TdZMgpGbJYVcqKRcdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79 YFT0EXMqyJMbEQt6fHCWeDfOrIuOP3kpyVuQ== X-IronPort-AV: E=Sophos;i="5.87,226,1631592000"; d="scan'208";a="59593529" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [PATCH 2/5] xen/domain: Improve pirq handling Date: Thu, 11 Nov 2021 17:57:37 +0000 Message-ID: <20211111175740.23480-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211111175740.23480-1-andrew.cooper3@citrix.com> References: <20211111175740.23480-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1636653532490100003 free_pirq_struct() has no external users, so shouldn't be exposed. Making = it static necessitates moving the function as domain_destroy() uses it. Rework pirq_get_info() to have easier-to-follow logic. The one functional change is to the insertion failure path; we should not be using a full call_rcu() chain to free an otherwise local structure we failed to insert i= nto the radix tree to begin with. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis --- xen/common/domain.c | 62 ++++++++++++++++++++++++++------------------= ---- xen/include/xen/domain.h | 1 - 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 562872cdf87a..a53dd114d5ba 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -365,6 +365,39 @@ static int __init parse_extra_guest_irqs(const char *s) } custom_param("extra_guest_irqs", parse_extra_guest_irqs); =20 +static void _free_pirq_struct(struct rcu_head *head) +{ + xfree(container_of(head, struct pirq, rcu_head)); +} + +static void free_pirq_struct(void *ptr) +{ + struct pirq *pirq =3D ptr; + + call_rcu(&pirq->rcu_head, _free_pirq_struct); +} + +struct pirq *pirq_get_info(struct domain *d, int pirq) +{ + struct pirq *info =3D pirq_info(d, pirq); + + if ( likely(info) ) + return info; + + info =3D alloc_pirq_struct(d); + if ( unlikely(!info) ) + return NULL; + + info->pirq =3D pirq; + if ( likely(radix_tree_insert(&d->pirq_tree, pirq, info) =3D=3D 0) ) + return info; /* Success. */ + + /* Don't use call_rcu() to free a struct we failed to insert. */ + _free_pirq_struct(&info->rcu_head); + + return NULL; +} + /* * Release resources held by a domain. There may or may not be live * references to the domain, and it may or may not be fully constructed. @@ -1789,35 +1822,6 @@ long do_vm_assist(unsigned int cmd, unsigned int typ= e) } #endif =20 -struct pirq *pirq_get_info(struct domain *d, int pirq) -{ - struct pirq *info =3D pirq_info(d, pirq); - - if ( !info && (info =3D alloc_pirq_struct(d)) !=3D NULL ) - { - info->pirq =3D pirq; - if ( radix_tree_insert(&d->pirq_tree, pirq, info) ) - { - free_pirq_struct(info); - info =3D NULL; - } - } - - return info; -} - -static void _free_pirq_struct(struct rcu_head *head) -{ - xfree(container_of(head, struct pirq, rcu_head)); -} - -void free_pirq_struct(void *ptr) -{ - struct pirq *pirq =3D ptr; - - call_rcu(&pirq->rcu_head, _free_pirq_struct); -} - struct migrate_info { long (*func)(void *data); void *data; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 160c8dbdab33..b4d202fda9fd 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -44,7 +44,6 @@ void free_vcpu_struct(struct vcpu *v); #ifndef alloc_pirq_struct struct pirq *alloc_pirq_struct(struct domain *); #endif -void free_pirq_struct(void *); =20 /* * Initialise/destroy arch-specific details of a VCPU. --=20 2.11.0 From nobody Mon Apr 29 19:16:11 2024 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; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1636653531; cv=none; d=zohomail.com; s=zohoarc; b=InEjklftbsK2dueD1OAMxR1U07K/n/ZVengaYaR0iKkVOcgbsP0xXNpYe+za0mCG59bnrMlS6dj8CMSPitLGk9Cm+84j4qh/ZriwE3WxWD7P1NUhk6JkM3wCaclJ+uwvz29zPoO2CKQRLo7ZPmlZxOEbblTqurG/X7ortB3lzT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636653531; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fprq8xIAksNErW/09yRBY5UoepxCeoe+Z+1OSXzzRbY=; b=MCYgzzRlhjxFqQunhWrEyK0YNA1uXr17pbJ2kEdeyhmvDCq616AnZb6HJu6pBOoM8ybDRo6kJ1Iy+HbEytVb9uy9a7pFqLTz/Otu5xnpKzavgt9+dSQIsvuiC8g24upGLEhqq8dML4hFd9X6Api6UdtKt0S4wtnDmHIJhh266vA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636653531583490.6846607501923; Thu, 11 Nov 2021 09:58:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.224830.388351 (Exim 4.92) (envelope-from ) id 1mlEKw-00061Z-Iy; Thu, 11 Nov 2021 17:58:10 +0000 Received: by outflank-mailman (output) from mailman id 224830.388351; Thu, 11 Nov 2021 17:58:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKw-00061S-Fs; Thu, 11 Nov 2021 17:58:10 +0000 Received: by outflank-mailman (input) for mailman id 224830; Thu, 11 Nov 2021 17:58:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKv-0005kR-6q for xen-devel@lists.xenproject.org; Thu, 11 Nov 2021 17:58:09 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ecce4348-4318-11ec-9787-a32c541c8605; Thu, 11 Nov 2021 18:58:07 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ecce4348-4318-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1636653487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wZjOooR7h3617EbhfqFJc1ylcvpSG2QwEC0bQQSIklo=; b=H184UounUCpDqJbBWjVnZhwg7Cvd38MeHcehF4gQ+47ZLLD6VjGUK3Sj D0AHlE3HdzGRMQkPClVTugIMJpx+MEmx6JNC2sezIwwQD0Ylu4WRQLQe4 gAXAowJg32tscjROYZCPwlm0spjevpmdpl1Qrz/Hrx77E1KNedrF0DL3S I=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: DJMeo/F80T5kkf/alFsTsShab5w4ojag5j96fmWJRUuoVF0nOYRG6bTFv4REPTw7nzPOjDXJiG yo7lOH9d8DMQKSC1S2swjdAqYyGN+1cquh91CSrXsHqqPeJD/IBAy2VFMxznZXwsKeSfBee/Gx 97L+CpZS3oPCDaoBiYteVp1W5hJ8/162HQyOW/qWGv9yBicwosirfnX+tyRtUC3z+P/rZFgpFL nr+BTBW6OgTjFxpaKndUUAvArOIO3uugmo9D2z/yLV0XRpwpIbKV4QvLqcQmscoExA7kzottqF DzZ8F8VwbrxKU67Iyw6JpB5r X-SBRS: 5.1 X-MesageID: 57653926 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:C4ryNqKjPLpZJsZwFE+RcpIlxSXFcZb7ZxGr2PjKsXjdYENS12MEy jcdXz2GPKuCamqhKI92PNvk90wCvZfTnNVnGwBlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUZUideSc+EH140Es6wrZg6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB2Cz/Iq4 /pQv6erTAd1b4ucmboUVydHRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsFFgMg5IdatF4QYonx6lhnSDOo8QICFSKLPjTNd9Gpv2J0VTKyAD yYfQWs1cxLGXRIfAHIeVLt92/qzj0LvKiIN/Tp5ooJoujOOnWSdyoPFMsfRe9GMbdVYmACfv G2u11r+BhYWJdmO0w2v+3inhvLMtS7jUYdUH7q9ntZg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HwVJqy45lQTYZaivbBCFszAk= IronPort-HdrOrdr: A9a23:m1QOnau0xHHIRx4Mt+A+cgtu7skDTtV00zEX/kB9WHVpmszxra 6TdZMgpGbJYVcqKRcdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79 YFT0EXMqyJMbEQt6fHCWeDfOrIuOP3kpyVuQ== X-IronPort-AV: E=Sophos;i="5.87,226,1631592000"; d="scan'208";a="57653926" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [PATCH 3/5] xen/sort: Switch to an extern inline implementation Date: Thu, 11 Nov 2021 17:57:38 +0000 Message-ID: <20211111175740.23480-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211111175740.23480-1-andrew.cooper3@citrix.com> References: <20211111175740.23480-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1636653532512100004 There are exactly 3 callers of sort() in the hypervisor. Both arm callers pass in NULL for the swap function. While this might seem like an attractive option at first, it causes generic_swap() to be used whi= ch forced a byte-wise copy. Provide real swap functions which the compiler can optimise sensibly. Furthermore, use of function pointers in tight loops like that can be very = bad for performance. Implement sort() as extern inline, so the optimiser can judge whether to inline things or not. On x86, the diffstat shows how much of a better job the compiler can do when it is able to see the cmp/swap implementations. $ ../scripts/bloat-o-meter xen-syms-before xen-syms-after add/remove: 0/5 grow/shrink: 1/1 up/down: 505/-735 (-230) Function old new delta sort_exception_table 31 536 +505 u32_swap 9 - -9 generic_swap 34 - -34 cmp_ex 36 - -36 swap_ex 41 - -41 sort_exception_tables 90 38 -52 sort 563 - -563 Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis --- xen/arch/arm/bootfdt.c | 9 +++++- xen/arch/arm/io.c | 9 +++++- xen/include/xen/sort.h | 55 +++++++++++++++++++++++++++++++++- xen/lib/sort.c | 80 ++--------------------------------------------= ---- 4 files changed, 72 insertions(+), 81 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index afaa0e249b71..e318ef960386 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -448,6 +448,13 @@ static int __init cmp_memory_node(const void *key, con= st void *elem) return 0; } =20 +static void __init swap_memory_node(void *_a, void *_b, size_t size) +{ + struct membank *a =3D _a, *b =3D _b; + + SWAP(*a, *b); +} + /** * boot_fdt_info - initialize bootinfo from a DTB * @fdt: flattened device tree binary @@ -472,7 +479,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t pa= ddr) * the banks sorted in ascending order. So sort them through. */ sort(bootinfo.mem.bank, bootinfo.mem.nr_banks, sizeof(struct membank), - cmp_memory_node, NULL); + cmp_memory_node, swap_memory_node); =20 early_print_info(); =20 diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index 729287e37c59..1a066f9ae502 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -80,6 +80,13 @@ static int cmp_mmio_handler(const void *key, const void = *elem) return 0; } =20 +static void swap_mmio_handler(void *_a, void *_b, size_t size) +{ + struct mmio_handler *a =3D _a, *b =3D _b; + + SWAP(*a, *b); +} + static const struct mmio_handler *find_mmio_handler(struct domain *d, paddr_t gpa) { @@ -170,7 +177,7 @@ void register_mmio_handler(struct domain *d, =20 /* Sort mmio handlers in ascending order based on base address */ sort(vmmio->handlers, vmmio->num_entries, sizeof(struct mmio_handler), - cmp_mmio_handler, NULL); + cmp_mmio_handler, swap_mmio_handler); =20 write_unlock(&vmmio->lock); } diff --git a/xen/include/xen/sort.h b/xen/include/xen/sort.h index a403652948e7..01479ea44606 100644 --- a/xen/include/xen/sort.h +++ b/xen/include/xen/sort.h @@ -3,8 +3,61 @@ =20 #include =20 +/* + * sort - sort an array of elements + * @base: pointer to data to sort + * @num: number of elements + * @size: size of each element + * @cmp: pointer to comparison function + * @swap: pointer to swap function or NULL + * + * This function does a heapsort on the given array. You may provide a + * swap function optimized to your element type. + * + * Sorting time is O(n log n) both on average and worst-case. While + * qsort is about 20% faster on average, it suffers from exploitable + * O(n*n) worst-case behavior and extra memory requirements that make + * it less suitable for kernel use. + */ +#ifndef SORT_IMPLEMENTATION +extern gnu_inline +#endif void sort(void *base, size_t num, size_t size, int (*cmp)(const void *, const void *), - void (*swap)(void *, void *, size_t)); + void (*swap)(void *, void *, size_t)) +{ + /* pre-scale counters for performance */ + size_t i =3D (num / 2) * size, n =3D num * size, c, r; + + /* heapify */ + while ( i > 0 ) + { + for ( r =3D i -=3D size; r * 2 + size < n; r =3D c ) + { + c =3D r * 2 + size; + if ( (c < n - size) && (cmp(base + c, base + c + size) < 0) ) + c +=3D size; + if ( cmp(base + r, base + c) >=3D 0 ) + break; + swap(base + r, base + c, size); + } + } + + /* sort */ + for ( i =3D n; i > 0; ) + { + i -=3D size; + swap(base, base + i, size); + for ( r =3D 0; r * 2 + size < i; r =3D c ) + { + c =3D r * 2 + size; + if ( (c < i - size) && (cmp(base + c, base + c + size) < 0) ) + c +=3D size; + if ( cmp(base + r, base + c) >=3D 0 ) + break; + swap(base + r, base + c, size); + } + } +} =20 #endif /* __XEN_SORT_H__ */ diff --git a/xen/lib/sort.c b/xen/lib/sort.c index 35ce0d7abdec..b7e78cc0e8d2 100644 --- a/xen/lib/sort.c +++ b/xen/lib/sort.c @@ -4,81 +4,5 @@ * Jan 23 2005 Matt Mackall */ =20 -#include - -static void u32_swap(void *a, void *b, size_t size) -{ - uint32_t t =3D *(uint32_t *)a; - - *(uint32_t *)a =3D *(uint32_t *)b; - *(uint32_t *)b =3D t; -} - -static void generic_swap(void *a, void *b, size_t size) -{ - char t; - - do { - t =3D *(char *)a; - *(char *)a++ =3D *(char *)b; - *(char *)b++ =3D t; - } while ( --size > 0 ); -} - -/* - * sort - sort an array of elements - * @base: pointer to data to sort - * @num: number of elements - * @size: size of each element - * @cmp: pointer to comparison function - * @swap: pointer to swap function or NULL - * - * This function does a heapsort on the given array. You may provide a - * swap function optimized to your element type. - * - * Sorting time is O(n log n) both on average and worst-case. While - * qsort is about 20% faster on average, it suffers from exploitable - * O(n*n) worst-case behavior and extra memory requirements that make - * it less suitable for kernel use. - */ - -void sort(void *base, size_t num, size_t size, - int (*cmp)(const void *, const void *), - void (*swap)(void *, void *, size_t size)) -{ - /* pre-scale counters for performance */ - size_t i =3D (num / 2) * size, n =3D num * size, c, r; - - if ( !swap ) - swap =3D (size =3D=3D 4 ? u32_swap : generic_swap); - - /* heapify */ - while ( i > 0 ) - { - for ( r =3D i -=3D size; r * 2 + size < n; r =3D c ) - { - c =3D r * 2 + size; - if ( (c < n - size) && (cmp(base + c, base + c + size) < 0) ) - c +=3D size; - if ( cmp(base + r, base + c) >=3D 0 ) - break; - swap(base + r, base + c, size); - } - } - - /* sort */ - for ( i =3D n; i > 0; ) - { - i -=3D size; - swap(base, base + i, size); - for ( r =3D 0; r * 2 + size < i; r =3D c ) - { - c =3D r * 2 + size; - if ( (c < i - size) && (cmp(base + c, base + c + size) < 0) ) - c +=3D size; - if ( cmp(base + r, base + c) >=3D 0 ) - break; - swap(base + r, base + c, size); - } - } -} +#define SORT_IMPLEMENTATION +#include --=20 2.11.0 From nobody Mon Apr 29 19:16:11 2024 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; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1636653533; cv=none; d=zohomail.com; s=zohoarc; b=fNUQhJV05jJdKR7qVWwmXqnHUvKREmSF0TVMCH7cw11csAPWX0Id/gcAz8OXasQNxzhWdpR94vyRij1vZxK7Qne7TxGSLS9MMmBPO/Eb5QZENYQmNCVwNyP5BT5c+Mzqb7tWf/LdWxOETbb2TZSK9Dw5ioQ75UuFf6o5YsfCqNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636653533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ihj/Mwo8qrfY0Or9qivqfdaGJKxqL/VbZ3szNpxfc98=; b=I/DclSxLm7PPzxdDImhc/34LAMzM0RFcfdUiTmFV9BTiJziKDlWt5CxcWoh2OAz8+j+wq/bL6Ry8xwjTUKKSr/t4OG2hUfLyPXE3jCW2mq2Wsj8ysB51YEpmZp+2mZGnaSkFqTP07wV/aFGtwHkwe3QG0340P9ztQGGF35HyX6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636653533386601.5960838399149; Thu, 11 Nov 2021 09:58:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.224832.388368 (Exim 4.92) (envelope-from ) id 1mlEKy-0006MB-DF; Thu, 11 Nov 2021 17:58:12 +0000 Received: by outflank-mailman (output) from mailman id 224832.388368; Thu, 11 Nov 2021 17:58:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKy-0006Ld-2b; Thu, 11 Nov 2021 17:58:12 +0000 Received: by outflank-mailman (input) for mailman id 224832; Thu, 11 Nov 2021 17:58:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKw-0005kR-HK for xen-devel@lists.xenproject.org; Thu, 11 Nov 2021 17:58:10 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ed5ad4e9-4318-11ec-9787-a32c541c8605; Thu, 11 Nov 2021 18:58:09 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ed5ad4e9-4318-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1636653489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T/0v3Sf50cFNF0yODlWT/nVv/6FJ5Q1x8/OSVwgO6GU=; b=N3o6QLgR2TsS1YQBhgrnhxYf/Ew5hFqDWaK5+crlXtn7fjufJaMehnw/ rdSVa3sc+NiyP/WsXzdk5NayMm//V8u1qFnfvJYejxZ9RU6WO4e/QzAY6 5q09X0jcNVHloc7Fw1mHpntY4wdev4vcGTdHpyi+xZbJpQxMrGasbgDzt Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ggK1CUUX5UhS1Uoe+hmHccflEXRTp8qP6qoQASuwhQ7Kcag+nXHrVcWvMInyZoRiAXSxQBOyMh icY6ZrvnEKPlyCsGQ+A4wgyEPMpDC9rAqmUSgoSTRhhn7XAnv4MJjhib8nO0raHGdWLTHR1FbR NvUY5I6eAMidEg0hwr4/U9PRNRjTZHx3SShdjvY39ffKxq9WEkExOY8u9libeskDBs+eukUBvD dmsYDXIKUp5Z7VFEomG9MJnE+BhOylAaTtoUVAZ0S1/bi8qaBaA0uyPdRx3Unc64P8h/VFPUnb rFRNN9KL1oeVyshHymzU1/th X-SBRS: 5.1 X-MesageID: 57155539 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:2Zbtlagvs3HzPLDzIC5skhXTX161rRcKZh0ujC45NGQN5FlHY01je htvDG2GMq6JN2T2Lt1yPtu0pk5X68fUzNc2GlZoqy02FHsb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oAMKRCQ7InQLlbGILes1htZGEk0F0/NtTo5w7Rg29cx2IDga++wk YiaT/P3aQfNNwFcagr424rbwP+4lK2v0N+wlgVWicFj5DcypVFMZH4sDfjZw0/DaptVBoaHq 9Prl9lVyI97EyAFUbtJmp6jGqEDryW70QKm0hK6UID66vROS7BbPg/W+5PwZG8O4whlkeydx /1QtL2WWy4WNZHHnf8/CDhcEyteLPRZreqvzXiX6aR/zmXDenrohf5vEFs3LcsT/eMf7WNmr KJCbmpXN1ba2rzwkOnTpupE36zPKOHCOo8Ft24m5jbeFfs8GrjIQrnQ5M8e1zA17ixLNauBP pdENGE+BPjGSxJ/CnNJD7Q0pcH233LzKjJgpnOJmKVitgA/yyQuieOwYbI5YOeiWsF9jkue4 GXc8AzRIDsXKdiewjqt6W+3i6nEmiaTcJIfEvi0++BnhHWXx3cPE1sGWF2ju/67h0WiHdVFJ CQpFjEG9PZoshbxF5+kAkP+8CXsUgMgt8R4DuwbzhOk9aHo6AOCJDMlSj5LSM1/q5pjLdA17 WOhk9TsDD1plbSaT3OB67uZxQ+P1TgpwXwqPnFdE1ZcizX3iMRq10+UEI4/eEKgpoStQWmY/ tyckMQpa1z/Z+Yv3r7zw13IiinESnPhHl9svVW/so5IA2pEiG+Zi26AtQezARVodt/xory9U J4swpn2AAcmV8HlqcB1aL9RdIxFHt7cWNEmvXZhHoM66xOm8GO5cIZb7VlWfRkybJtaKGC5P RCM5mu9AaO/2lPzPMebhKrrW6wXIVXIT4y5Bpg4kPISCnSOSON31H43PhPBt4wcuEMtjbs+K f+mnTWEVh4n5VBc5GPuHY81iOZzrghnnD+7bc2rnnyPjOvFDFbIGOhtDbd7Rr1ghE9yiF6Oq Ig32grj40g3bdASlQGLq9NOdg5TciBgbX00wuQOHtO+zsNdMDlJI5fsLXkJIOSJRoxZybXF+ G+TQEhdxAatjHHLM1zSOHtidKnuTdB0qndiZX4gOlOh2n4CZ4ez7fhAK8trLOd/rOEzn+RpS /QletmbBqgdQDrw5DlAP4L2q5ZvdUr3iFvWbTalejU2Y7VpWxfNpo3/ZgLq+SRXVni3uMIyr qeOzATeRZZfFQ1uANyPMKCkzk+rvGhbk+V3BhOaLt5WcUTq0Y5rNy2u0aNnf5BScU3On2LI2 RyXDBEUofj2j7U0qNSZ17qZq4qJEvdlGhYIFWfs8rvrZzLR+XCuwNEcXb/QLyzdTm795I6re f5Rk6PnKPQCkVtH79h8HrJswf5s7tfjveYHnAFtHXGNZFW3ELJwZHKB2JAX5KFKw7ZYvyqwW 16OpYYGaenYZpu9HQ5DPhchY8SCyeoQy2vb4vkCKUnn4DN6oeicWkJIMhjQ0CFQIdOZ6m/+L TvNbCLO1zGCtw== IronPort-HdrOrdr: A9a23:JEO63KotJcgm2uXwdh/HDFIaV5oTeYIsimQD101hICG8cqSj+f xG+85rrCMc6QxhPk3I9urhBEDtex/hHNtOkOws1NSZLW7bUQmTXeJfBOLZqlWKcUDDH6xmpM NdmsBFeaXN5DNB7PoSjjPWLz9Z+qjkzJyV X-IronPort-AV: E=Sophos;i="5.87,226,1631592000"; d="scan'208";a="57155539" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 4/5] xen/wait: Remove indirect jump Date: Thu, 11 Nov 2021 17:57:39 +0000 Message-ID: <20211111175740.23480-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211111175740.23480-1-andrew.cooper3@citrix.com> References: <20211111175740.23480-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1636653535021100001 There is no need for this to be an indirect jump at all. Execution always returns to a specific location, so use a direct jump instead. Use a named label for the jump. As both 1 and 2 have disappeared as labels, rename 3 to skip to better describe its purpose. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/common/wait.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/xen/common/wait.c b/xen/common/wait.c index 24716e76768b..9276d76464fb 100644 --- a/xen/common/wait.c +++ b/xen/common/wait.c @@ -144,18 +144,16 @@ static void __prepare_to_wait(struct waitqueue_vcpu *= wqv) "push %%r8; push %%r9; push %%r10; push %%r11;" "push %%r12; push %%r13; push %%r14; push %%r15;" =20 - "call 1f;" - "1: addq $2f-1b,(%%rsp);" "sub %%esp,%%ecx;" "cmp %3,%%ecx;" - "ja 3f;" + "ja .L_skip;" "mov %%rsp,%%rsi;" =20 /* check_wakeup_from_wait() longjmp()'s to this point. */ - "2: rep movsb;" + ".L_wq_resume: rep movsb;" "mov %%rsp,%%rsi;" - "3: pop %%rax;" =20 + ".L_skip:" "pop %%r15; pop %%r14; pop %%r13; pop %%r12;" "pop %%r11; pop %%r10; pop %%r9; pop %%r8;" "pop %%rbp; pop %%rdx; pop %%rbx; pop %%rax" @@ -204,15 +202,14 @@ void check_wakeup_from_wait(void) } =20 /* - * Hand-rolled longjmp(). Returns to the pointer on the top of - * wqv->stack, and lands on a `rep movs` instruction. All other GPRs = are - * restored from the stack, so are available for use here. + * Hand-rolled longjmp(). Returns to __prepare_to_wait(), and lands o= n a + * `rep movs` instruction. All other GPRs are restored from the stack= , so + * are available for use here. */ asm volatile ( - "mov %1,%%"__OP"sp; INDIRECT_JMP %[ip]" + "mov %1,%%"__OP"sp; jmp .L_wq_resume;" : : "S" (wqv->stack), "D" (wqv->esp), - "c" ((char *)get_cpu_info() - (char *)wqv->esp), - [ip] "r" (*(unsigned long *)wqv->stack) + "c" ((char *)get_cpu_info() - (char *)wqv->esp) : "memory" ); unreachable(); } --=20 2.11.0 From nobody Mon Apr 29 19:16:11 2024 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; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1636653530; cv=none; d=zohomail.com; s=zohoarc; b=k95MSlA+EIfBqtfqUuOqxSZnb5QssGgQFiAHtczT2ngKh2TQizMeRVXGgTKfYO1mDHuoWBVK92hcIEnY5rxDT3HVieQZS0Fs3vJ1Gra+p3KMHX5CGz4UBZ2//gED0eRvdciRRh+xe9F3PvAN1V7Y7qck/1eg6pfsY5O5KiICUm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636653530; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e6S9vdcqDIv5H0N7f6vHsp2KUzq+XFy64R+Ki85E7MU=; b=iAtgvZPlRzsF1w6nSb2TNAKMGWLrCo/0YeeIkdll/9er089AtEt+UeW4ntC9PtrLaTgSceGTbrffvQCsDiGcv80HsexyPaWf45ioiRVZaHRz6Il9KRLt5NNDSO6sehO4y1GUgjXa4YCLRExIhbppkJRJgqDdpvBHD6znp1hj2LM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636653530967460.8481376907192; Thu, 11 Nov 2021 09:58:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.224829.388339 (Exim 4.92) (envelope-from ) id 1mlEKr-0005ke-7d; Thu, 11 Nov 2021 17:58:05 +0000 Received: by outflank-mailman (output) from mailman id 224829.388339; Thu, 11 Nov 2021 17:58:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKr-0005kX-4e; Thu, 11 Nov 2021 17:58:05 +0000 Received: by outflank-mailman (input) for mailman id 224829; Thu, 11 Nov 2021 17:58:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mlEKp-0005kR-5A for xen-devel@lists.xenproject.org; Thu, 11 Nov 2021 17:58:03 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e83478eb-4318-11ec-9787-a32c541c8605; Thu, 11 Nov 2021 18:58:01 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e83478eb-4318-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1636653481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CXeFV8Xqmdo3yz2//NOSZu7RJ4WSbd7zRTgIylaOvOw=; b=LuMpIMBnDZfdtGN4urH92ShVuE5jKi4uBdIkQPRr/rqxnDT/rTPmNXv+ grhxNFTU1vjdai248yix1jksNE4xj5VbbBcJwIvPzDYgMRJIYuCSC8GA/ 17JOOcDNqM2HfriTzY7i2AMfWaUq3YQgVBdHTTBk3gglNL/zBzA2Zv+vq I=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: codMHIFZaRjxz7BqHayLa6IhmuTXM70vyzcqWvu+3nat2xxYf616NZ2HzcV1RQ/mxvnRjG1euK d4opZAV13N9LFdUWQjddNjSBmMCaXCqelaZTdHBMaws62FWMX66lyCpRIrxUjCjbaIyiq8tjlL agoUmbu1zMCAkNtjuAnTvSq1GNpKeIKDNswgIopjGfsbEKLGXxvUsWlhJ8vMIUkS0br7NnN/FH tmMT+hOqSD+nB/558Yd5WZxNwM7yYMzabhMRg5tIe0tQgm9uKWBS3Qi+BafTAMt1XdZQldgwPZ XV5G2EKGHlTJHi7sKIowXa2I X-SBRS: 5.1 X-MesageID: 57653922 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:ot6mJa/UsPR6BQ9CkMnVDrUDVHmTJUtcMsCJ2f8bNWPcYEJGY0x3x 2tNWT/VOqzbZWTzfN0gYY3noRhSv5TVy4drS1Ro+yw8E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si9AttENlFEkvU2yb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jg+gghiDPnT5bWFnLYJgXQHA5vTtYhDrqHsVFiOyuMZn+ ++g2wrXTIAtXQNnCMqKOvujw0no5SoWmf5oXluOKd5WIR2+/I9vIi33r/k2P8BTdkmTmmrEj 16bWE5Kq/PMrok59MjyqZqF94r5QfFjGkd6HnXA6erkPyft4Wf+k5RLV/yFfG6BWTqsqrmif +hc09r1LOYDwARRq4N5HrtmkfA+6t/oq+MIxwhoBiyWPVGiC7cmKXiax8hf8KZKw+YB6wexX 0uO/PhcOKmIZ5y5QAJAelJ9Y7TRz+wQlxnT8e8xcRfz6yJA9baaVVlfYkuXgytHIbopaI4oz I/NYiLNB9BTXvbyDuu7sw== IronPort-HdrOrdr: A9a23:YmBkxq9Bxiv3lbj1Ue9uk+DgI+orL9Y04lQ7vn2YSXRuHPBw8P re5cjztCWE7gr5N0tBpTntAsW9qDbnhPtICOoqTNCftWvdyQiVxehZhOOIqVDd8m/Fh4pgPM 9bAtBD4bbLbGSS4/yU3ODBKadD/OW6 X-IronPort-AV: E=Sophos;i="5.87,226,1631592000"; d="scan'208";a="57653922" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 5/5] x86/ioapic: Drop function pointers from __ioapic_{read,write}_entry() Date: Thu, 11 Nov 2021 17:57:40 +0000 Message-ID: <20211111175740.23480-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211111175740.23480-1-andrew.cooper3@citrix.com> References: <20211111175740.23480-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1636653532489100002 Function pointers are expensive, and the raw parameter is a constant from a= ll callers, meaning that it predicts very well with local branch history. Furthermore, the knock-on effects are quite impressive. $ ../scripts/bloat-o-meter xen-syms-before xen-syms-after add/remove: 0/4 grow/shrink: 3/9 up/down: 459/-823 (-364) Function old new delta __ioapic_write_entry 73 286 +213 __ioapic_read_entry 75 276 +201 save_IO_APIC_setup 182 227 +45 eoi_IO_APIC_irq 241 229 -12 disable_IO_APIC 296 280 -16 mask_IO_APIC_setup 272 240 -32 __io_apic_write 46 - -46 __io_apic_read 46 - -46 io_apic_set_pci_routing 985 930 -55 __io_apic_eoi.part 223 161 -62 io_apic_write 69 - -69 io_apic_read 69 - -69 restore_IO_APIC_setup 325 253 -72 ioapic_guest_write 1413 1333 -80 clear_IO_APIC_pin 447 343 -104 setup_IO_APIC 5148 4988 -160 Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/arch/x86/io_apic.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index c3ad9efac88d..1c49a0fe1478 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -235,11 +235,19 @@ union entry_union { struct IO_APIC_route_entry __ioapic_read_entry( unsigned int apic, unsigned int pin, bool raw) { - unsigned int (*read)(unsigned int, unsigned int) - =3D raw ? __io_apic_read : io_apic_read; union entry_union eu; - eu.w1 =3D (*read)(apic, 0x10 + 2 * pin); - eu.w2 =3D (*read)(apic, 0x11 + 2 * pin); + + if ( raw ) + { + eu.w1 =3D __io_apic_read(apic, 0x10 + 2 * pin); + eu.w2 =3D __io_apic_read(apic, 0x11 + 2 * pin); + } + else + { + eu.w1 =3D io_apic_read(apic, 0x10 + 2 * pin); + eu.w2 =3D io_apic_read(apic, 0x11 + 2 * pin); + } + return eu.entry; } =20 @@ -259,12 +267,18 @@ void __ioapic_write_entry( unsigned int apic, unsigned int pin, bool raw, struct IO_APIC_route_entry e) { - void (*write)(unsigned int, unsigned int, unsigned int) - =3D raw ? __io_apic_write : io_apic_write; union entry_union eu =3D { .entry =3D e }; =20 - (*write)(apic, 0x11 + 2*pin, eu.w2); - (*write)(apic, 0x10 + 2*pin, eu.w1); + if ( raw ) + { + __io_apic_write(apic, 0x11 + 2 * pin, eu.w2); + __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + } + else + { + io_apic_write(apic, 0x11 + 2 * pin, eu.w2); + io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + } } =20 static void ioapic_write_entry( --=20 2.11.0