Changes to time accounting
cover Changes to time accounting
From: Andrii Anisov <[email protected]>
That is the second attempt of the changes for the time accounting in XEN. The initial topic is here [1].
In this series it is introduced a time accounting infrastructure separated from runstates, and made an attempt to use new infra solely for taking scheduling decissions.
This series still employs ideas of the initial series about what hypervisor, idle and guest time are.
Yet, this series lacks of connection between new time accounting infra and runstate. This is TODO, currently.
The main goal of this work is to improve time accounting precission as well as avoiding charging guests for the other entities (guests or hypervisor itself) work.
Changes from:
Initial RFC series [1]:
- Time accounting made independent from runstates infrastructure.
- Dropped odd patches to ARM64 code.
[1] https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg01839.html
Andrii Anisov (9):
schedule: Introduce per-pcpu time accounting
sysctl: extend XEN_SYSCTL_getcpuinfo interface
xentop: show CPU load information
arm64: utilize time accounting
tacc: Introduce a lockless interface for guest time sched:rtds: get guest time from time accounting code
tacc: Introduce a locked interface for guest time sched:credit: get guest time from time accounting code sched:credit2: get guest time from time accounting code
tools/xenstat/libxenstat/src/xenstat.c | 50 +++++++++ tools/xenstat/libxenstat/src/xenstat.h | 15 +++ tools/xenstat/libxenstat/src/xenstat_priv.h | 5 + tools/xenstat/xentop/xentop.c | 36 ++++++ xen/arch/arm/arm64/entry.S | 39 ++++++- xen/arch/arm/domain.c | 2 + xen/common/Kconfig | 5 + xen/common/sched_credit.c | 12 +- xen/common/sched_credit2.c | 17 +-- xen/common/sched_rt.c | 4 +- xen/common/schedule.c | 168 +++++++++++++++++++++++++++- xen/common/sysctl.c | 4 + xen/include/public/sysctl.h | 4 + xen/include/xen/sched.h | 50 +++++++++ 14 files changed, 386 insertions(+), 25 deletions(-)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 1/9 schedule: Introduce per-pcpu time accounting
From: Andrii Anisov <[email protected]>
Introduce per-pcpu time accounting what includes the following states:
TACC_HYP - the pcpu executes hypervisor code like softirq processing
(including scheduling), tasklets and context switchesTACC_GUEST - the pcpu executes guests codeTACC_IDLE - the low-power state of the pcpuTACC_IRQ - the pcpu performs interrupts processing, without separation to
guest or hypervisor interruptsTACC_GSYNC - the pcpu executes hypervisor code to process synchronous trap
from the guest. E.g. hypercall processing or io emulation.
Currently, the only reenterant state is TACC_IRQ. It is assumed, no changes to state other than TACC_IRQ could happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other states. It is acumulated between other states transition moments, and is substracted from the old state on states transion calculation.
--- xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 27 +++++++++++++++++ 2 files changed, 108 insertions(+)
xen/common/schedule.c +81 -0
@@ -1539,6 +1539,87 @@ static void schedule(void)context_switch (prev, next); } +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change (enum TACC_STATES new_state) +{ +s_time_t now, delta; +struct tacc * tacc = &this_cpu (tacc); +unsigned long flags; + +local_irq_save (flags); + + now =NOW (); + delta = now - tacc->state_entry_time; + +/* We do not expect states reenterability (at least through this function)*/ +ASSERT (new_state != tacc->state); + + tacc->state_time[tacc->state] += delta - tacc->irq_time; + tacc->state_time[TACC_IRQ ] += tacc->irq_time; + tacc->irq_time =0 ; + tacc->state = new_state; + tacc->state_entry_time = now; + +local_irq_restore (flags); +} + +void tacc_hyp (int place) +{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_HYP ); +} + +void tacc_guest (int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GUEST ); +} + +void tacc_idle (int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_IDLE ); +} + +void tacc_gsync (int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GSYNC ); +} + +void tacc_irq_enter (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id(), place, this_cpu(tacc).irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >=0 ); + +if ( tacc->irq_cnt ==0 ) + { + tacc->irq_enter_time =NOW (); + } + + tacc->irq_cnt++; +} + +void tacc_irq_exit (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(), place, tacc->irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >0 ); +if ( tacc->irq_cnt ==1 ) + { + tacc->irq_time =NOW () - tacc->irq_enter_time; + tacc->irq_enter_time =0 ; + } + + tacc->irq_cnt--; +} +void context_saved (struct vcpu *prev) {/* Clear running flag /after/ writing context to memory. */
xen/include/xen/sched.h +27 -0
@@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key);void arch_do_physinfo (struct xen_sysctl_physinfo *pi); +enum TACC_STATES { +TACC_HYP =0 , +TACC_GUEST =1 , +TACC_IDLE =2 , +TACC_IRQ =3 , +TACC_GSYNC =4 , +TACC_STATES_MAX +}; + +struct tacc +{ +s_time_t state_time[TACC_STATES_MAX ]; +s_time_t state_entry_time; +int state; + +s_time_t guest_time; + +s_time_t irq_enter_time; +s_time_t irq_time; +int irq_cnt; +}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp (int place); +void tacc_idle (int place); +#endif /* __SCHED_H__ */ /*
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Andrii,
Quoted 8 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Introduce per-pcpu time accounting what includes the following states:
TACC_HYP- the pcpu executes hypervisor code like softirq processing
(including scheduling), tasklets and context switchesTACC_GUEST- the pcpu executes guests codeTACC_IDLE- the low-power state of the pcpu
Is it really low-power?
Quoted 2 lines
TACC_IRQ- the pcpu performs interrupts processing, without separation to
guest or hypervisor interrupts
I think, word "distinguishing" would be better than "separation"
Quoted 39 lines
TACC_GSYNC- the pcpu executes hypervisor code to process synchronous trap
from the guest. E.g. hypercall processing or io emulation.Currently, the only reenterant state is
TACC_IRQ. It is assumed, no changes to state other thanTACC_IRQcould happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other states. It is acumulated between other states transition moments, and is substracted from the old state on states transion calculation.Signed-off-by Andrii Anisov <[email protected]>--- xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 27 +++++++++++++++++ 2 files changed, 108 insertions(+)xen/common/schedule.c +16
-0@@ -1539,6 +1539,87 @@ static void schedule(void)context_switch (prev, next); } +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change (enum TACC_STATES new_state) +{ +s_time_t now, delta; +struct tacc * tacc = &this_cpu (tacc); +unsigned long flags; + +local_irq_save (flags); + + now =NOW (); + delta = now - tacc->state_entry_time; + +/* We do not expect states reenterability (at least through this function)*/ +ASSERT (new_state != tacc->state); +
xen/common/schedule.c static void schedule(void) · line 1567
Quoted 10 lines
xen/common/schedule.c +10
-0+ tacc->state_time[tacc->state] += delta - tacc->irq_time; + tacc->state_time[TACC_IRQ ] += tacc->irq_time; + tacc->irq_time =0 ; + tacc->state = new_state; + tacc->state_entry_time = now; + +local_irq_restore (flags); +} + +void tacc_hyp (int place)
I believe, you want some enum for this "place" parameter type
xen/common/schedule.c static void schedule(void) · line 1569
Quoted 2 lines
xen/common/schedule.c +2
-0+{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place);
Please, don't push commented-out code. BTW, I think, it is possible to add some TACC_DEBUG facilities to enable/disable this traces during compile-time.
Also, looks like you don't use "place" parameter at all.
Lastly, I believe that this function (and other similar functions below) can be defined as "static inline" in a header file.
Quoted 18 lines
xen/common/schedule.c +18
-0+tacc_state_change (TACC_HYP ); +} + +void tacc_guest (int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GUEST ); +} + +void tacc_idle (int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_IDLE ); +} + +void tacc_gsync (int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place);
xen/common/schedule.c static void schedule(void) · line 1597
Quoted 10 lines
xen/common/schedule.c +10
-0+tacc_state_change (TACC_GSYNC ); +} + +void tacc_irq_enter (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id(), place, this_cpu(tacc).irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >=0 );
You can make irq_cnt unsigned and drop this assert.
xen/common/schedule.c static void schedule(void) · line 1602
Quoted 5 lines
xen/common/schedule.c +5
-0+ +if ( tacc->irq_cnt ==0 ) + { + tacc->irq_enter_time =NOW (); + }
Coding style:
---
Braces should be omitted for blocks with a single statement. e.g.,
if ( condition )
single_statement();
---
Quoted 8 lines
xen/common/schedule.c +8
-0+ + tacc->irq_cnt++; +} + +void tacc_irq_exit (int place) +{ +struct tacc * tacc = &this_cpu (tacc); +
xen/common/schedule.c static void schedule(void) · line 1620
Quoted 10 lines
xen/common/schedule.c +10
-0+// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(), place, tacc->irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >0 ); +if ( tacc->irq_cnt ==1 ) + { + tacc->irq_time =NOW () - tacc->irq_enter_time; + tacc->irq_enter_time =0 ; + } + + tacc->irq_cnt--;
What if, you IRQ will arrive right after this? I believe, you will lose some of the accumulated time.
Quoted 10 lines
xen/common/schedule.c +2
-0+} +void context_saved (struct vcpu *prev) {/* Clear running flag /after/ writing context to memory. */ xen/include/xen/sched.h +0
-0
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1005
Quoted 4 lines
xen/include/xen/sched.h +1
-0@@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key);void arch_do_physinfo (struct xen_sysctl_physinfo *pi); +enum TACC_STATES {
If I remember correct, enum names should in lower case
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1018
Quoted 13 lines
xen/include/xen/sched.h +13
-0+TACC_HYP =0 , +TACC_GUEST =1 , +TACC_IDLE =2 , +TACC_IRQ =3 , +TACC_GSYNC =4 , +TACC_STATES_MAX +}; + +struct tacc +{ +s_time_t state_time[TACC_STATES_MAX ]; +s_time_t state_entry_time; +int state;
enum, maybe?
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1030
Quoted 12 lines
xen/include/xen/sched.h +12
-0+ +s_time_t guest_time; + +s_time_t irq_enter_time; +s_time_t irq_time; +int irq_cnt; +}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp (int place); +void tacc_idle (int place);
What about functions from sched.c? Should they be declared there?
Quoted 4 lines
xen/include/xen/sched.h +1
-0+#endif /* __SCHED_H__ */ /*
Signature · 5 lines
Volodymyr Babchuk at EPAM _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Hello Volodymyr,
Quoted 7 lines · Volodymyr Babchuk
Quoted 6 lines
Introduce per-pcpu time accounting what includes the following states:
TACC_HYP- the pcpu executes hypervisor code like softirq processing
(including scheduling), tasklets and context switchesTACC_GUEST- the pcpu executes guests codeTACC_IDLE- the low-power state of the pcpuIs it really low-power?
It is rather matter of scheduling design. It differs from OS to OS, even from arch to arch. See [1].
Me personally tend to treat only low-power state as a true idle.
As a bad (IMO) example I can give the current XEN mainline. Pretty heavy tasks could be performed by the idle vcpu, and they are accounted as idle. This may mislead, for example, cpufreq governor.
Quoted 3 lines
Quoted 2 lines
TACC_IRQ- the pcpu performs interrupts processing, without separation to
guest or hypervisor interruptsI think, word "distinguishing" would be better than "separation"
Why so?
Quoted 51 lines
Quoted 40 lines
TACC_GSYNC- the pcpu executes hypervisor code to process synchronous trap
from the guest. E.g. hypercall processing or io emulation.Currently, the only reenterant state is
TACC_IRQ. It is assumed, no changes to state other thanTACC_IRQcould happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other states. It is acumulated between other states transition moments, and is substracted from the old state on states transion calculation.Signed-off-by Andrii Anisov <[email protected]>--- xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 27 +++++++++++++++++ 2 files changed, 108 insertions(+)xen/common/schedule.c +16
-0@@ -1539,6 +1539,87 @@ static void schedule(void)context_switch (prev, next); } +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change (enum TACC_STATES new_state) +{ +s_time_t now, delta; +struct tacc * tacc = &this_cpu (tacc); +unsigned long flags; + +local_irq_save (flags); + + now =NOW (); + delta = now - tacc->state_entry_time; + +/* We do not expect states reenterability (at least through this function)*/ +ASSERT (new_state != tacc->state); +xen/common/schedule.c static void schedule(void) · line 1567
Quoted 10 lines
xen/common/schedule.c +10
-0+ tacc->state_time[tacc->state] += delta - tacc->irq_time; + tacc->state_time[TACC_IRQ ] += tacc->irq_time; + tacc->irq_time =0 ; + tacc->state = new_state; + tacc->state_entry_time = now; + +local_irq_restore (flags); +} + +void tacc_hyp (int place)I believe, you want some enum for this "place" parameter type
Quoted 7 lines
xen/common/schedule.c static void schedule(void) · line 1569
Quoted 2 lines
xen/common/schedule.c +2
-0+{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place); Please, don't push commented-out code. BTW, I think, it is possible to add some
TACC_DEBUGfacilities to enable/disable this traces during compile-time.Also, looks like you don't use "place" parameter at all.
Since that is the RFC, I've comforted myself with leaving my debug code in place. I hope it should not be confusing.
Quoted 3 lines
Lastly, I believe that this function (and other similar functions below) can be defined as "static inline" in a header file
Not this time. They are mostly called from asm (at least now).
Quoted 22 lines
Quoted 22 lines
xen/common/schedule.c +21
-0+tacc_state_change (TACC_HYP ); +} + +void tacc_guest (int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GUEST ); +} + +void tacc_idle (int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_IDLE ); +} + +void tacc_gsync (int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GSYNC ); +} +
Quoted 8 lines
xen/common/schedule.c static void schedule(void) · line 1597
Quoted 7 lines
xen/common/schedule.c +7
-0+void tacc_irq_enter (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id(), place, this_cpu(tacc).irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >=0 );You can make
irq_cntunsigned and drop this assert.
No. Otherwise one might miss proper call sequence when utilize this for the different arch, and have no notice from the debug assertion.
Quoted 6 lines
xen/common/schedule.c static void schedule(void) · line 1602
Quoted 6 lines
xen/common/schedule.c +5
-0+ +if ( tacc->irq_cnt ==0 ) + { + tacc->irq_enter_time =NOW (); + }
Quoted 9 lines
Coding style:
---
Braces should be omitted for blocks with a single statement. e.g.,if ( condition )
single_statement();---
OK.
Quoted 12 lines
Quoted 12 lines
xen/common/schedule.c +12
-0+ + tacc->irq_cnt++; +} + +void tacc_irq_exit (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(), place, tacc->irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >0 ); +if ( tacc->irq_cnt ==1 )
Quoted 8 lines
xen/common/schedule.c static void schedule(void) · line 1620
Quoted 6 lines
xen/common/schedule.c +6
-0+ { + tacc->irq_time =NOW () - tacc->irq_enter_time; + tacc->irq_enter_time =0 ; + } + + tacc->irq_cnt--;What if, you IRQ will arrive right after this? I believe, you will lose some of the accumulated time.
See ASSERT(!local_irq_is_enabled()) above.
Quoted 12 lines
Quoted 12 lines
xen/common/schedule.c +2
-0+} +void context_saved (struct vcpu *prev) {/* Clear running flag /after/ writing context to memory. */ xen/include/xen/sched.h +0
-0@@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key);
Quoted 4 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1005
Quoted 3 lines
xen/include/xen/sched.h +1
-0void arch_do_physinfo (struct xen_sysctl_physinfo *pi); +enum TACC_STATES {If I remember correct, enum names should in lower case
Ugh...
Quoted 15 lines
Quoted 4 lines
xen/include/xen/sched.h +3
-0+TACC_HYP =0 , +TACC_GUEST =1 , + TACC_IDLE = 2,xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1018
Quoted 10 lines
xen/include/xen/sched.h +10
-0+TACC_IRQ =3 , +TACC_GSYNC =4 , +TACC_STATES_MAX +}; + +struct tacc +{ +s_time_t state_time[TACC_STATES_MAX ]; +s_time_t state_entry_time; +int state;enum, maybe?
Maybe.
Quoted 14 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1030
Quoted 13 lines
xen/include/xen/sched.h +12
-0+ +s_time_t guest_time; + +s_time_t irq_enter_time; +s_time_t irq_time; +int irq_cnt; +}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp (int place); +void tacc_idle (int place);What about functions from
sched.c? Should they be declared there?
Maybe.
Quoted 7 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1034
Quoted 5 lines
xen/include/xen/sched.h +1
-0+#endif /* __SCHED_H__ */ /*
[1] https://elixir.bootlin.com/linux/latest/source/kernel/sched/cputime.c#L429
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
In reply to Andrii AnisovHi Andrii,
Sorry for the late answer. It would be good to get a review from the scheduler maintainers (Dario, George) to make sure they are happy with the suggested states here.
Please see my comments below.
Quoted 3 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Introduce per-pcpu time accounting what includes the following states:
I think we need a very detailed description of each states. Otherwise it will be hard to know how to categorize it.
Quoted 3 lines
TACC_HYP- the pcpu executes hypervisor code like softirq processing
(including scheduling), tasklets and context switches
IHMO, "like" is too weak here. What do you exactly plan to introduce?
For instance, on Arm, you consider that leave_hypervisor_tail() is part of TACC_HYP. This function will include some handling for synchronous trap.
Quoted 1 line
TACC_GUEST- the pcpu executes guests code
Looking at the arm64 code, you are executing some hypervisor code here. I agree this is impossible to not run any hypervisor code with TACC_GUEST, but I think this should be clarified in the documentation.
Quoted 1 line
TACC_IDLE- the low-power state of the pcpu
Did you intend to mean "idle vCPU" is in use?
Quoted 8 lines
TACC_IRQ- the pcpu performs interrupts processing, without separation to
guest or hypervisor interruptsTACC_GSYNC- the pcpu executes hypervisor code to process synchronous trap
from the guest. E.g. hypercall processing or io emulation.Currently, the only reenterant state is
TACC_IRQ. It is assumed, no changes to state other thanTACC_IRQcould happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other states.
s/comparing/compare/
Quoted 1 line
It is acumulated between other states transition moments, and is substracted
s/acumulated/accumulated/ s/substracted/subtracted/
Quoted 1 line
from the old state on states transion calculation.
s/transion/transition/
Quoted 12 lines
Signed-off-by Andrii Anisov <[email protected]>--- xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 27 +++++++++++++++++ 2 files changed, 108 insertions(+)xen/common/schedule.c +0
-0
xen/common/schedule.c static void schedule(void) · line 1544
Quoted 6 lines
xen/common/schedule.c +3
-0@@ -1539,6 +1539,87 @@ static void schedule(void)context_switch (prev, next); } +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change (enum TACC_STATES new_state)
This should never be called with the TACC_IRQ, right?
Quoted 13 lines
xen/common/schedule.c +13
-0+{ +s_time_t now, delta; +struct tacc * tacc = &this_cpu (tacc); +unsigned long flags; + +local_irq_save (flags); + + now =NOW (); + delta = now - tacc->state_entry_time; + +/* We do not expect states reenterability (at least through this function)*/ +ASSERT (new_state != tacc->state); +
xen/common/schedule.c static void schedule(void) · line 1567
Quoted 10 lines
xen/common/schedule.c +10
-0+ tacc->state_time[tacc->state] += delta - tacc->irq_time; + tacc->state_time[TACC_IRQ ] += tacc->irq_time; + tacc->irq_time =0 ; + tacc->state = new_state; + tacc->state_entry_time = now; + +local_irq_restore (flags); +} + +void tacc_hyp (int place)
Place is never used except for your commented printk. So what's the goal for it?
Also, is it really necessary to provide helper for each state? Couldn't we just introduce one functions doing all the state?
Quoted 39 lines
xen/common/schedule.c +39
-0+{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_HYP ); +} + +void tacc_guest (int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GUEST ); +} + +void tacc_idle (int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_IDLE ); +} + +void tacc_gsync (int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GSYNC ); +} + +void tacc_irq_enter (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id(), place, this_cpu(tacc).irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >=0 ); + +if ( tacc->irq_cnt ==0 ) + { + tacc->irq_enter_time =NOW (); + } + + tacc->irq_cnt++; +} +
xen/common/schedule.c static void schedule(void) · line 1616
Quoted 10 lines
xen/common/schedule.c +10
-0+void tacc_irq_exit (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(), place, tacc->irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >0 ); +if ( tacc->irq_cnt ==1 ) + { + tacc->irq_time =NOW () - tacc->irq_enter_time;
If I understand correctly, you will use irq_time to update TACC_IRQ in tacc_state_change(). It may be possible to receive another interrupt before the state is changed (e.g. HYP -> GUEST). This means only the time for the last IRQ received would be accounted.
Quoted 14 lines
xen/common/schedule.c +6
-0+ tacc->irq_enter_time =0 ; + } + + tacc->irq_cnt--; +} +void context_saved (struct vcpu *prev) {/* Clear running flag /after/ writing context to memory. */ xen/include/xen/sched.h +0
-0
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1005
Quoted 4 lines
xen/include/xen/sched.h +1
-0@@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key);void arch_do_physinfo (struct xen_sysctl_physinfo *pi); +enum TACC_STATES {
We don't tend to use all uppercases for enum name.
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1006
Quoted 1 line
xen/include/xen/sched.h +1
-0+ TACC_HYP = 0,
enum begins at 0 and increment by one every time. So there is no need to hardcode a number.
Also, looking at the code, I think you rely on the first state to be TACC_HYP. Am I correct?
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1012
Quoted 6 lines
xen/include/xen/sched.h +6
-0+TACC_GUEST =1 , +TACC_IDLE =2 , +TACC_IRQ =3 , +TACC_GSYNC =4 , + TACC_STATES_MAX +};
It would be good to document all the states in the header as well.
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1014
Quoted 2 lines
xen/include/xen/sched.h +2
-0+ +struct tacc
Please document the structure.
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1018
Quoted 4 lines
xen/include/xen/sched.h +4
-0+{ +s_time_t state_time[TACC_STATES_MAX ]; +s_time_t state_entry_time; +int state;
This should be the enum you used above here.
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1020
Quoted 2 lines
xen/include/xen/sched.h +2
-0+ +s_time_t guest_time;
This is not used.
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1024
Quoted 4 lines
xen/include/xen/sched.h +4
-0+ +s_time_t irq_enter_time; +s_time_t irq_time; +int irq_cnt;
Why do you need this to be signed?
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1034
Quoted 11 lines
xen/include/xen/sched.h +7
-0+}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp (int place); +void tacc_idle (int place); +#endif /* __SCHED_H__ */ /*
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Hello Julien,
Quoted 1 line · Julien Grall
It would be good to get a review from the scheduler maintainers (Dario, George) to make sure they are happy with the suggested states here.
I would not say I'm completely happy with this set of states. I'd like to have a discussion on this topic with scheduler maintainers. Also because they could have a different view from x86 world.
Quoted 3 lines
Quoted 1 line
Introduce per-pcpu time accounting what includes the following states:
I think we need a very detailed description of each states. Otherwise it will be hard to know how to categorize it.
I agree that we need a very detailed description of each states. Ask questions if something is not clear or doubtful. I guess we could have something better after Q&A process.
Quoted 6 lines
Quoted 4 lines
TACC_HYP- the pcpu executes hypervisor code like softirq processing (including scheduling), tasklets and context switchesIHMO, "like" is too weak here. What do you exactly plan to introduce?
I think this should be what hypervisor does except hypercall and IO emulation (what is TACC_GSYNC).
Quoted 2 lines
For instance, on Arm, you consider that
leave_hypervisor_tail()is part ofTACC_HYP. This function will include some handling for synchronous trap.
I guess you are saying about p2m_flush_vm. I doubt here, and open for suggestions.
Quoted 3 lines
Quoted 1 line
TACC_GUEST- the pcpu executes guests codeLooking at the arm64 code, you are executing some hypervisor code here. I agree this is impossible to not run any hypervisor code with
TACC_GUEST, but I think this should be clarified in the documentation.
Do you mean adding few words about still having some hypervisor code near the actual context switch from/to guest (entry/return_from_trap)?
Quoted 4 lines
Quoted 2 lines
TACC_IDLE- the low-power state of the pcpuDid you intend to mean "idle vCPU" is in use?
No. I did mean what is written.
Currently, the idle vcpu does hypervisor work (e.g. tasklets) along with the low-power mode. IMO we have to separate them.
Quoted 11 lines
Quoted 9 lines
TACC_IRQ- the pcpu performs interrupts processing, without separation to guest or hypervisor interruptsTACC_GSYNC- the pcpu executes hypervisor code to process synchronous trap from the guest. E.g. hypercall processing or io emulation.Currently, the only reenterant state is
TACC_IRQ. It is assumed, no changes to state other thanTACC_IRQcould happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other states.s/comparing/compare/
OK.
Quoted 4 lines
Quoted 2 lines
It is acumulated between other states transition moments, and is substracted
s/acumulated/accumulated/ s/substracted/subtracted/
OK.
Quoted 2 lines
Quoted 2 lines
from the old state on states transion calculation.
[1]
Quoted 2 lines
s/transion/transition/
OK.
Quoted 8 lines
Quoted 8 lines
Signed-off-by Andrii Anisov <[email protected]>---
xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++xen/include/xen/sched.h| 27 +++++++++++++++++2 files changed, 108 insertions(+)
Quoted 12 lines
xen/common/schedule.c static void schedule(void) · line 1543
Quoted 10 lines
xen/common/schedule.c +3
-0@@ -1539,6 +1539,87 @@ static void schedule(void) context_switch(prev, next); } +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change (enum TACC_STATES new_state)This should never be called with the
TACC_IRQ, right?
Yes. Actually, tacc->state should never be TACC_IRQ.
Because of TACC_IRQ reenterability it is handled through the tacc->irq_cnt and tacc->irq_enter_time.
Quoted 18 lines
Quoted 18 lines
xen/common/schedule.c +17
-0+{ + s_time_t now, delta; + struct tacc* tacc = &this_cpu(tacc); + unsigned long flags; + + local_irq_save(flags); + + now = NOW(); + delta = now - tacc->state_entry_time; + + /* We do not expect states reenterability (at least through this function)*/ + ASSERT(new_state != tacc->state); + + tacc->state_time[tacc->state] += delta - tacc->irq_time; + tacc->state_time[TACC_IRQ] += tacc->irq_time; + tacc->irq_time = 0; + tacc->state = new_state;
Quoted 8 lines
xen/common/schedule.c static void schedule(void) · line 1567
Quoted 6 lines
xen/common/schedule.c +6
-0+ tacc->state_entry_time = now; + + local_irq_restore(flags); +} + +void tacc_hyp (int place)Place is never used except for your commented printk. So what's the goal for it?
Place is just a piece of code used for debugging, as well as printk. I keept it here because this series is very RFC, yet it could be removed.
Quoted 1 line
Also, is it really necessary to provide helper for each state? Couldn't we just introduce one functions doing all the state?
I'd like calling that stuff from assembler without parameters. But have no strong opinion here.
Quoted 43 lines
Quoted 43 lines
xen/common/schedule.c +43
-0+{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_HYP); +} + +void tacc_guest (int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_GUEST); +} + +void tacc_idle (int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_IDLE); +} + +void tacc_gsync (int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_GSYNC); +} + +void tacc_irq_enter (int place) +{ + struct tacc* tacc = &this_cpu(tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id(), place, this_cpu(tacc).irq_cnt); + ASSERT(!local_irq_is_enabled()); + ASSERT(tacc->irq_cnt >= 0); + + if ( tacc->irq_cnt == 0 ) + { + tacc->irq_enter_time = NOW(); + } + + tacc->irq_cnt++; +} + +void tacc_irq_exit (int place) +{ + struct tacc* tacc = &this_cpu(tacc); +
Quoted 8 lines
xen/common/schedule.c static void schedule(void) · line 1616
Quoted 6 lines
xen/common/schedule.c +6
-0+// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(), place, tacc->irq_cnt); + ASSERT(!local_irq_is_enabled()); + ASSERT(tacc->irq_cnt > 0); + if ( tacc->irq_cnt == 1 ) + { + tacc->irq_time = NOW() - tacc->irq_enter_time;If I understand correctly, you will use
irq_timeto updateTACC_IRQintacc_state_change(). It may be possible to receive another interrupt before the state is changed (e.g. HYP -> GUEST). This means only the time for the last IRQ received would be accounted.
I do lock IRQs for state change. Shouldn't that protect it?
Quoted 11 lines
Quoted 11 lines
xen/common/schedule.c +6
-0+ tacc->irq_enter_time = 0; + } + + tacc->irq_cnt--; +} + void context_saved(struct vcpu *prev) { /* Clear running flag /after/ writing context to memory. */xen/include/xen/sched.h +0
-0
Quoted 8 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1003
Quoted 6 lines
index e3601c1..04a8724 100644
xen/include/xen/sched.h +1
-0@@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key); void arch_do_physinfo(struct xen_sysctl_physinfo *pi); +enum TACC_STATES {We don't tend to use all uppercases for enum name.
OK.
Quoted 6 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1006
Quoted 2 lines
xen/include/xen/sched.h +1
-0+ TACC_HYP = 0,enum begins at 0 and increment by one every time. So there is no need to hardcode a number.
Also, looking at the code, I think you rely on the first state to be
TACC_HYP. Am I correct?
TACC_HYP is expected to be the initial state of the PCPU.
Quoted 8 lines
Quoted 8 lines
xen/include/xen/sched.h +6
-0+ TACC_GUEST = 1, + TACC_IDLE = 2, + TACC_IRQ = 3, + TACC_GSYNC = 4, + TACC_STATES_MAX +};It would be good to document all the states in the header as well.
OK.
Quoted 5 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1014
Quoted 3 lines
xen/include/xen/sched.h +2
-0+ +struct tacc Please document the structure.
OK.
Quoted 7 lines
Quoted 5 lines
+{
+s_time_tstate_time[TACC_STATES_MAX];
+s_time_tstate_entry_time;
+ int state;This should be the enum you used above here.
Yep.
Quoted 4 lines
Quoted 2 lines
+
+s_time_tguest_time;This is not used.
Yep, will drop it.
Quoted 6 lines
Quoted 5 lines
+
+s_time_tirq_enter_time;
+s_time_tirq_time;
+ intirq_cnt;Why do you need this to be signed?
For assertion.
Quoted 13 lines
Quoted 10 lines
xen/include/xen/sched.h +7
-0+}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp (int place); +void tacc_idle (int place); +#endif /*
__SCHED_H__*/
/*Cheers,
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Hello All,
This is gentle reminder about this RFC.
Sadly, Andrii Anisov has left our team. But I'm commited to continue his work on time accounting and real time scheduling.
I do realize, that proposed patches have become moldy. I can rebase them onto current master, if it would help.
Quoted 6 lines · Andrii Anisov
Hello Julien,
Quoted 1 line · Julien Grall
It would be good to get a review from the scheduler maintainers (Dario, George) to make sure they are happy with the suggested states here.
I would not say I'm completely happy with this set of states. I'd like to have a discussion on this topic with scheduler maintainers. Also because they could have a different view from x86 world.
I would love to hear any inputs on this topc from general scheduling approach standpoint and from x86 view.
Quoted 247 lines
Quoted 3 lines
Quoted 1 line
Introduce per-pcpu time accounting what includes the following states:
I think we need a very detailed description of each states. Otherwise it will be hard to know how to categorize it.
I agree that we need a very detailed description of each states. Ask questions if something is not clear or doubtful. I guess we could have something better after Q&A process.
Quoted 4 lines
Quoted 2 lines
TACC_HYP- the pcpu executes hypervisor code like softirq processing
(including scheduling), tasklets and context switchesIHMO, "like" is too weak here. What do you exactly plan to introduce?
I think this should be what hypervisor does except hypercall and IO emulation (what is
TACC_GSYNC).Quoted 1 line
For instance, on Arm, you consider that
leave_hypervisor_tail()is part ofTACC_HYP. This function will include some handling for synchronous trap.I guess you are saying about
p2m_flush_vm. I doubt here, and open for suggestions.Quoted 3 lines
Quoted 1 line
TACC_GUEST- the pcpu executes guests codeLooking at the arm64 code, you are executing some hypervisor code here. I agree this is impossible to not run any hypervisor code with
TACC_GUEST, but I think this should be clarified in the documentation.Do you mean adding few words about still having some hypervisor code near the actual context switch from/to guest (entry/return_from_trap)?
Quoted 3 lines
Quoted 1 line
TACC_IDLE- the low-power state of the pcpuDid you intend to mean "idle vCPU" is in use?
No. I did mean what is written.
Currently, the idle vcpu does hypervisor work (e.g. tasklets) along with the low-power mode. IMO we have to separate them.Quoted 10 lines
Quoted 8 lines
TACC_IRQ- the pcpu performs interrupts processing, without separation to
guest or hypervisor interruptsTACC_GSYNC- the pcpu executes hypervisor code to process synchronous trap
from the guest. E.g. hypercall processing or io emulation.Currently, the only reenterant state is
TACC_IRQ. It is assumed, no changes to state other thanTACC_IRQcould happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other states.s/comparing/compare/
OK.
Quoted 3 lines
Quoted 1 line
It is acumulated between other states transition moments, and is substracted
s/acumulated/accumulated/ s/substracted/subtracted/
OK.
Quoted 1 line
Quoted 1 line
from the old state on states transion calculation.
[1]
Quoted 1 line
s/transion/transition/
OK.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Andrii Anisov <[email protected]>--- xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 27 +++++++++++++++++ 2 files changed, 108 insertions(+)Quoted 12 lines
xen/common/schedule.c static void schedule(void) · line 1543
Quoted 10 lines
xen/common/schedule.c +3
-0@@ -1539,6 +1539,87 @@ static void schedule(void)context_switch (prev, next); } +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change (enum TACC_STATES new_state)This should never be called with the
TACC_IRQ, right?Yes. Actually,
tacc->stateshould never beTACC_IRQ.
Because ofTACC_IRQreenterability it is handled through thetacc->irq_cntandtacc->irq_enter_time.Quoted 17 lines
Quoted 17 lines
xen/common/schedule.c +17
-0+{ +s_time_t now, delta; +struct tacc * tacc = &this_cpu (tacc); +unsigned long flags; + +local_irq_save (flags); + + now =NOW (); + delta = now - tacc->state_entry_time; + +/* We do not expect states reenterability (at least through this function)*/ +ASSERT (new_state != tacc->state); + + tacc->state_time[tacc->state] += delta - tacc->irq_time; + tacc->state_time[TACC_IRQ ] += tacc->irq_time; + tacc->irq_time =0 ; + tacc->state = new_state;Quoted 8 lines
xen/common/schedule.c static void schedule(void) · line 1567
Quoted 6 lines
xen/common/schedule.c +6
-0+ tacc->state_entry_time = now; + +local_irq_restore (flags); +} + +void tacc_hyp (int place)Place is never used except for your commented printk. So what's the goal for it?
Place is just a piece of code used for debugging, as well as printk. I keept it here because this series is very RFC, yet it could be removed.
Quoted 1 line
Also, is it really necessary to provide helper for each state? Couldn't we just introduce one functions doing all the state?
I'd like calling that stuff from assembler without parameters. But have no strong opinion here.
Quoted 43 lines
Quoted 43 lines
xen/common/schedule.c +43
-0+{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_HYP ); +} + +void tacc_guest (int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GUEST ); +} + +void tacc_idle (int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_IDLE ); +} + +void tacc_gsync (int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place); +tacc_state_change (TACC_GSYNC ); +} + +void tacc_irq_enter (int place) +{ +struct tacc * tacc = &this_cpu (tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id(), place, this_cpu(tacc).irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >=0 ); + +if ( tacc->irq_cnt ==0 ) + { + tacc->irq_enter_time =NOW (); + } + + tacc->irq_cnt++; +} + +void tacc_irq_exit (int place) +{ +struct tacc * tacc = &this_cpu (tacc); +Quoted 8 lines
xen/common/schedule.c static void schedule(void) · line 1616
Quoted 6 lines
xen/common/schedule.c +6
-0+// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(), place, tacc->irq_cnt); +ASSERT (!local_irq_is_enabled ()); +ASSERT (tacc->irq_cnt >0 ); +if ( tacc->irq_cnt ==1 ) + { + tacc->irq_time =NOW () - tacc->irq_enter_time;If I understand correctly, you will use
irq_timeto updateTACC_IRQintacc_state_change(). It may be possible to receive another interrupt before the state is changed (e.g. HYP -> GUEST). This means only the time for the last IRQ received would be accounted.I do lock IRQs for state change. Shouldn't that protect it?
Quoted 10 lines
Quoted 10 lines
xen/common/schedule.c +6
-0+ tacc->irq_enter_time =0 ; + } + + tacc->irq_cnt--; +} +void context_saved (struct vcpu *prev) {/* Clear running flag /after/ writing context to memory. */ xen/include/xen/sched.h +0
-0Quoted 8 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1003
Quoted 6 lines
index e3601c1..04a8724 100644
xen/include/xen/sched.h +1
-0@@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key);void arch_do_physinfo (struct xen_sysctl_physinfo *pi); +enum TACC_STATES {We don't tend to use all uppercases for enum name.
OK.
Quoted 5 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1006
Quoted 1 line
xen/include/xen/sched.h +1
-0+ TACC_HYP = 0,enum begins at 0 and increment by one every time. So there is no need to hardcode a number.
Also, looking at the code, I think you rely on the first state to be
TACC_HYP. Am I correct?
TACC_HYPis expected to be the initial state of the PCPU.Quoted 7 lines
Quoted 7 lines
xen/include/xen/sched.h +6
-0+TACC_GUEST =1 , +TACC_IDLE =2 , +TACC_IRQ =3 , +TACC_GSYNC =4 , + TACC_STATES_MAX +};It would be good to document all the states in the header as well.
OK.
Quoted 4 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1014
Quoted 2 lines
xen/include/xen/sched.h +2
-0+ +struct tacc Please document the structure.
OK.
Quoted 6 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1018
Quoted 4 lines
xen/include/xen/sched.h +4
-0+{ +s_time_t state_time[TACC_STATES_MAX ]; +s_time_t state_entry_time; +int state;This should be the enum you used above here.
Yep.
Quoted 4 lines
xen/include/xen/sched.h
Quoted 2 lines
xen/include/xen/sched.h +2
-0+ +s_time_t guest_time;This is not used.
Yep, will drop it.
Quoted 5 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1024
Quoted 4 lines
xen/include/xen/sched.h +4
-0+ +s_time_t irq_enter_time; +s_time_t irq_time; +int irq_cnt;Why do you need this to be signed?
For assertion.
Quoted 13 lines
xen/include/xen/sched.h extern void dump_runq(unsigned char key); · line 1034
Quoted 10 lines
xen/include/xen/sched.h +7
-0+}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp (int place); +void tacc_idle (int place); +#endif /* __SCHED_H__ */ /* Cheers,
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Quoted 2 lines · Volodymyr Babchuk
Hello All,
Hello Volodymyr,
Quoted 5 lines
This is gentle reminder about this RFC.
Sadly, Andrii Anisov has left our team. But I'm commited to continue his work on time accounting and real time scheduling.
Ok, so, first of all, sorry that this has not been properly addressed.
I personally never forgot about it or anything... Still, I haven't been able to look into it properly.
Quoted 3 lines
I do realize, that proposed patches have become moldy. I can rebase them onto current master, if it would help.
As a matter of fact, it would. Especially considering that, AFAICT, this pre-dates core-scheduling.
So, if you're really keen doing such a rebase and resending, I will be happy to have a look at how it ends up looking like.
Thanks and Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Quoted 5 lines · Dario Faggioli
Quoted 2 lines · Volodymyr Babchuk
Hello All,
Hello Volodymyr,
Hi Dario,
Quoted 10 lines
Quoted 5 lines
This is gentle reminder about this RFC.
Sadly, Andrii Anisov has left our team. But I'm commited to continue his work on time accounting and real time scheduling.
Ok, so, first of all, sorry that this has not been properly addressed.
I personally never forgot about it or anything... Still, I haven't been able to look into it properly.
I see.. Anyways, thanks for the reply.
Actually, I tried to not only rebase this patch series to the current mainline, but also to add x86 support. This gave me deeper unsterstanding of the inner workings. At least I hope so :)
Anyways, I want to discuss the matter before continuing reworking the patches. The goal of those patches is to account guest time more precisely.
Right now I can see only two main reasons, when guest can be charged for a time it dindn't used: interrupts and soft irqs.
- do_softirq() is called every time we leave hypervisor mode. It is used to do housekeeping for the hypervisor itself. But, some random guest will charged for time spent in do_softirq() unless this function is not called on a idle vcpu.
- also, pCPU can be interrupted by IRQ assigned to some other guest or to hypervisor itself. But time spent in interrupt handler will be charged for a guest being interrupted.
So, basically, to account guest time correctly, we need to substract time spent in do_softirq() and in do_IRQ().
Actually, we can charge the correct guest for time spent in do_IRQ(), because handler code will eventually know target vCPU for the interrupt. There is technical problem with interrupt nesting. We will need some stack to track nesting correctly. But this is doable.
Just for statistical purposes we can track hypervisor time somwhere, but it is not needed for scheduling decisions.
Am I missing something?
Re: [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu time accounting
Quoted 6 lines · Volodymyr Babchuk
Quoted 1 line · Dario Faggioli
Actually, I tried to not only rebase this patch series to the current mainline, but also to add x86 support. This gave me deeper unsterstanding of the inner workings. At least I hope so :)
Right.
Quoted 4 lines
Anyways, I want to discuss the matter before continuing reworking the patches. The goal of those patches is to account guest time more precisely.
Yes, I agree. IIRC, the patches are doing more than that, e.g., discriminating between the runtime of the idle vCPUs and the time during which the CPUs were actually idle, and even trying to classify somehow what the hypervisor was actually doing (guest sync, etc).
But, indeed, I would very much start with the one yous stated above, as a goal.
Quoted 9 lines
Right now I can see only two main reasons, when guest can be charged for a time it dindn't used: interrupts and soft irqs.
-
do_softirq()is called every time we leave hypervisor mode. It is used to do housekeeping for the hypervisor itself. But, some random guest will charged for time spent indo_softirq()unless this function
is not called on a idle vcpu.
Quoted 5 lines
- also, pCPU can be interrupted by IRQ assigned to some other guest or
to hypervisor itself. But time spent in interrupt handler will be charged for a guest being interrupted.
I think those are the ones, yes.
Quoted 3 lines
So, basically, to account guest time correctly, we need to substract time spent in
do_softirq()and indo_IRQ().
That's how I'd try to do this, if it were me doing it.
Quoted 5 lines
Actually, we can charge the correct guest for time spent in
do_IRQ(), because handler code will eventually know target vCPU for the interrupt. There is technical problem with interrupt nesting. We will need some stack to track nesting correctly. But this is doable.
Yes, there's this, and maybe a few other "dependencies" that we may discuss about, and try to track and account for, for even greather fairness. But maybe this can come as a second step?
Quoted 3 lines
Just for statistical purposes we can track hypervisor time somwhere, but it is not needed for scheduling decisions.
What we need is, I think, a way to tell the used/admin that that time is being spent in the hypervisor. E.g., if we were spending (let's exaggerate) 20% of the time processing interrupts and softirqs, the user would see some of this 20% load coming from each guest. It certainly wasn't ideal, but we do not want for such 20% to suddenly vanish either.
Quoted 2 lines
Am I missing something?
To me, it seems you're not. :-)
Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)
RFC 2/9 sysctl: extend XEN_SYSCTL_getcpuinfo interface
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
Extend XEN_SYSCTL_getcpuinfo interface with timing information provided by introduced time accounting infrastructure.
--- xen/common/schedule.c | 33 ++++++++++++++++++++++++++++----- xen/common/sysctl.c | 4 ++++ xen/include/public/sysctl.h | 4 ++++ xen/include/xen/sched.h | 4 ++++ 4 files changed, 40 insertions(+), 5 deletions(-)
xen/common/schedule.c +28 -5
@@ -208,13 +208,36 @@ void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate)uint64_t get_cpu_idle_time (unsigned int cpu) { -struct vcpu_runstate_info state = {0 }; -struct vcpu *v = idle_vcpu[cpu]; +struct tacc *tacc = &per_cpu (tacc, cpu); -if (cpu_online (cpu) && v ) -vcpu_runstate_get (v, &state); +return tacc->state_time[TACC_IDLE ]; +} + +uint64_t get_cpu_guest_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); + +return tacc->state_time[TACC_GUEST ]; +} + +uint64_t get_cpu_hyp_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); + +return tacc->state_time[TACC_HYP ]; +} + +uint64_t get_cpu_irq_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); + +return tacc->state_time[TACC_IRQ ]; +} +uint64_t get_cpu_gsync_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); -return state.time[RUNSTATE_running]; +return tacc->state_time[TACC_GSYNC ]; }/*
xen/common/sysctl.c +4 -0
@@ -152,6 +152,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)for ( i =0 ; i < nr_cpus; i++ ) { cpuinfo.idletime =get_cpu_idle_time (i); + cpuinfo.guesttime =get_cpu_guest_time (i); + cpuinfo.hyptime =get_cpu_hyp_time (i); + cpuinfo.gsynctime =get_cpu_gsync_time (i); + cpuinfo.irqtime =get_cpu_irq_time (i);if (copy_to_guest_offset (op->u.getcpuinfo.info, i, &cpuinfo,1 ) ) goto out;
xen/include/public/sysctl.h +4 -0
@@ -168,6 +168,10 @@ struct xen_sysctl_debug_keys {/* XEN_SYSCTL_getcpuinfo */ struct xen_sysctl_cpuinfo {uint64_aligned_t idletime; +uint64_aligned_t hyptime; +uint64_aligned_t guesttime; +uint64_aligned_t irqtime; +uint64_aligned_t gsynctime; };typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cpuinfo_t);
xen/include/xen/sched.h +4 -0
@@ -876,6 +876,10 @@ void restore_vcpu_affinity(struct domain *d);void vcpu_runstate_get (struct vcpu *v,struct vcpu_runstate_info *runstate);uint64_t get_cpu_idle_time (unsigned int cpu); +uint64_t get_cpu_hyp_time (unsigned int cpu); +uint64_t get_cpu_guest_time (unsigned int cpu); +uint64_t get_cpu_gsync_time (unsigned int cpu); +uint64_t get_cpu_irq_time (unsigned int cpu);/* * Used by idle loop to decide whether there is work to do:
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 2/9] sysctl: extend XEN_SYSCTL_getcpuinfo interface
Hi,
Quoted 18 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Extend
XEN_SYSCTL_getcpuinfointerface with timing information provided by introduced time accounting infrastructure.Signed-off-by Andrii Anisov <[email protected]>--- xen/common/schedule.c | 33 ++++++++++++++++++++++++++++----- xen/common/sysctl.c | 4 ++++ xen/include/public/sysctl.h | 4 ++++ xen/include/xen/sched.h | 4 ++++ 4 files changed, 40 insertions(+), 5 deletions(-)xen/common/schedule.c +0
-0
xen/common/schedule.c void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) · line 213
Quoted 10 lines
xen/common/schedule.c +2
-4@@ -208,13 +208,36 @@ void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate)uint64_t get_cpu_idle_time (unsigned int cpu) { -struct vcpu_runstate_info state = {0 }; -struct vcpu *v = idle_vcpu[cpu]; +struct tacc *tacc = &per_cpu (tacc, cpu); -if (cpu_online (cpu) && v ) -vcpu_runstate_get (v, &state); +return tacc->state_time[TACC_IDLE ];
So what's the difference between the current idle time and the new version?
Quoted 19 lines
xen/common/schedule.c +19
-0+} + +uint64_t get_cpu_guest_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); + +return tacc->state_time[TACC_GUEST ]; +} + +uint64_t get_cpu_hyp_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); + +return tacc->state_time[TACC_HYP ]; +} + +uint64_t get_cpu_irq_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu);
xen/common/schedule.c void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) · line 241
Quoted 10 lines
xen/common/schedule.c +7
-1+ +return tacc->state_time[TACC_IRQ ]; +} +uint64_t get_cpu_gsync_time (unsigned int cpu) +{ +struct tacc *tacc = &per_cpu (tacc, cpu); -return state.time[RUNSTATE_running]; +return tacc->state_time[TACC_GSYNC ]; }
You may want to introduce an helper retrieving the time for a given state rather than duplicating it.
Quoted 7 lines
xen/common/schedule.c +0
-0/* xen/common/sysctl.c +0
-0
xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 158
Quoted 7 lines
xen/common/sysctl.c +4
-0@@ -152,6 +152,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)for ( i =0 ; i < nr_cpus; i++ ) { cpuinfo.idletime =get_cpu_idle_time (i); + cpuinfo.guesttime =get_cpu_guest_time (i); + cpuinfo.hyptime =get_cpu_hyp_time (i); + cpuinfo.gsynctime =get_cpu_gsync_time (i); + cpuinfo.irqtime =get_cpu_irq_time (i);
It feels to me we want a function that fills up the structure.
xen/include/public/sysctl.h
Quoted 7 lines
xen/common/sysctl.c +0
-0if (copy_to_guest_offset (op->u.getcpuinfo.info, i, &cpuinfo,1 ) ) goto out;xen/include/public/sysctl.h +0
-0
As a side note, SYSCTL version will need to be bumped if this wasn't done before during the current release.
Quoted 17 lines
xen/include/public/sysctl.h +4
-0@@ -168,6 +168,10 @@ struct xen_sysctl_debug_keys {/* XEN_SYSCTL_getcpuinfo */ struct xen_sysctl_cpuinfo {uint64_aligned_t idletime; +uint64_aligned_t hyptime; +uint64_aligned_t guesttime; +uint64_aligned_t irqtime; +uint64_aligned_t gsynctime; };typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cpuinfo_t);xen/include/xen/sched.h +0
-0
xen/include/xen/sched.h void restore_vcpu_affinity(struct domain *d); · line 885
Quoted 10 lines
xen/include/xen/sched.h +4
-0@@ -876,6 +876,10 @@ void restore_vcpu_affinity(struct domain *d);void vcpu_runstate_get (struct vcpu *v,struct vcpu_runstate_info *runstate);uint64_t get_cpu_idle_time (unsigned int cpu); +uint64_t get_cpu_hyp_time (unsigned int cpu); +uint64_t get_cpu_guest_time (unsigned int cpu); +uint64_t get_cpu_gsync_time (unsigned int cpu); +uint64_t get_cpu_irq_time (unsigned int cpu);/* * Used by idle loop to decide whether there is work to do:
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 2/9] sysctl: extend XEN_SYSCTL_getcpuinfo interface
Hello Julien
Quoted 16 lines · Julien Grall
Hi,
Quoted 13 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Extend
XEN_SYSCTL_getcpuinfointerface with timing information provided by introduced time accounting infrastructure.Signed-off-by Andrii Anisov <[email protected]>---
xen/common/schedule.c | 33 ++++++++++++++++++++++++++++----- xen/common/sysctl.c | 4 ++++xen/include/public/sysctl.h| 4 ++++ xen/include/xen/sched.h | 4 ++++4 files changed, 40 insertions(+), 5 deletions(-)
Quoted 15 lines
xen/common/schedule.c void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) · line 211
Quoted 13 lines
xen/common/schedule.c +2
-4@@ -208,13 +208,36 @@ void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) uint64_t get_cpu_idle_time(unsigned int cpu) { - struct vcpu_runstate_info state = { 0 }; - struct vcpu *v = idle_vcpu[cpu]; + struct tacc *tacc = &per_cpu(tacc, cpu); - if ( cpu_online(cpu) && v ) - vcpu_runstate_get(v, &state); + return tacc->state_time[TACC_IDLE];So what's the difference between the current idle time and the new version?
Currently, idle time is the idle vcpu run time, what includes tasklets, scheduling, irq processing etc. IMO it may confuse cpufreq and power management.
Quoted 23 lines
Quoted 23 lines
xen/common/schedule.c +22
-0+} + +uint64_t get_cpu_guest_time (unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_GUEST]; +} + +uint64_t get_cpu_hyp_time (unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_HYP]; +} + +uint64_t get_cpu_irq_time (unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_IRQ]; +}
Quoted 8 lines
xen/common/schedule.c void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) · line 241
Quoted 6 lines
xen/common/schedule.c +4
-1+uint64_t get_cpu_gsync_time (unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); - return state.time[RUNSTATE_running]; + return tacc->state_time[TACC_GSYNC]; }You may want to introduce an helper retrieving the time for a given state rather than duplicating it.
Yep.
Quoted 16 lines
Quoted 7 lines
xen/common/schedule.c +0
-0/*xen/common/sysctl.c +0
-0xen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 158
Quoted 7 lines
xen/common/sysctl.c +4
-0@@ -152,6 +152,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) for ( i = 0; i < nr_cpus; i++ ) { cpuinfo.idletime = get_cpu_idle_time(i); + cpuinfo.guesttime = get_cpu_guest_time(i); + cpuinfo.hyptime = get_cpu_hyp_time(i); + cpuinfo.gsynctime = get_cpu_gsync_time(i); + cpuinfo.irqtime = get_cpu_irq_time(i);It feels to me we want a function that fills up the structure.
Maybe.
Quoted 38 lines
xen/include/public/sysctl.h
Quoted 7 lines
xen/common/sysctl.c +0
-0if ( copy_to_guest_offset(op->u.getcpuinfo.info, i, &cpuinfo, 1) ) goto out;xen/include/public/sysctl.h +0
-0As a side note, SYSCTL version will need to be bumped if this wasn't done before during the current release.
Quoted 16 lines
xen/include/public/sysctl.h +4
-0@@ -168,6 +168,10 @@ struct xen_sysctl_debug_keys { /* XEN_SYSCTL_getcpuinfo */ struct xen_sysctl_cpuinfo { uint64_aligned_t idletime; + uint64_aligned_t hyptime; + uint64_aligned_t guesttime; + uint64_aligned_t irqtime; + uint64_aligned_t gsynctime; }; typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);xen/include/xen/sched.h +0
-0xen/include/xen/sched.h void restore_vcpu_affinity(struct domain *d); · line 884
Quoted 9 lines
xen/include/xen/sched.h +4
-0@@ -876,6 +876,10 @@ void restore_vcpu_affinity(struct domain *d); void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate); uint64_t get_cpu_idle_time(unsigned int cpu); +uint64_t get_cpu_hyp_time (unsigned int cpu); +uint64_t get_cpu_guest_time (unsigned int cpu); +uint64_t get_cpu_gsync_time (unsigned int cpu); +uint64_t get_cpu_irq_time (unsigned int cpu); /** Used by idle loop to decide whether there is work to do: Cheers,
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 3/9 xentop: show CPU load information
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
Let xentop request and show information about CPU load provided by new time accounting infrastructure.
--- tools/xenstat/libxenstat/src/xenstat.c | 50 +++++++++++++++++++++++++++++ tools/xenstat/libxenstat/src/xenstat.h | 15 +++++++++ tools/xenstat/libxenstat/src/xenstat_priv.h | 5 +++ tools/xenstat/xentop/xentop.c | 36 +++++++++++++++++++++ 4 files changed, 106 insertions(+)
tools/xenstat/libxenstat/src/xenstat.c +50 -0
@@ -134,6 +134,9 @@ void xenstat_uninit(xenstat_handle * handle)xenstat_node *xenstat_get_node (xenstat_handle * handle,unsigned int flags) {#define DOMAIN_CHUNK_SIZE 256 +xc_cpuinfo_t *cpuinfo; +int max_cpus, nr_cpus; +xenstat_node *node;xc_physinfo_t physinfo = {0 };xc_domaininfo_t domaininfo[DOMAIN_CHUNK_SIZE ];
@@ -163,6 +166,28 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags) * handle->page_size; node->freeable_mb =0 ; + + max_cpus = node->num_cpus; + + cpuinfo =calloc (max_cpus,sizeof (xc_cpuinfo_t)); +if (!cpuinfo) +return NULL ; + +if (xc_getcpuinfo (handle->xc_handle, max_cpus, cpuinfo, &nr_cpus) <0 ) { +free (cpuinfo); +return NULL ; + } + +for ( i =0 ; i < nr_cpus; i++) { + node->idle_time += cpuinfo[i].idletime; + node->hyp_time += cpuinfo[i].hyptime; + node->guest_time += cpuinfo[i].guesttime; + node->gsync_time += cpuinfo[i].gsynctime; + node->irq_time += cpuinfo[i].irqtime; + } + +free (cpuinfo); +/* malloc(0) is not portable, so allocate a single domain. This will * be resized below. */ node->domains =malloc (sizeof (xenstat_domain));
@@ -332,6 +357,31 @@ unsigned long long xenstat_node_cpu_hz(xenstat_node * node)return node->cpu_hz; } +unsigned long long xenstat_node_idle_time (xenstat_node * node) +{ +return node->idle_time; +} + +unsigned long long xenstat_node_guest_time (xenstat_node * node) +{ +return node->guest_time; +} + +unsigned long long xenstat_node_hyp_time (xenstat_node * node) +{ +return node->hyp_time; +} + +unsigned long long xenstat_node_gsync_time (xenstat_node * node) +{ +return node->gsync_time; +} + +unsigned long long xenstat_node_irq_time (xenstat_node * node) +{ +return node->irq_time; +} +/* Get the domain ID for this domain */ unsigned xenstat_domain_id (xenstat_domain * domain) {
tools/xenstat/libxenstat/src/xenstat.h +15 -0
@@ -80,6 +80,21 @@ unsigned int xenstat_node_num_cpus(xenstat_node * node);/* Get information about the CPU speed */ unsigned long long xenstat_node_cpu_hz (xenstat_node * node); +/* Get information about the CPU idle time */ +unsigned long long xenstat_node_idle_time (xenstat_node * node); + +/* Get information about the CPU guest execution time */ +unsigned long long xenstat_node_guest_time (xenstat_node * node); + +/* Get information about the CPU hypervisor execution time */ +unsigned long long xenstat_node_hyp_time (xenstat_node * node); + +/* Get information about the CPU guest syncronous trap execution time */ +unsigned long long xenstat_node_gsync_time (xenstat_node * node); + +/* Get information about the CPU IRQ serving time */ +unsigned long long xenstat_node_irq_time (xenstat_node * node); +/* * Domain functions - extract information from a xenstat_domain */
tools/xenstat/libxenstat/src/xenstat_priv.h +5 -0
@@ -45,6 +45,11 @@ struct xenstat_node {unsigned int flags;unsigned long long cpu_hz;unsigned int num_cpus; +unsigned long long hyp_time; +unsigned long long guest_time; +unsigned long long idle_time; +unsigned long long gsync_time; +unsigned long long irq_time;unsigned long long tot_mem;unsigned long long free_mem;unsigned int num_domains;
tools/xenstat/xentop/xentop.c +36 -0
@@ -930,6 +930,40 @@ void adjust_field_widths(xenstat_domain *domain) fields[FIELD_VBD_WSECT -1 ].default_width = length; } +void do_utilization (void ) +{ +double us_elapsed =0.0 , + us_hyp =0.0 , + us_guest =0.0 , + us_idle =0.0 , + us_gsync =0.0 , + us_irq =0.0 ; + +/* Can't calculate CPU percentage without a current and a previous sample.*/ +if (prev_node !=NULL && cur_node !=NULL ) { + +/* Calculate the time elapsed in microseconds */ + us_elapsed = ((curtime.tv_sec-oldtime.tv_sec)*1000000.0 + +(curtime.tv_usec - oldtime.tv_usec)); + +/* In the following, nanoseconds must be multiplied by 1000.0 to +* convert to microseconds, then divided by 100.0 to get a percentage, +* resulting in a multiplication by 10.0 */ + us_idle = ((xenstat_node_idle_time (cur_node) - +xenstat_node_idle_time (prev_node))/10.0 )/us_elapsed; + us_guest = ((xenstat_node_guest_time (cur_node) - +xenstat_node_guest_time (prev_node))/10.0 )/us_elapsed; + us_hyp = ((xenstat_node_hyp_time (cur_node) - +xenstat_node_hyp_time (prev_node))/10.0 )/us_elapsed; + us_gsync = ((xenstat_node_gsync_time (cur_node) - +xenstat_node_gsync_time (prev_node))/10.0 )/us_elapsed; + us_irq = ((xenstat_node_irq_time (cur_node) - +xenstat_node_irq_time (prev_node))/10.0 )/us_elapsed; + } + +"%%CPU(s): %6.1f gu, %6.1f gs, %6.1f ir, %6.1f hy, %6.1f id \n" , + us_guest, us_gsync, us_irq, us_hyp, us_idle); +}/* Section printing functions */ /* Prints the top summary, above the domain table */
@@ -972,6 +1006,8 @@ void do_summary(void) used =xenstat_node_tot_mem (cur_node); freeable_mb =0 ; +do_utilization (); +/* Dump node memory and cpu information */ if ( freeable_mb <=0 ) print("Mem: %lluk total, %lluk used, %lluk free ",
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 4/9 arm64: utilize time accounting
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
Call time accounting hooks from appropriate transition points of the ARM64 code.
--- xen/arch/arm/arm64/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- xen/arch/arm/domain.c | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-)
xen/arch/arm/arm64/entry.S +36 -3
@@ -143,12 +143,21 @@ .endm - .macro exit, hyp, compat + .macro exit, hyp, compat, tacc=1 .if \hyp == 0 /* Guest mode */ + .if \tacc == 1 + + mov x0, #1 + bl tacc_hyp + + .endif + bl leave_hypervisor_tail /* Disables interrupts on return */ + mov x0, #1 + bl tacc_guest exit_guest \compat .endif
@@ -205,9 +214,15 @@ hyp_sync: hyp_irq: entry hyp=1 + mov x0,#5 + bl tacc_irq_enter msr daifclr, #4 mov x0, sp bl do_trap_irq + + mov x0,#5 + bl tacc_irq_exit + exit hyp=1 guest_sync:
@@ -291,6 +306,9 @@ guest_sync_slowpath: * to save them. */ entry hyp=0, compat=0, save_x0_x1=0 + + mov x0,#1 + bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be
@@ -307,6 +325,10 @@ guest_sync_slowpath: guest_irq: entry hyp=0, compat=0 + + mov x0,#6 + bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be
@@ -319,6 +341,8 @@ guest_irq: mov x0, sp bl do_trap_irq 1: + mov x0,#6 + bl tacc_irq_exit exit hyp=0, compat=0 guest_fiq_invalid:
@@ -334,6 +358,9 @@ guest_error: guest_sync_compat: entry hyp=0, compat=1 + + mov x0,#2 + bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be
@@ -350,6 +377,10 @@ guest_sync_compat: guest_irq_compat: entry hyp=0, compat=1 + + mov x0,#7 + bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be
@@ -362,6 +393,8 @@ guest_irq_compat: mov x0, sp bl do_trap_irq 1: + mov x0,#7 + bl tacc_irq_exit exit hyp=0, compat=1 guest_fiq_invalid_compat:
@@ -376,9 +409,9 @@ guest_error_compat: exit hyp=0, compat=1 ENTRY(return_to_new_vcpu32) - exit hyp=0, compat=1 + exit hyp=0, compat=1, tacc=0 ENTRY(return_to_new_vcpu64) - exit hyp=0, compat=0 + exit hyp=0, compat=0, tacc=0 return_from_trap: msr daifset, #2 /* Mask interrupts */
xen/arch/arm/domain.c +2 -0
@@ -51,11 +51,13 @@ static void do_idle(void)process_pending_softirqs ();local_irq_disable (); +tacc_idle (1 );if (cpu_is_haltable (cpu) ) {dsb (sy);wfi (); } +tacc_hyp (2 );local_irq_enable ();sched_tick_resume ();
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 4/9] arm64: utilize time accounting
Hi Andrii,
Quoted 4 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Call time accounting hooks from appropriate transition points of the ARM64 code.
I'd prefer more elaborate commit message. For example - what are appropriate transition points? I mean - how you chose ones?
Quoted 11 lines
Signed-off-by Andrii Anisov <[email protected]>--- xen/arch/arm/arm64/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- xen/arch/arm/domain.c | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-)xen/arch/arm/arm64/entry.S +0
-0
xen/arch/arm/arm64/entry.S line 150
Quoted 9 lines
xen/arch/arm/arm64/entry.S +2
-1@@ -143,12 +143,21 @@ .endm - .macro exit, hyp, compat + .macro exit, hyp, compat, tacc=1 .if \hyp == 0 /* Guest mode */ + .if \tacc == 1
There is a hard tab, instead of 8 spaces.
Also, while it is easy to guess what 'hyp' and 'compat' mean, it is hard to tell what 'tacc' stands for. I think, you need either better name for this or a comment, which explains all parameters.
xen/arch/arm/arm64/entry.S line 155
Quoted 5 lines
xen/arch/arm/arm64/entry.S +5
-0+ + mov x0, #1 + bl tacc_hyp + + .endif
The same about hard tabs. Probably, there are more of them in this patch.
xen/arch/arm/arm64/entry.S hyp_sync: · line 217
Quoted 13 lines
xen/arch/arm/arm64/entry.S +4
-0+ bl leave_hypervisor_tail /* Disables interrupts on return */ + mov x0, #1 + bl tacc_guest exit_guest \compat .endif@@ -205,9 +214,15 @@ hyp_sync: hyp_irq: entry hyp=1 + mov x0,#5
Space is missing before #5
xen/arch/arm/arm64/entry.S hyp_sync: · line 223
Quoted 6 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_irq_enter msr daifclr, #4 mov x0, sp bl do_trap_irq + + mov x0,#5
Space is missing before #5
xen/arch/arm/arm64/entry.S guest_sync_slowpath: · line 309
Quoted 10 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_irq_exit + exit hyp=1 guest_sync:@@ -291,6 +306,9 @@ guest_sync_slowpath: * to save them. */ entry hyp=0, compat=0, save_x0_x1=0 +
There are trailing whitespaces. I sure that 'git diff' highlights such mistakes...
xen/arch/arm/arm64/entry.S guest_sync_slowpath: · line 310
Quoted 1 line
xen/arch/arm/arm64/entry.S +1
-0+ mov x0,#1
Space is missing before #1
xen/arch/arm/arm64/entry.S guest_sync_slowpath: · line 329
Quoted 10 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -307,6 +325,10 @@ guest_sync_slowpath: guest_irq: entry hyp=0, compat=0 + + mov x0,#6
Space is missing before #6
xen/arch/arm/arm64/entry.S guest_irq: · line 344
Quoted 10 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -319,6 +341,8 @@ guest_irq: mov x0, sp bl do_trap_irq 1: + mov x0,#6
Space is missing before #6, also looks like there is a hard tab character.
xen/arch/arm/arm64/entry.S guest_error: · line 362
Quoted 10 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_irq_exit exit hyp=0, compat=0 guest_fiq_invalid:@@ -334,6 +358,9 @@ guest_error: guest_sync_compat: entry hyp=0, compat=1 + + mov x0,#2
Space is missing before #2.
xen/arch/arm/arm64/entry.S guest_sync_compat: · line 381
Quoted 10 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -350,6 +377,10 @@ guest_sync_compat: guest_irq_compat: entry hyp=0, compat=1 + + mov x0,#7
Space is missing before #7.
xen/arch/arm/arm64/entry.S guest_irq_compat: · line 396
Quoted 10 lines
xen/arch/arm/arm64/entry.S +3
-0+ bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -362,6 +393,8 @@ guest_irq_compat: mov x0, sp bl do_trap_irq 1: + mov x0,#7
Space is missing before #7...
Quoted 23 lines
xen/arch/arm/arm64/entry.S +3
-2+ bl tacc_irq_exit exit hyp=0, compat=1 guest_fiq_invalid_compat:@@ -376,9 +409,9 @@ guest_error_compat: exit hyp=0, compat=1 ENTRY(return_to_new_vcpu32) - exit hyp=0, compat=1 + exit hyp=0, compat=1, tacc=0 ENTRY(return_to_new_vcpu64) - exit hyp=0, compat=0 + exit hyp=0, compat=0, tacc=0 return_from_trap: msr daifset, #2 /* Mask interrupts */xen/arch/arm/domain.c +0
-0
xen/arch/arm/domain.c static void do_idle(void) · line 54
Quoted 4 lines
xen/arch/arm/domain.c +1
-0@@ -51,11 +51,13 @@ static void do_idle(void)process_pending_softirqs ();local_irq_disable (); +tacc_idle (1 );
1 and 2 (below) look like some magical values to me. I believe, you need to define some enumeration.
xen/arch/arm/domain.c static void do_idle(void) · line 63
Quoted 9 lines
xen/arch/arm/domain.c +1
-0if (cpu_is_haltable (cpu) ) {dsb (sy);wfi (); } +tacc_hyp (2 );local_irq_enable ();sched_tick_resume ();
--
Volodymyr Babchuk at EPAM
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 4/9] arm64: utilize time accounting
Hello Volodymyr,
Quoted 3 lines · Volodymyr Babchuk
Hi Andrii,
As we agreed, I'll wipe out debugging remains as well as cleanup coding style nits and resend the series.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 4/9] arm64: utilize time accounting
Quoted 9 lines · On Thu, 12 Sep 2019, 13:10 Andrii Anisov, <[email protected]> wrote:
Hello Volodymyr,
Quoted 3 lines · Volodymyr Babchuk
Hi Andrii,
As we agreed, I'll wipe out debugging remains as well as cleanup coding style nits and resend the series.
This an RFC and I am sure there current state is enough to spark a discussion. There are no need to waste time resending it and use filling up inboxes.
Please wait for more time.
Cheers,
Quoted 8 lines
--
Sincerely,
Andrii Anisov._______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 4/9] arm64: utilize time accounting
Quoted 3 lines · Julien Grall
This an RFC and I am sure there current state is enough to spark a discussion. There are no need to waste time resending it and use filling up inboxes.
Please wait for more time.
Gotcha!
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 4/9] arm64: utilize time accounting
In reply to Andrii Anisov(+ George and Dario)
Hi,
Quoted 16 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Call time accounting hooks from appropriate transition points of the ARM64 code.
Signed-off-by Andrii Anisov <[email protected]>--- xen/arch/arm/arm64/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- xen/arch/arm/domain.c | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-)xen/arch/arm/arm64/entry.S +0
-0
xen/arch/arm/arm64/entry.S line 150
Quoted 9 lines
xen/arch/arm/arm64/entry.S +2
-1@@ -143,12 +143,21 @@ .endm - .macro exit, hyp, compat + .macro exit, hyp, compat, tacc=1 .if \hyp == 0 /* Guest mode */ + .if \tacc == 1
This is here because you may already be in the HYP state, right?
I noticed in the previous patch you mention that you only handle "re-entry" for the IRQ state.
As you don't have "exit" for states other than IRQ, then I would not consider this is as re-entry. It is more like you transition from one state to another (it happen this is the same state).
The problem of re-entry would be if you take an exception that is going to switch the state. But the concern would be exactly the same if you take an exception that switch the state (such as synchronous hypervisor exception).
This raises the question, how do you account SError interrupt/synchronous exception?
xen/arch/arm/arm64/entry.S line 157
Quoted 7 lines
xen/arch/arm/arm64/entry.S +6
-0+ + mov x0, #1 + bl tacc_hyp + + .endif + bl leave_hypervisor_tail /* Disables interrupts on return */
As mentioned in the previous patch, leave_hypervisor_tail() may do some IO emulation that requires to be preemptible. So I don't think this is correct to get that time accounted to the hypervisor.
Quoted 99 lines
xen/arch/arm/arm64/entry.S +28
-2+ mov x0, #1 + bl tacc_guest exit_guest \compat .endif@@ -205,9 +214,15 @@ hyp_sync: hyp_irq: entry hyp=1 + mov x0,#5 + bl tacc_irq_enter msr daifclr, #4 mov x0, sp bl do_trap_irq + + mov x0,#5 + bl tacc_irq_exit + exit hyp=1 guest_sync:@@ -291,6 +306,9 @@ guest_sync_slowpath: * to save them. */ entry hyp=0, compat=0, save_x0_x1=0 + + mov x0,#1 + bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -307,6 +325,10 @@ guest_sync_slowpath: guest_irq: entry hyp=0, compat=0 + + mov x0,#6 + bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -319,6 +341,8 @@ guest_irq: mov x0, sp bl do_trap_irq 1: + mov x0,#6 + bl tacc_irq_exit exit hyp=0, compat=0 guest_fiq_invalid:@@ -334,6 +358,9 @@ guest_error: guest_sync_compat: entry hyp=0, compat=1 + + mov x0,#2 + bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -350,6 +377,10 @@ guest_sync_compat: guest_irq_compat: entry hyp=0, compat=1 + + mov x0,#7 + bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT * is not set. If a vSError took place, the initial exception will be@@ -362,6 +393,8 @@ guest_irq_compat: mov x0, sp bl do_trap_irq 1: + mov x0,#7 + bl tacc_irq_exit exit hyp=0, compat=1 guest_fiq_invalid_compat:@@ -376,9 +409,9 @@ guest_error_compat: exit hyp=0, compat=1 ENTRY(return_to_new_vcpu32) - exit hyp=0, compat=1 + exit hyp=0, compat=1, tacc=0 ENTRY(return_to_new_vcpu64) - exit hyp=0, compat=0 + exit hyp=0, compat=0, tacc=0 return_from_trap: msr daifset, #2 /* Mask interrupts */xen/arch/arm/domain.c +0
-0
xen/arch/arm/domain.c static void do_idle(void) · line 54
Quoted 4 lines
xen/arch/arm/domain.c +1
-0@@ -51,11 +51,13 @@ static void do_idle(void)process_pending_softirqs ();local_irq_disable (); +tacc_idle (1 );
Any reason to call this before the if and not inside?
xen/arch/arm/domain.c static void do_idle(void) · line 63
Quoted 10 lines
xen/arch/arm/domain.c +1
-0if (cpu_is_haltable (cpu) ) {dsb (sy);wfi (); } +tacc_hyp (2 );local_irq_enable ();sched_tick_resume ();
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC 4/9] arm64: utilize time accounting
Quoted 29 lines · Julien Grall
(+ George and Dario)
Hi,
Quoted 16 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
Call time accounting hooks from appropriate transition points of the ARM64 code.
Signed-off-by Andrii Anisov <[email protected]>---
xen/arch/arm/arm64/entry.S| 39 ++++++++++++++++++++++++++++++++++++--- xen/arch/arm/domain.c | 2 ++2 files changed, 38 insertions(+), 3 deletions(-)xen/arch/arm/arm64/entry.S +0
-0@@ -143,12 +143,21 @@Quoted 5 lines
.endm
- .macro exit, hyp, compat
+ .macro exit, hyp, compat, tacc=1
.if \hyp == 0 /* Guest mode */
+ .if \tacc == 1This is here because you may already be in the HYP state, right?
Quoted 6 lines
I noticed in the previous patch you mention that you only handle "re-entry" for the IRQ state.
As you don't have "exit" for states other than IRQ, then I would not consider this is as re-entry. It is more like you transition from one state to another (it happen this is the same state).
The problem of re-entry would be if you take an exception that is going to switch the state. But the concern would be exactly the same if you take an exception that switch the state (such as synchronous hypervisor exception).
Quoted 1 line
This raises the question, how do you account SError interrupt/synchronous exception?
Well, I guess I have to think more about it. Maybe I do not understand completely that problem now.
Quoted 10 lines
Quoted 8 lines
xen/arch/arm/arm64/entry.S +6
-0+ + mov x0, #1 + bl tacc_hyp + + .endif +bl
leave_hypervisor_tail/* Disables interrupts on return */As mentioned in the previous patch,
leave_hypervisor_tail()may do some IO emulation that requires to be preemptible. So I don't think this is correct to get that time accounted to the hypervisor.
Could you please point me to the line of the code? Are you saying about GIC?
Quoted 86 lines
Quoted 86 lines
+ mov x0, #1
+ bltacc_guest
exit_guest\compat
.endifxen/arch/arm/arm64/entry.S +0
-0@@ -205,9 +214,15 @@ hyp_sync:
hyp_irq:
entry hyp=1
+ mov x0,#5
+ bltacc_irq_enter
msr daifclr, #4
mov x0, sp
bldo_trap_irqxen/arch/arm/arm64/entry.S +4
-0+ + mov x0,#5 + bl tacc_irq_exit +exit hyp=1
guest_sync:xen/arch/arm/arm64/entry.S +0
-0@@ -291,6 +306,9 @@ guest_sync_slowpath: * to save them. */entry hyp=0, compat=0, save_x0_x1=0
+
+ mov x0,#1
+ bltacc_gsync
/*
* The vSError will be checked whileSKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT
* is not set. If a vSError took place, the initial exception will bexen/arch/arm/arm64/entry.S +0
-0@@ -307,6 +325,10 @@ guest_sync_slowpath:
guest_irq:
entry hyp=0, compat=0xen/arch/arm/arm64/entry.S +4
-0+ + mov x0,#6 + bl tacc_irq_enter +/*
* The vSError will be checked whileSKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT
* is not set. If a vSError took place, the initial exception will bexen/arch/arm/arm64/entry.S +0
-0@@ -319,6 +341,8 @@ guest_irq:mov x0, sp
bldo_trap_irq
1:
+ mov x0,#6
+ bltacc_irq_exit
exit hyp=0, compat=0
guest_fiq_invalid:xen/arch/arm/arm64/entry.S +0
-0@@ -334,6 +358,9 @@ guest_error:
guest_sync_compat:
entry hyp=0, compat=1
+
+ mov x0,#2
+ bltacc_gsync
/*
* The vSError will be checked whileSKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT
* is not set. If a vSError took place, the initial exception will bexen/arch/arm/arm64/entry.S +0
-0@@ -350,6 +377,10 @@ guest_sync_compat:
guest_irq_compat:
entry hyp=0, compat=1xen/arch/arm/arm64/entry.S +4
-0+ + mov x0,#7 + bl tacc_irq_enter +/*
* The vSError will be checked whileSKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT
* is not set. If a vSError took place, the initial exception will bexen/arch/arm/arm64/entry.S +0
-0@@ -362,6 +393,8 @@ guest_irq_compat:mov x0, sp
bldo_trap_irq
1:
+ mov x0,#7
+ bltacc_irq_exit
exit hyp=0, compat=1
guest_fiq_invalid_compat:xen/arch/arm/arm64/entry.S +0
-0@@ -376,9 +409,9 @@ guest_error_compat:exit hyp=0, compat=1
ENTRY(return_to_new_vcpu32)
- exit hyp=0, compat=1
+ exit hyp=0, compat=1, tacc=0ENTRY(return_to_new_vcpu64)
- exit hyp=0, compat=0
+ exit hyp=0, compat=0, tacc=0return_from_trap:
msr daifset, #2 /* Mask interrupts */xen/arch/arm/domain.c +0
-0
Quoted 8 lines
xen/arch/arm/domain.c static void do_idle(void) · line 53
Quoted 6 lines
xen/arch/arm/domain.c +1
-0@@ -51,11 +51,13 @@ static void do_idle(void) process_pending_softirqs(); local_irq_disable(); + tacc_idle(1);Any reason to call this before the if and not inside?
Maybe having at least a bit of idle for non-haltable cpu. But from the second thought it would not work.
Quoted 13 lines
xen/arch/arm/domain.c static void do_idle(void)
Quoted 10 lines
xen/arch/arm/domain.c +1
-0if ( cpu_is_haltable(cpu) ) { dsb(sy); wfi(); } + tacc_hyp(2); local_irq_enable(); sched_tick_resume();Cheers,
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 5/9 tacc: Introduce a lockless interface for guest time
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
The lockless interface to acquire guest time by scheduling code is introduced. It can be used by schedulers what do not require guest time from a different pcpu to take scheduling decission.
--- xen/common/schedule.c | 10 ++++++++++ xen/include/xen/sched.h | 8 ++++++++ 2 files changed, 18 insertions(+)
xen/common/schedule.c +10 -0
@@ -1643,6 +1643,16 @@ void tacc_irq_exit(int place) tacc->irq_cnt--; } +s_time_t tacc_get_guest_time (struct tacc *tacc) +{ +s_time_t guest_time; + + guest_time = tacc->state_time[TACC_GUEST ]; + guest_time += tacc->state_time[TACC_GSYNC ]; + +return guest_time; +} +void context_saved (struct vcpu *prev) {/* Clear running flag /after/ writing context to memory. */
xen/include/xen/sched.h +8 -0
@@ -266,6 +266,8 @@ struct vcpustruct evtchn_fifo_vcpu *evtchn_fifo; +s_time_t pcpu_guest_time; +/* vPCI per-vCPU area, used to store data for long running operations. */ struct vpci_vcpu vpci;
@@ -1033,6 +1035,12 @@ DECLARE_PER_CPU(struct tacc, tacc);void tacc_hyp (int place);void tacc_idle (int place); +s_time_t tacc_get_guest_time (struct tacc *tacc); +inline s_time_t tacc_get_guest_time_delta (void ) +{ +return tacc_get_guest_time (&this_cpu (tacc)) - current->pcpu_guest_time; +} +#endif /* __SCHED_H__ */ /*
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 6/9 sched:rtds: get guest time from time accounting code
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
While the RTDS scheduler code does not use guest time from the other pcpu, we are free to go with lockless time accounting.
--- xen/common/sched_rt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/common/sched_rt.c +2 -2
@@ -945,8 +945,9 @@ burn_budget(const struct scheduler *ops, struct rt_vcpu *svc, s_time_t now)if (is_idle_vcpu (svc->vcpu) )return ; +ASSERT (svc->vcpu == current);/* burn at nanoseconds level */ - delta = now - svc->last_start; + delta =tacc_get_guest_time_delta ();/* * delta < 0 only happens in nested virtualization; * TODO: how should we handle delta < 0 in a better way?
@@ -960,7 +961,6 @@ burn_budget(const struct scheduler *ops, struct rt_vcpu *svc, s_time_t now) } svc->cur_budget -= delta; - svc->last_start = now;if ( svc->cur_budget <=0 ) {
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 7/9 tacc: Introduce a locked interface for guest time
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
The locked interface to acquire guest time by scheduling code is introduced. It can be used by schedulers what do require guest time from a different pcpu to take scheduling decission.
--- xen/common/Kconfig | 3 +++ xen/common/schedule.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 11 +++++++++++ 3 files changed, 58 insertions(+)
xen/common/Kconfig +3 -0
@@ -221,6 +221,9 @@ config ARGO menu "Schedulers" visible if EXPERT = "y" +config TACC_NEEDS_LOCK + bool + config SCHED_CREDIT bool "Credit scheduler support" default y
xen/common/schedule.c +44 -0
83 lines not on this page · raw message
xen/include/xen/sched.h +11 -0
@@ -1028,6 +1028,9 @@ struct taccs_time_t irq_enter_time;s_time_t irq_time;int irq_cnt; +#ifdef CONFIG_TACC_NEEDS_LOCK +spinlock_t tacc_lock; +#endif }; DECLARE_PER_CPU(struct tacc, tacc);
@@ -1041,6 +1044,14 @@ inline s_time_t tacc_get_guest_time_delta(void) return tacc_get_guest_time(&this_cpu(tacc)) - current->pcpu_guest_time; } +#ifdef CONFIG_TACC_NEEDS_LOCK +s_time_t tacc_get_guest_time_cpu (int cpu); +inline s_time_t tacc_get_guest_time_delta_vcpu (struct vcpu * vcpu) +{ +return tacc_get_guest_time_cpu (vcpu->processor) - vcpu->pcpu_guest_time; +} +#endif +#endif /* __SCHED_H__ */ /*
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 8/9 sched:credit: get guest time from time accounting code
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
While the Credit scheduler code uses guest time from the other pcpu, we have to use locked time accounting.
--- xen/common/Kconfig | 1 + xen/common/sched_credit.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-)
xen/common/Kconfig +1 -0
@@ -227,6 +227,7 @@ config TACC_NEEDS_LOCK config SCHED_CREDIT bool "Credit scheduler support" default y + select TACC_NEEDS_LOCK ---help--- The traditional credit scheduler is a general purpose scheduler.
xen/common/sched_credit.c +5 -7
@@ -324,16 +324,15 @@ runq_remove(struct csched_vcpu *svc)__runq_remove (svc); } -static void burn_credits (struct csched_vcpu *svc,s_time_t now) +static void burn_credits (struct csched_vcpu *svc,s_time_t delta) { -s_time_t delta;uint64_t val;unsigned int credits;/* Assert svc is current */ ASSERT ( svc ==CSCHED_VCPU (curr_on_cpu (svc->vcpu->processor)) ); -if ( (delta = now - svc->start_time) <=0 ) +if ( delta <=0 )return ; val = delta *CSCHED_CREDITS_PER_MSEC + svc->residual;
@@ -341,7 +340,6 @@ static void burn_credits(struct csched_vcpu *svc, s_time_t now) credits = val;ASSERT (credits == val);/* make sure we haven't truncated val */ atomic_sub (credits, &svc->credit); - svc->start_time += (credits *MILLISECS (1 )) /CSCHED_CREDITS_PER_MSEC ; }static bool_t __read_mostly opt_tickle_one_idle =1 ;
@@ -956,7 +954,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned int cpu)/* * Update credits */ -burn_credits (svc,NOW ()); +burn_credits (svc,tacc_get_guest_time_delta_vcpu (svc->vcpu));/* * Put this VCPU and domain back on the active list if it was
@@ -1856,14 +1854,14 @@ csched_schedule( (unsigned char *)&d); } - runtime = now - current->runstate.state_entry_time; + runtime =tacc_get_guest_time_delta ();if ( runtime <0 )/* Does this ever happen? */ runtime =0 ;if ( !is_idle_vcpu (scurr->vcpu) ) {/* Update credits of a non-idle VCPU. */ -burn_credits (scurr, now); +burn_credits (scurr, runtime); scurr->start_time -= now; scurr->last_sched_time = now; }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC 9/9 sched:credit2: get guest time from time accounting code
In reply to Andrii AnisovFrom: Andrii Anisov <[email protected]>
While the Credit2 scheduler code uses guest time from the other pcpu, we have to use locked time accounting.
--- xen/common/Kconfig | 1 + xen/common/sched_credit2.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-)
xen/common/Kconfig +1 -0
@@ -234,6 +234,7 @@ config SCHED_CREDIT config SCHED_CREDIT2 bool "Credit2 scheduler support" default y + select TACC_NEEDS_LOCK ---help--- The credit2 scheduler is a general purpose scheduler that is optimized for lower latency and higher VM density.
xen/common/sched_credit2.c +9 -8
@@ -1342,7 +1342,7 @@ static inline bool is_preemptable(const struct csched2_vcpu *svc,return true;ASSERT (svc->vcpu->is_running); -return now - svc->vcpu->runstate.state_entry_time > +return tacc_get_guest_time_delta_vcpu (svc->vcpu)> ratelimit -CSCHED2_RATELIMIT_TICKLE_TOLERANCE ; }
@@ -1722,7 +1722,7 @@ void burn_credits(struct csched2_runqueue_data *rqd,return ; } - delta = now - svc->start_time; + delta =tacc_get_guest_time_delta_vcpu (svc->vcpu);if (unlikely (delta <=0 ) ) {
@@ -1739,7 +1739,7 @@ void burn_credits(struct csched2_runqueue_data *rqd,if (has_cap (svc) ) svc->budget -= delta; - svc->start_time = now; + svc->vcpu->pcpu_guest_time += delta; out:if (unlikely (tb_init_done) )
@@ -3189,8 +3189,8 @@ csched2_runtime(const struct scheduler *ops, int cpu, {s_time_t ratelimit_min =MICROSECS (prv->ratelimit_us);if ( snext->vcpu->is_running ) - ratelimit_min = snext->vcpu->runstate.state_entry_time + -MICROSECS (prv->ratelimit_us) - now; + ratelimit_min =tacc_get_guest_time_delta_vcpu (snext->vcpu) + +MICROSECS (prv->ratelimit_us);if ( ratelimit_min > min_time ) min_time = ratelimit_min; }
@@ -3265,6 +3265,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,struct csched2_vcpu *snext =NULL ;struct csched2_private *prv =csched2_priv (per_cpu (scheduler, cpu));bool yield = false, soft_aff_preempt = false; +s_time_t guest_time; *skipped =0 ;
@@ -3286,8 +3287,8 @@ runq_candidate(struct csched2_runqueue_data *rqd,* no point forcing it to do so until rate limiting expires. */ if ( !yield && prv->ratelimit_us &&vcpu_runnable (scurr->vcpu) && - (now - scurr->vcpu->runstate.state_entry_time) < -MICROSECS (prv->ratelimit_us) ) + ((guest_time =tacc_get_guest_time_delta_vcpu (scurr->vcpu)) < +MICROSECS (prv->ratelimit_us))) {if (unlikely (tb_init_done) ) {
@@ -3297,7 +3298,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, } d; d.dom = scurr->vcpu->domain->domain_id; d.vcpu = scurr->vcpu->vcpu_id; - d.runtime = now - scurr->vcpu->runstate.state_entry_time; + d.runtime = guest_time;__trace_var (TRC_CSCHED2_RATELIMIT ,1 ,sizeof (d), (unsigned char *)&d);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel