All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/10] Allow vcpu to pause self
@ 2007-06-27 13:37 Tian, Kevin
  2007-07-11 17:02 ` Keir Fraser
  0 siblings, 1 reply; 11+ messages in thread
From: Tian, Kevin @ 2007-06-27 13:37 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2367 bytes --]

Add self pause ability, which is required by vcpu0/dom0 when
running on a AP. This can't be satisfied by existing interface,
since the new flag also serves as a sync point.

Signed-off-by Kevin Tian <kevin.tian@intel.com>

diff -r d5315422dbc8 xen/common/domain.c
--- a/xen/common/domain.c	Mon May 14 18:35:31 2007 -0400
+++ b/xen/common/domain.c	Mon May 14 20:21:04 2007 -0400
@@ -530,6 +530,17 @@ void vcpu_pause_nosync(struct vcpu *v)
     vcpu_sleep_nosync(v);
 }
 
+/* _VPF_need_sync serves not only as flag for sync pause, but also
+ * as hint for other cpu waiting for this pause.
+ */
+void vcpu_pause_self(void)
+{
+    struct vcpu *v = current;
+
+    set_bit(_VPF_need_sync, &v->pause_flags);
+    vcpu_pause_nosync(v);
+}
+
 void vcpu_unpause(struct vcpu *v)
 {
     if ( atomic_dec_and_test(&v->pause_count) )
diff -r d5315422dbc8 xen/common/schedule.c
--- a/xen/common/schedule.c	Mon May 14 18:35:31 2007 -0400
+++ b/xen/common/schedule.c	Mon May 14 18:54:28 2007 -0400
@@ -691,6 +691,13 @@ void context_saved(struct vcpu *prev)
 
     if ( unlikely(test_bit(_VPF_migrating, &prev->pause_flags)) )
         vcpu_migrate(prev);
+
+    if ( unlikely(test_bit(_VPF_need_sync, &prev->pause_flags)) )
+    {
+        sync_vcpu_execstate(prev);
+        /* test and clear can be split, since here is the only clear
point */
+        clear_bit(_VPF_need_sync, &prev->pause_flags);
+    }
 }
 
 /* The scheduler timer: force a run through the scheduler */
diff -r d5315422dbc8 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h	Mon May 14 18:35:31 2007 -0400
+++ b/xen/include/xen/sched.h	Mon May 14 20:21:30 2007 -0400
@@ -457,6 +457,9 @@ extern struct domain *domain_list;
  /* VCPU affinity has changed: migrating to a new CPU. */
 #define _VPF_migrating       3
 #define VPF_migrating        (1UL<<_VPF_migrating)
+ /* VCPU needs full context sync once switched out */
+#define _VPF_need_sync       4
+#define VPF_need_sync        (1UL<<_VPF_need_sync)
 
 static inline int vcpu_runnable(struct vcpu *v)
 {
@@ -467,6 +470,7 @@ static inline int vcpu_runnable(struct v
 
 void vcpu_pause(struct vcpu *v);
 void vcpu_pause_nosync(struct vcpu *v);
+void vcpu_pause_self(void);
 void domain_pause(struct domain *d);
 void vcpu_unpause(struct vcpu *v);
 void domain_unpause(struct domain *d);

[-- Attachment #2: vcpu_pause_self.patch --]
[-- Type: application/octet-stream, Size: 2366 bytes --]

Add self pause ability, which is required by vcpu0/dom0 when
running on a AP. This can't be satisfied by existing interface,
since the new flag also serves as a sync point.

Signed-off-by Kevin Tian <kevin.tian@intel.com>

diff -r d5315422dbc8 xen/common/domain.c
--- a/xen/common/domain.c	Mon May 14 18:35:31 2007 -0400
+++ b/xen/common/domain.c	Mon May 14 20:21:04 2007 -0400
@@ -530,6 +530,17 @@ void vcpu_pause_nosync(struct vcpu *v)
     vcpu_sleep_nosync(v);
 }
 
+/* _VPF_need_sync serves not only as flag for sync pause, but also
+ * as hint for other cpu waiting for this pause.
+ */
+void vcpu_pause_self(void)
+{
+    struct vcpu *v = current;
+
+    set_bit(_VPF_need_sync, &v->pause_flags);
+    vcpu_pause_nosync(v);
+}
+
 void vcpu_unpause(struct vcpu *v)
 {
     if ( atomic_dec_and_test(&v->pause_count) )
diff -r d5315422dbc8 xen/common/schedule.c
--- a/xen/common/schedule.c	Mon May 14 18:35:31 2007 -0400
+++ b/xen/common/schedule.c	Mon May 14 18:54:28 2007 -0400
@@ -691,6 +691,13 @@ void context_saved(struct vcpu *prev)
 
     if ( unlikely(test_bit(_VPF_migrating, &prev->pause_flags)) )
         vcpu_migrate(prev);
+
+    if ( unlikely(test_bit(_VPF_need_sync, &prev->pause_flags)) )
+    {
+        sync_vcpu_execstate(prev);
+        /* test and clear can be split, since here is the only clear point */
+        clear_bit(_VPF_need_sync, &prev->pause_flags);
+    }
 }
 
 /* The scheduler timer: force a run through the scheduler */
diff -r d5315422dbc8 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h	Mon May 14 18:35:31 2007 -0400
+++ b/xen/include/xen/sched.h	Mon May 14 20:21:30 2007 -0400
@@ -457,6 +457,9 @@ extern struct domain *domain_list;
  /* VCPU affinity has changed: migrating to a new CPU. */
 #define _VPF_migrating       3
 #define VPF_migrating        (1UL<<_VPF_migrating)
+ /* VCPU needs full context sync once switched out */
+#define _VPF_need_sync       4
+#define VPF_need_sync        (1UL<<_VPF_need_sync)
 
 static inline int vcpu_runnable(struct vcpu *v)
 {
@@ -467,6 +470,7 @@ static inline int vcpu_runnable(struct v
 
 void vcpu_pause(struct vcpu *v);
 void vcpu_pause_nosync(struct vcpu *v);
+void vcpu_pause_self(void);
 void domain_pause(struct domain *d);
 void vcpu_unpause(struct vcpu *v);
 void domain_unpause(struct domain *d);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

end of thread, other threads:[~2007-07-12  8:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-27 13:37 [PATCH 6/10] Allow vcpu to pause self Tian, Kevin
2007-07-11 17:02 ` Keir Fraser
2007-07-12  2:37   ` Tian, Kevin
2007-07-12  5:05     ` Tian, Kevin
2007-07-12  6:02       ` Tian, Kevin
2007-07-12  7:41         ` Keir Fraser
2007-07-12  8:07           ` Tian, Kevin
2007-07-12  7:44       ` Keir Fraser
2007-07-12  8:01         ` Keir Fraser
2007-07-12  8:23           ` Tian, Kevin
2007-07-12  8:30             ` Keir Fraser

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.