[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 10/48] xen/sched: add scheduler helpers hiding vcpu



On 04.09.19 16:49, Jan Beulich wrote:
On 09.08.2019 16:57, Juergen Gross wrote:
Add the following helpers using a sched_unit as input instead of a
vcpu:

- is_idle_unit() similar to is_idle_vcpu()
- is_unit_online() similar to is_vcpu_online()
- unit_runnable() like vcpu_runnable()

Since for vCPU-s within a unit the return values can vary, I think
it would be nice if you made explicit here what the unit-wide return
values are meant to mean in such a case (and why the chosen
alternative is better than the other one).

- sched_set_res() to set the current processor of an unit
- sched_unit_cpu() to get the current processor of an unit

What is "the processor of a unit" when there are multiple
entities within a unit, and hence multiple processors needed
in order to run the unit?

--- a/xen/include/xen/sched-if.h
+++ b/xen/include/xen/sched-if.h
@@ -59,6 +59,62 @@ static inline void set_sched_res(unsigned int cpu, struct 
sched_resource *res)
      per_cpu(sched_res, cpu) = res;
  }
+static inline bool is_idle_unit(const struct sched_unit *unit)
+{
+    return is_idle_vcpu(unit->vcpu_list);
+}
+
+static inline bool is_unit_online(const struct sched_unit *unit)
+{
+    return is_vcpu_online(unit->vcpu_list);
+}
+
+static inline bool unit_runnable(const struct sched_unit *unit)
+{
+    return vcpu_runnable(unit->vcpu_list);
+}

+static inline void sched_set_res(struct sched_unit *unit,
+                                 struct sched_resource *res)
+{
+    unit->vcpu_list->processor = res->processor;
+    unit->res = res;
+}
+
+static inline unsigned int sched_unit_cpu(struct sched_unit *unit)
+{
+    return unit->res->processor;
+}
+
+static inline void sched_set_pause_flags(struct sched_unit *unit,
+                                         unsigned int bit)
+{
+    __set_bit(bit, &unit->vcpu_list->pause_flags);
+}
+
+static inline void sched_clear_pause_flags(struct sched_unit *unit,
+                                           unsigned int bit)
+{
+    __clear_bit(bit, &unit->vcpu_list->pause_flags);
+}
+
+static inline void sched_set_pause_flags_atomic(struct sched_unit *unit,
+                                                unsigned int bit)
+{
+    set_bit(bit, &unit->vcpu_list->pause_flags);
+}
+
+static inline void sched_clear_pause_flags_atomic(struct sched_unit *unit,
+                                                  unsigned int bit)
+{
+    clear_bit(bit, &unit->vcpu_list->pause_flags);
+}

And with the above - are some/all of these going to remain like
this, or will they gain for_each-style loops later?

I will add short descriptions to the commit message.


Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.