All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] evtchn: double per-channel locking can't hit identical channels
@ 2020-11-24 17:03 Jan Beulich
  2020-11-25  5:40 ` Jürgen Groß
  2020-11-25 11:11 ` Julien Grall
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2020-11-24 17:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

Inter-domain channels can't possibly be bound to themselves, there's
always a 2nd channel involved, even when this is a loopback into the
same domain. As a result we can drop one conditional each from the two
involved functions.

With this, the number of evtchn_write_lock() invocations can also be
shrunk by half, swapping the two incoming function arguments instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -326,23 +326,18 @@ static long evtchn_alloc_unbound(evtchn_
 
 static void double_evtchn_lock(struct evtchn *lchn, struct evtchn *rchn)
 {
-    if ( lchn <= rchn )
-    {
-        evtchn_write_lock(lchn);
-        if ( lchn != rchn )
-            evtchn_write_lock(rchn);
-    }
-    else
-    {
-        evtchn_write_lock(rchn);
-        evtchn_write_lock(lchn);
-    }
+    ASSERT(lchn != rchn);
+
+    if ( lchn > rchn )
+        SWAP(lchn, rchn);
+
+    evtchn_write_lock(lchn);
+    evtchn_write_lock(rchn);
 }
 
 static void double_evtchn_unlock(struct evtchn *lchn, struct evtchn *rchn)
 {
-    if ( lchn != rchn )
-        evtchn_write_unlock(lchn);
+    evtchn_write_unlock(lchn);
     evtchn_write_unlock(rchn);
 }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] evtchn: double per-channel locking can't hit identical channels
  2020-11-24 17:03 [PATCH] evtchn: double per-channel locking can't hit identical channels Jan Beulich
@ 2020-11-25  5:40 ` Jürgen Groß
  2020-11-25 11:11 ` Julien Grall
  1 sibling, 0 replies; 3+ messages in thread
From: Jürgen Groß @ 2020-11-25  5:40 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu


[-- Attachment #1.1.1: Type: text/plain, Size: 544 bytes --]

On 24.11.20 18:03, Jan Beulich wrote:
> Inter-domain channels can't possibly be bound to themselves, there's
> always a 2nd channel involved, even when this is a loopback into the
> same domain. As a result we can drop one conditional each from the two
> involved functions.
> 
> With this, the number of evtchn_write_lock() invocations can also be
> shrunk by half, swapping the two incoming function arguments instead.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] evtchn: double per-channel locking can't hit identical channels
  2020-11-24 17:03 [PATCH] evtchn: double per-channel locking can't hit identical channels Jan Beulich
  2020-11-25  5:40 ` Jürgen Groß
@ 2020-11-25 11:11 ` Julien Grall
  1 sibling, 0 replies; 3+ messages in thread
From: Julien Grall @ 2020-11-25 11:11 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 24/11/2020 17:03, Jan Beulich wrote:
> Inter-domain channels can't possibly be bound to themselves, there's
> always a 2nd channel involved, even when this is a loopback into the
> same domain. As a result we can drop one conditional each from the two
> involved functions.
> 
> With this, the number of evtchn_write_lock() invocations can also be
> shrunk by half, swapping the two incoming function arguments instead.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-25 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 17:03 [PATCH] evtchn: double per-channel locking can't hit identical channels Jan Beulich
2020-11-25  5:40 ` Jürgen Groß
2020-11-25 11:11 ` Julien Grall

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.