From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Bertrand Marquis" <bertrand.marquis@arm.com>
Subject: [PATCH 1/5] xen/domain: Remove function pointers from domain pause helpers
Date: Thu, 11 Nov 2021 17:57:36 +0000 [thread overview]
Message-ID: <20211111175740.23480-2-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20211111175740.23480-1-andrew.cooper3@citrix.com>
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 <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
---
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;
}
-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;
atomic_inc(&d->pause_count);
- 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);
arch_domain_pause(d);
}
@@ -1250,12 +1253,12 @@ static void do_domain_pause(struct domain *d,
void domain_pause(struct domain *d)
{
ASSERT(d != current->domain);
- do_domain_pause(d, vcpu_sleep_sync);
+ _domain_pause(d, true /* sync */);
}
void domain_pause_nosync(struct domain *d)
{
- do_domain_pause(d, vcpu_sleep_nosync);
+ _domain_pause(d, false /* nosync */);
}
void domain_unpause(struct domain *d)
@@ -1269,8 +1272,8 @@ void domain_unpause(struct domain *d)
vcpu_wake(v);
}
-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 = d->controller_pause_count;
@@ -1289,11 +1292,21 @@ int __domain_pause_by_systemcontroller(struct domain *d,
prev = cmpxchg(&d->controller_pause_count, old, new);
} while ( prev != old );
- pause_fn(d);
+ _domain_pause(d, sync);
return 0;
}
+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 = 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)
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);
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);
-}
/* domain_pause() but safe against trying to pause current. */
int __must_check domain_pause_except_self(struct domain *d);
--
2.11.0
next prev parent reply other threads:[~2021-11-11 17:58 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 17:57 [PATCH 0/5] xen: various function pointer cleanups Andrew Cooper
2021-11-11 17:57 ` Andrew Cooper [this message]
2021-11-12 9:36 ` [PATCH 1/5] xen/domain: Remove function pointers from domain pause helpers Julien Grall
2021-11-18 1:47 ` Andrew Cooper
2021-11-18 9:28 ` Julien Grall
2021-11-12 9:57 ` Jan Beulich
2021-11-17 23:31 ` Andrew Cooper
2021-11-15 10:13 ` Bertrand Marquis
2021-11-15 10:20 ` Jan Beulich
2021-11-15 10:23 ` Bertrand Marquis
2021-11-15 10:55 ` Jan Beulich
2021-11-15 11:23 ` Bertrand Marquis
2021-11-15 14:11 ` Julien Grall
2021-11-15 14:45 ` Bertrand Marquis
2021-11-16 0:41 ` Stefano Stabellini
2021-11-16 7:15 ` Jan Beulich
2021-11-11 17:57 ` [PATCH 2/5] xen/domain: Improve pirq handling Andrew Cooper
2021-11-12 10:16 ` Jan Beulich
2021-11-11 17:57 ` [PATCH 3/5] xen/sort: Switch to an extern inline implementation Andrew Cooper
2021-11-11 18:15 ` Julien Grall
2021-11-16 0:36 ` Stefano Stabellini
2021-11-16 0:41 ` Andrew Cooper
2021-12-17 15:56 ` Andrew Cooper
2021-12-17 16:15 ` Julien Grall
2021-11-12 9:39 ` Julien Grall
2021-11-12 10:25 ` Jan Beulich
2021-11-11 17:57 ` [PATCH 4/5] xen/wait: Remove indirect jump Andrew Cooper
2021-11-12 10:35 ` Jan Beulich
2021-11-11 17:57 ` [PATCH 5/5] x86/ioapic: Drop function pointers from __ioapic_{read,write}_entry() Andrew Cooper
2021-11-12 10:43 ` Jan Beulich
2021-11-18 0:32 ` Andrew Cooper
2021-11-18 9:06 ` Jan Beulich
2021-11-18 9:07 ` Jan Beulich
2021-11-18 17:33 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211111175740.23480-2-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.