Skip to contentSkip to conversation

common/vm_event: Prevent guest locking with large max_vcpus

PATCH Superseded Razvan Cojocaru 3 participants 5 messages Feb 8, 2017

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/vm_event: Prevent guest locking with large max_vcpus

It is currently possible for the guest to lock when subscribing to synchronous vm_events if max_vcpus is larger than the number of available ring buffer slots. This patch no longer blocks already paused VCPUs, fixing the issue for this use case.

---
 xen/common/vm_event.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/vm_event.c +2 -1
index 82ce8f1..2005a64 100644
@@ -316,7 +316,8 @@ void vm_event_put_request(struct domain *d,
      * See the comments above wake_blocked() for more information
      * on how this mechanism works to avoid waiting. */
     avail_req = vm_event_ring_available(ved);
-    if( current->domain == d && avail_req < d->max_vcpus )
+    if( current->domain == d && avail_req < d->max_vcpus &&
+        !atomic_read( &current->vm_event_pause_count ) )
         vm_event_mark_and_pause(current, ved);
 
     vm_event_ring_unlock(ved);
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 16 lines · Razvan Cojocaru

It is currently possible for the guest to lock when subscribing to synchronous vm_events if max_vcpus is larger than the number of available ring buffer slots. This patch no longer blocks already paused VCPUs, fixing the issue for this use case.

---
 xen/common/vm_event.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/vm_event.c +0 -0
index 82ce8f1..2005a64 100644

xen/common/vm_event.c void vm_event_put_request(struct domain *d, · line 322

Quoted 8 lines
xen/common/vm_event.c +2 -1
@@ -316,7 +316,8 @@ void vm_event_put_request(struct domain *d,
      * See the comments above wake_blocked() for more information
      * on how this mechanism works to avoid waiting. */
     avail_req = vm_event_ring_available(ved);
-    if( current->domain == d && avail_req < d->max_vcpus )
+    if( current->domain == d && avail_req < d->max_vcpus &&
+        !atomic_read( &current->vm_event_pause_count ) )
         vm_event_mark_and_pause(current, ved);
 

Hi Razvan,
I would also like to have the change made in this patch that unblocks the vCPUs as soon as a spot opens up on the ring. Doing just what this patch has will not solve the problem if there are asynchronous events used.

Tamas

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 31 lines · Tamas K Lengyel

On Wed, Feb 8, 2017 at 2:00 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:

It is currently possible for the guest to lock when subscribing to synchronous vm_events if max_vcpus is larger than the number of available ring buffer slots. This patch no longer blocks already paused VCPUs, fixing the issue for this use case.

<mailto:[email protected]>>
---
xen/common/vm_event.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 82ce8f1..2005a64 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -316,7 +316,8 @@ void vm_event_put_request(struct domain *d,
* See the comments above wake_blocked() for more information
* on how this mechanism works to avoid waiting. */
avail_req = vm_event_ring_available(ved);
- if( current->domain == d && avail_req < d->max_vcpus )
+ if( current->domain == d && avail_req < d->max_vcpus &&
+ !atomic_read( &current->vm_event_pause_count ) )
vm_event_mark_and_pause(current, ved);

Quoted 4 lines

Hi Razvan,
I would also like to have the change made in this patch that unblocks the vCPUs as soon as a spot opens up on the ring. Doing just what this patch has will not solve the problem if there are asynchronous events used.

Fair enough, I thought that might need more discussion and thus put into a subsequent patch, but I'll modify that as well, give it a spin and submit V2.

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 31 lines · Razvan Cojocaru
Quoted 30 lines · Tamas K Lengyel

On Wed, Feb 8, 2017 at 2:00 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:

It is currently possible for the guest to lock when subscribing to synchronous vm_events if max_vcpus is larger than the number of available ring buffer slots. This patch no longer blocks already paused VCPUs, fixing the issue for this use case.

<mailto:[email protected]>>
---
xen/common/vm_event.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 82ce8f1..2005a64 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -316,7 +316,8 @@ void vm_event_put_request(struct domain *d,
* See the comments above wake_blocked() for more information
* on how this mechanism works to avoid waiting. */
avail_req = vm_event_ring_available(ved);
- if( current->domain == d && avail_req < d->max_vcpus )
+ if( current->domain == d && avail_req < d->max_vcpus &&
+ !atomic_read( &current->vm_event_pause_count ) )
vm_event_mark_and_pause(current, ved);

Quoted 7 lines
Quoted 4 lines

Hi Razvan,
I would also like to have the change made in this patch that unblocks the vCPUs as soon as a spot opens up on the ring. Doing just what this patch has will not solve the problem if there are asynchronous events used.

Fair enough, I thought that might need more discussion and thus put into a subsequent patch, but I'll modify that as well, give it a spin and submit V2.

If you are spinning a v2, please pull current out into a variable at the start (more efficient), and atomic_read() doesn't need spaces inside.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 36 lines · Andrew Cooper
Quoted 35 lines · Razvan Cojocaru
Quoted 34 lines · Tamas K Lengyel

On Wed, Feb 8, 2017 at 2:00 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:

It is currently possible for the guest to lock when subscribing to synchronous vm_events if max_vcpus is larger than the number of available ring buffer slots. This patch no longer blocks already paused VCPUs, fixing the issue for this use case.

<mailto:[email protected]>>
---
xen/common/vm_event.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 82ce8f1..2005a64 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -316,7 +316,8 @@ void vm_event_put_request(struct domain *d,
* See the comments above wake_blocked() for more information
* on how this mechanism works to avoid waiting. */
avail_req = vm_event_ring_available(ved);
- if( current->domain == d && avail_req < d->max_vcpus )
+ if( current->domain == d && avail_req < d->max_vcpus &&
+ !atomic_read( &current->vm_event_pause_count ) )
vm_event_mark_and_pause(current, ved);

Hi Razvan,
I would also like to have the change made in this patch that unblocks the vCPUs as soon as a spot opens up on the ring. Doing just what this patch has will not solve the problem if there are asynchronous events used.

Quoted 6 lines
Quoted 3 lines

Fair enough, I thought that might need more discussion and thus put into a subsequent patch, but I'll modify that as well, give it a spin and submit V2.

If you are spinning a v2, please pull current out into a variable at the start (more efficient), and atomic_read() doesn't need spaces inside.

Will do.

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel