All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
	Wei Liu <wl@xen.org>, Stefano Stabellini <sstabellini@kernel.org>
Subject: [PATCH v4 04/10] evtchn: don't call Xen consumer callback with per-channel lock held
Date: Tue, 5 Jan 2021 14:10:29 +0100	[thread overview]
Message-ID: <e0179c46-face-4c64-9aeb-186be65ab77b@suse.com> (raw)
In-Reply-To: <cf0a1c24-0146-1017-7310-9536f2ed0ad1@suse.com>

While there don't look to be any problems with this right now, the lock
order implications from holding the lock can be very difficult to follow
(and may be easy to violate unknowingly). The present callbacks don't
(and no such callback should) have any need for the lock to be held.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v4: Go back to v2.
v3: Drain callbacks before proceeding with closing. Re-base.

--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -767,9 +767,18 @@ int evtchn_send(struct domain *ld, unsig
         rport = lchn->u.interdomain.remote_port;
         rchn  = evtchn_from_port(rd, rport);
         if ( consumer_is_xen(rchn) )
-            xen_notification_fn(rchn)(rd->vcpu[rchn->notify_vcpu_id], rport);
-        else
-            evtchn_port_set_pending(rd, rchn->notify_vcpu_id, rchn);
+        {
+            /* Don't keep holding the lock for the call below. */
+            xen_event_channel_notification_t fn = xen_notification_fn(rchn);
+            struct vcpu *rv = rd->vcpu[rchn->notify_vcpu_id];
+
+            rcu_lock_domain(rd);
+            evtchn_read_unlock(lchn);
+            fn(rv, rport);
+            rcu_unlock_domain(rd);
+            return 0;
+        }
+        evtchn_port_set_pending(rd, rchn->notify_vcpu_id, rchn);
         break;
     case ECS_IPI:
         evtchn_port_set_pending(ld, lchn->notify_vcpu_id, lchn);



  parent reply	other threads:[~2021-01-05 13:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 13:07 [PATCH v4 00/10] evtchn: (not so) recent XSAs follow-on Jan Beulich
2021-01-05 13:09 ` [PATCH v4 01/10] evtchn: use per-channel lock where possible Jan Beulich
2021-01-08 20:32   ` Julien Grall
2021-01-11 10:14     ` Jan Beulich
2021-01-11 11:06       ` Julien Grall
2021-01-27  7:39         ` Jan Beulich
2021-01-05 13:09 ` [PATCH v4 02/10] evtchn: bind-interdomain doesn't need to hold both domains' event locks Jan Beulich
2021-01-09 15:41   ` Julien Grall
2021-01-09 16:14     ` Julien Grall
2021-01-25 13:47       ` Jan Beulich
2021-01-05 13:10 ` [PATCH v4 03/10] evtchn: convert domain event lock to an r/w one Jan Beulich
2021-01-05 13:10 ` Jan Beulich [this message]
2021-01-09 15:41   ` [PATCH v4 04/10] evtchn: don't call Xen consumer callback with per-channel lock held Julien Grall
2021-01-05 13:10 ` [PATCH v4 05/10] evtchn: closing of vIRQ-s doesn't require looping over all vCPU-s Jan Beulich
2021-01-09 16:17   ` Julien Grall
2021-01-05 13:11 ` [PATCH v4 06/10] evtchn: slightly defer lock acquire where possible Jan Beulich
2021-01-09 16:25   ` Julien Grall
2021-01-05 13:12 ` [PATCH v4 07/10] evtchn: add helper for port_is_valid() + evtchn_from_port() Jan Beulich
2021-01-09 16:31   ` Julien Grall
2021-01-05 13:12 ` [PATCH v4 08/10] evtchn: closing of ports doesn't need to hold both domains' event locks Jan Beulich
2021-01-05 13:13 ` [PATCH v4 09/10] evtchn: type adjustments Jan Beulich
2021-01-05 13:13 ` [PATCH v4 10/10] evtchn: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq() Jan Beulich

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=e0179c46-face-4c64-9aeb-186be65ab77b@suse.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=julien@xen.org \
    --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.