Skip to contentSkip to conversation

xen/sched.h Whitespace and bool cleanup

PATCH In review Andrew Cooper 2 participants 5 messages Feb 15, 2017 – Feb 17, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xen/sched.h Whitespace and bool cleanup

Extend the Maptrack comment to point at the Grant table subsystem.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

---
 xen/include/xen/sched.h | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)
xen/include/xen/sched.h +24 -24
index 063efe6..def097e 100644
@@ -139,7 +139,7 @@ void evtchn_destroy_final(struct domain *d); /* from complete_domain_destroy */
 
 struct waitqueue_vcpu;
 
-struct vcpu 
+struct vcpu
 {
     int              vcpu_id;
 
@@ -176,20 +176,20 @@ struct vcpu
     uint64_t last_run_time;
 
     /* Has the FPU been initialised? */
-    bool_t           fpu_initialised;
+    bool             fpu_initialised;
     /* Has the FPU been used since it was last saved? */
-    bool_t           fpu_dirtied;
+    bool             fpu_dirtied;
     /* Initialization completed for this VCPU? */
-    bool_t           is_initialised;
+    bool             is_initialised;
     /* Currently running on a CPU? */
-    bool_t           is_running;
+    bool             is_running;
     /* VCPU should wake fast (do not deep sleep the CPU). */
-    bool_t           is_urgent;
+    bool             is_urgent;
 
 #ifdef VCPU_TRAP_LAST
 #define VCPU_TRAP_NONE    0
     struct {
-        bool_t           pending;
+        bool             pending;
         uint8_t          old_mask;
     }                async_exception_state[VCPU_TRAP_LAST];
 #define async_exception_state(t) async_exception_state[(t)-1]
@@ -197,11 +197,11 @@ struct vcpu
 #endif
 
     /* Require shutdown to be deferred for some asynchronous operation? */
-    bool_t           defer_shutdown;
+    bool             defer_shutdown;
     /* VCPU is paused following shutdown request (d->is_shutting_down)? */
-    bool_t           paused_for_shutdown;
+    bool             paused_for_shutdown;
     /* VCPU need affinity restored */
-    bool_t           affinity_broken;
+    bool             affinity_broken;
 
 
     /*
@@ -222,7 +222,7 @@ struct vcpu
     /* VCPU paused by system controller. */
     int              controller_pause_count;
 
-    /* Maptrack */
+    /* Grant table map tracking. */
     unsigned int     maptrack_head;
     unsigned int     maptrack_tail;
 
@@ -375,17 +375,17 @@ struct domain
     s8               need_iommu;
 #endif
     /* is node-affinity automatically computed? */
-    bool_t           auto_node_affinity;
+    bool             auto_node_affinity;
     /* Is this guest fully privileged (aka dom0)? */
-    bool_t           is_privileged;
+    bool             is_privileged;
     /* Is this a xenstore domain (not dom0)? */
-    bool_t           is_xenstore;
+    bool             is_xenstore;
     /* Domain's VCPUs are pinned 1:1 to physical CPUs? */
-    bool_t           is_pinned;
+    bool             is_pinned;
     /* Non-migratable and non-restoreable? */
-    bool_t           disable_migrate;
+    bool             disable_migrate;
     /* Is this guest being debugged by dom0? */
-    bool_t           debugger_attached;
+    bool             debugger_attached;
     /*
      * Set to true at the very end of domain creation, when the domain is
      * unpaused for the first time by the systemcontroller.
@@ -408,8 +408,8 @@ struct domain
 
     /* Guest has shut down (inc. reason code)? */
     spinlock_t       shutdown_lock;
-    bool_t           is_shutting_down; /* in process of shutting down? */
-    bool_t           is_shut_down;     /* fully shut down? */
+    bool             is_shutting_down; /* in process of shutting down? */
+    bool             is_shut_down;     /* fully shut down? */
 #define SHUTDOWN_CODE_INVALID ~0u
     unsigned int     shutdown_code;
 
@@ -558,7 +558,7 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags,
 /*
  * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
  * This is the preferred function if the returned domain reference
- * is short lived,  but it cannot be used if the domain reference needs 
+ * is short lived,  but it cannot be used if the domain reference needs
  * to be kept beyond the current scope (e.g., across a softirq).
  * The returned domain reference must be discarded using rcu_unlock_domain().
  */
@@ -675,7 +675,7 @@ void sync_local_execstate(void);
  * sync_vcpu_execstate() will switch and commit @prev's state.
  */
 void context_switch(
-    struct vcpu *prev, 
+    struct vcpu *prev,
     struct vcpu *next);
 
 /*
@@ -853,7 +853,7 @@ uint64_t get_cpu_idle_time(unsigned int cpu);
 void watchdog_domain_init(struct domain *d);
 void watchdog_domain_destroy(struct domain *d);
 
-/* 
+/*
  * Use this check when the following are both true:
  *  - Using this feature or interface requires full access to the hardware
  *    (that is, this would not be suitable for a driver domain)
@@ -882,7 +882,7 @@ void watchdog_domain_destroy(struct domain *d);
 #define need_iommu(d)    (0)
 #endif
 
-static inline bool_t is_vcpu_online(const struct vcpu *v)
+static inline bool is_vcpu_online(const struct vcpu *v)
 {
     return !test_bit(_VPF_down, &v->pause_flags);
 }
@@ -890,7 +890,7 @@ static inline bool_t is_vcpu_online(const struct vcpu *v)
 void set_vcpu_migration_delay(unsigned int delay);
 unsigned int get_vcpu_migration_delay(void);
 
-extern bool_t sched_smt_power_savings;
+extern bool sched_smt_power_savings;
 
 extern enum cpufreq_controller {
     FREQCTL_none, FREQCTL_dom0_kernel, FREQCTL_xen
Signature · 7 lines
2.1.4


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

PATCH 2/2 common/vcpu: Switch v->vcpu_info_mfn to mfn_t

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

---
 xen/common/domain.c     | 15 ++++++---------
 xen/include/xen/sched.h |  2 +-
 2 files changed, 7 insertions(+), 10 deletions(-)
xen/common/domain.c +6 -9
index 05130e2..5b069b9 100644
@@ -117,7 +117,7 @@ static void vcpu_info_reset(struct vcpu *v)
     v->vcpu_info = ((v->vcpu_id < XEN_LEGACY_MAX_VCPUS)
                     ? (vcpu_info_t *)&shared_info(d, vcpu_info[v->vcpu_id])
                     : &dummy_vcpu_info);
-    v->vcpu_info_mfn = mfn_x(INVALID_MFN);
+    v->vcpu_info_mfn = INVALID_MFN;
 }
 
 struct vcpu *alloc_vcpu(
@@ -1150,7 +1150,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset)
     if ( offset > (PAGE_SIZE - sizeof(vcpu_info_t)) )
         return -EINVAL;
 
-    if ( v->vcpu_info_mfn != mfn_x(INVALID_MFN) )
+    if ( !mfn_eq(v->vcpu_info_mfn, INVALID_MFN) )
         return -EINVAL;
 
     /* Run this command on yourself or on other offline VCPUS. */
@@ -1189,7 +1189,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset)
     }
 
     v->vcpu_info = new_info;
-    v->vcpu_info_mfn = page_to_mfn(page);
+    v->vcpu_info_mfn = _mfn(page_to_mfn(page));
 
     /* Set new vcpu_info pointer /before/ setting pending flags. */
     smp_wmb();
@@ -1208,22 +1208,19 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset)
 
 /*
  * Unmap the vcpu info page if the guest decided to place it somewhere
- * else. This is used from arch_domain_destroy and domain_soft_reset.
+ * else. This is used from domain_kill() and domain_soft_reset().
  */
 void unmap_vcpu_info(struct vcpu *v)
 {
-    unsigned long mfn;
-
-    if ( v->vcpu_info_mfn == mfn_x(INVALID_MFN) )
+    if ( mfn_eq(v->vcpu_info_mfn, INVALID_MFN) )
         return;
 
-    mfn = v->vcpu_info_mfn;
     unmap_domain_page_global((void *)
                              ((unsigned long)v->vcpu_info & PAGE_MASK));
 
     vcpu_info_reset(v);
 
-    put_page_and_type(mfn_to_page(mfn));
+    put_page_and_type(mfn_to_page(mfn_x(v->vcpu_info_mfn)));
 }
 
 int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
xen/include/xen/sched.h +1 -1
index def097e..32893de 100644
@@ -252,7 +252,7 @@ struct vcpu
     struct waitqueue_vcpu *waitqueue_vcpu;
 
     /* Guest-specified relocation of vcpu_info. */
-    unsigned long vcpu_info_mfn;
+    mfn_t            vcpu_info_mfn;
 
     struct evtchn_fifo_vcpu *evtchn_fifo;
 
Signature · 7 lines
2.1.4


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

Re: [PATCH 2/2] common/vcpu: Switch v->vcpu_info_mfn to mfn_t

In reply to Andrew Cooper
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 15.02.17 at 18:39, <[email protected]> wrote:
xen/common/domain.c +2 -4
@@ -1208,22 +1208,19 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset)
 
 /*
  * Unmap the vcpu info page if the guest decided to place it somewhere
- * else. This is used from arch_domain_destroy and domain_soft_reset.
+ * else. This is used from domain_kill() and domain_soft_reset().
  */
 void unmap_vcpu_info(struct vcpu *v)
 {
-    unsigned long mfn;
-
-    if ( v->vcpu_info_mfn == mfn_x(INVALID_MFN) )
+    if ( mfn_eq(v->vcpu_info_mfn, INVALID_MFN) )
         return;

xen/common/domain.c int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) · line 1224

Quoted 10 lines
xen/common/domain.c +1 -2
 
-    mfn = v->vcpu_info_mfn;
     unmap_domain_page_global((void *)
                              ((unsigned long)v->vcpu_info & PAGE_MASK));
 
     vcpu_info_reset(v);
 
-    put_page_and_type(mfn_to_page(mfn));
+    put_page_and_type(mfn_to_page(mfn_x(v->vcpu_info_mfn)));
 }

The elimination of the local variable here is wrong, as the failing smoke tests show: vcpu_info_reset() sets v->vcpu_info_mfn to INVALID_MFN.

Jan

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