Re: [PATCH 00/10] vtime: Delay cputime accounting to tick / context switch
On Tue, Jan 10, 2017 at 12:45:43PM +0100, Thomas Gleixner wrote: > On Thu, 5 Jan 2017, Frederic Weisbecker wrote: > > > This version is a rebase on top of latest Linus tree which includes > > the fix 8f2b468aadc ("s390/vtime: correct system time accounting"). > > > > Also a small change: I have moved account_system_index_scaled() to s390 > > in patch "s390/cputime: delayed accounting of system time" because it is > > the only user of the function. > > > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git > > vtime/acc-v2 > > Acked-by: Thomas Gleixner Thanks for your reviews! I added the acks on the series.
Re: [PATCH 00/10] vtime: Delay cputime accounting to tick / context switch
On Thu, 5 Jan 2017, Frederic Weisbecker wrote: > This version is a rebase on top of latest Linus tree which includes > the fix 8f2b468aadc ("s390/vtime: correct system time accounting"). > > Also a small change: I have moved account_system_index_scaled() to s390 > in patch "s390/cputime: delayed accounting of system time" because it is > the only user of the function. > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git > vtime/acc-v2 Acked-by: Thomas Gleixner
Re: [PATCH 00/10] vtime: Delay cputime accounting to tick / context switch
On Thu, 5 Jan 2017 18:11:40 +0100 Frederic Weisbecker wrote: > This version is a rebase on top of latest Linus tree which includes > the fix 8f2b468aadc ("s390/vtime: correct system time accounting"). > > Also a small change: I have moved account_system_index_scaled() to s390 > in patch "s390/cputime: delayed accounting of system time" because it is > the only user of the function. > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git > vtime/acc-v2 That looks good, I get sensible numbers for s390. Thanks for doing this! For the s390 parts: Acked-by: Martin Schwidefsky -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.
[PATCH 00/10] vtime: Delay cputime accounting to tick / context switch
This version is a rebase on top of latest Linus tree which includes the fix 8f2b468aadc ("s390/vtime: correct system time accounting"). Also a small change: I have moved account_system_index_scaled() to s390 in patch "s390/cputime: delayed accounting of system time" because it is the only user of the function. git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git vtime/acc-v2 Thanks, Frederic --- Frederic Weisbecker (9): powerpc32: Fix stale scaled stime on context switch ia64: Fix wrong start cputime assignment on task switch cputime: Allow accounting system time using cpustat index cputime: Export account_guest_time powerpc: Prepare accounting structure for cputime flush on tick powerpc: Migrate stolen_time field to accounting structure powerpc/vtime: Accumulate cputime and account only on tick/task switch ia64: Accumulate cputime and account only on tick/task switch vtime: Rename vtime_account_user() to vtime_flush() Martin Schwidefsky (1): s390/cputime: delayed accounting of system time arch/ia64/include/asm/thread_info.h | 6 ++ arch/ia64/kernel/time.c | 66 +++- arch/powerpc/include/asm/accounting.h | 14 +++- arch/powerpc/include/asm/paca.h | 1 - arch/powerpc/kernel/asm-offsets.c | 8 +- arch/powerpc/kernel/time.c| 138 +- arch/powerpc/xmon/xmon.c | 8 +- arch/s390/include/asm/lowcore.h | 65 arch/s390/include/asm/processor.h | 3 + arch/s390/kernel/vtime.c | 138 ++ include/linux/kernel_stat.h | 5 +- include/linux/vtime.h | 7 +- kernel/sched/cputime.c| 16 ++-- 13 files changed, 302 insertions(+), 173 deletions(-)
Re: [PATCH 00/10] vtime: Delay cputime accounting to tick
On Tue, Dec 06, 2016 at 03:20:55PM +1100, Paul Mackerras wrote: > On Tue, Dec 06, 2016 at 03:32:13AM +0100, Frederic Weisbecker wrote: > > This follows up Martin Schwidefsky's patch which propose to delay > > cputime accounting to the tick in order to minimize the calls to > > account_system_time() and alikes as these functions can carry quite some > > overhead: > > > > http://lkml.kernel.org/r/2016112728.13a0a3db@mschwide > > > > The set includes Martin's patch, rebased on top of tip:sched/core and > > latest s390 changes, and extends it to the other implementations of > > CONFIG_VIRT_CPU_ACCOUNTING_NATIVE (powerpc and ia64) along with a few > > core changes to adapt the whole. > > > > Only built-tested though as I don't have access to any of these archs. > > The patches look reasonable at a quick look. I assume that to test > them, we would want to run a guest in an overcommitted system, so as > to get some steal time. Do you have any more specific suggestions as > to what to run as a test? Just run some benchmark and see if the > user/system/irq times look reasonable? Or do you have something more > quantitative? So I guess we want to test both correctness and performance. To check correctness I use two little programs, one that does a userspace loop: int main(int argc, char **argv) { while (1); return 0; } And another that does a kernelspace loop. The latter is not 100% kernel loop but spends most of its time in kernel mode. int main(int argc, char **argv) { void *addr = sbrk(0); while (1) { brk(addr + 4096); brk(addr); } return 0; } Testing idle time just consist in checking the difference between two cat /proc/stat in a given timelapse for an idle CPU. For irqs it gets harder. There you just need to check if the numbers are reasonable. Now in order to measure performance, I think you need a workload that either does a lot of guest/host switch or does a lot of IRQs. Maybe just something that involves networking. Then comparing stime, hardirq and softirq should show some better nummbers. In order to increase the effect, you can set a very low HZ value (100?). Thanks.
Re: [PATCH 00/10] vtime: Delay cputime accounting to tick
On 12/06/2016 03:32 AM, Frederic Weisbecker wrote: > This follows up Martin Schwidefsky's patch which propose to delay > cputime accounting to the tick in order to minimize the calls to > account_system_time() and alikes as these functions can carry quite some > overhead: > > http://lkml.kernel.org/r/2016112728.13a0a3db@mschwide > > The set includes Martin's patch, rebased on top of tip:sched/core and > latest s390 changes, and extends it to the other implementations of > CONFIG_VIRT_CPU_ACCOUNTING_NATIVE (powerpc and ia64) along with a few > core changes to adapt the whole. > > Only built-tested though as I don't have access to any of these archs. > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git > vtime/acc > I have not checked the results yet (1), but this branch reduces the overhead of calculating the times a lot. I have a microbenchmark that does some simple KVM hypercalls under s390 and the average time shrinks from 280ns to 260ns. (we call accounting at guest enter and exit) About 50% of the savings seems to be Martins changes in vtime_account_irq_enter, the other 50% seems to be common code accounting doing less work. These savings of ~20ns per guest exit will also help virtio, pagefault and any other host activity on behalf of KVM guests. Nice. (1) the values seem to make sense but I have not done any calculation yet. > HEAD: ee6c393b212193bc01818c7cf4ae9cba3f469f00 > > Thanks, > Frederic > --- > > Frederic Weisbecker (9): > powerpc32: Fix stale scaled stime on context switch > ia64: Fix wrong start cputime assignment on task switch > cputime: Allow accounting system time using cpustat index > cputime: Export account_guest_time > powerpc: Prepare accounting structure for cputime flush on tick > powerpc: Migrate stolen_time field to accounting structure > powerpc/vtime: Accumulate cputime and account only on tick/task switch > ia64: Accumulate cputime and account only on tick/task switch > vtime: Rename vtime_account_user() to vtime_flush() > > Martin Schwidefsky (1): > s390/cputime: delayed accounting of system time > > > arch/ia64/include/asm/thread_info.h | 6 ++ > arch/ia64/kernel/time.c | 66 +++- > arch/powerpc/include/asm/accounting.h | 14 +++- > arch/powerpc/include/asm/paca.h | 1 - > arch/powerpc/kernel/asm-offsets.c | 8 +- > arch/powerpc/kernel/time.c| 138 > +- > arch/powerpc/xmon/xmon.c | 8 +- > arch/s390/include/asm/lowcore.h | 65 > arch/s390/include/asm/processor.h | 3 + > arch/s390/kernel/vtime.c | 116 +--- > include/linux/kernel_stat.h | 7 +- > include/linux/vtime.h | 7 +- > kernel/sched/cputime.c| 25 +++--- > 13 files changed, 295 insertions(+), 169 deletions(-) >
Re: [PATCH 00/10] vtime: Delay cputime accounting to tick
On Tue, 6 Dec 2016 15:20:55 +1100 Paul Mackerras wrote: > On Tue, Dec 06, 2016 at 03:32:13AM +0100, Frederic Weisbecker wrote: > > This follows up Martin Schwidefsky's patch which propose to delay > > cputime accounting to the tick in order to minimize the calls to > > account_system_time() and alikes as these functions can carry quite some > > overhead: > > > > http://lkml.kernel.org/r/2016112728.13a0a3db@mschwide > > > > The set includes Martin's patch, rebased on top of tip:sched/core and > > latest s390 changes, and extends it to the other implementations of > > CONFIG_VIRT_CPU_ACCOUNTING_NATIVE (powerpc and ia64) along with a few > > core changes to adapt the whole. > > > > Only built-tested though as I don't have access to any of these archs. > > The patches look reasonable at a quick look. I assume that to test > them, we would want to run a guest in an overcommitted system, so as > to get some steal time. Do you have any more specific suggestions as > to what to run as a test? Just run some benchmark and see if the > user/system/irq times look reasonable? Or do you have something more > quantitative? My quick test this morning showed that for s390 it works quite well. I yet have to do more detailed tests to see if the numbers really add up. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.
Re: [PATCH 00/10] vtime: Delay cputime accounting to tick
On Tue, Dec 06, 2016 at 03:32:13AM +0100, Frederic Weisbecker wrote: > This follows up Martin Schwidefsky's patch which propose to delay > cputime accounting to the tick in order to minimize the calls to > account_system_time() and alikes as these functions can carry quite some > overhead: > > http://lkml.kernel.org/r/2016112728.13a0a3db@mschwide > > The set includes Martin's patch, rebased on top of tip:sched/core and > latest s390 changes, and extends it to the other implementations of > CONFIG_VIRT_CPU_ACCOUNTING_NATIVE (powerpc and ia64) along with a few > core changes to adapt the whole. > > Only built-tested though as I don't have access to any of these archs. The patches look reasonable at a quick look. I assume that to test them, we would want to run a guest in an overcommitted system, so as to get some steal time. Do you have any more specific suggestions as to what to run as a test? Just run some benchmark and see if the user/system/irq times look reasonable? Or do you have something more quantitative? Paul.
[PATCH 00/10] vtime: Delay cputime accounting to tick
This follows up Martin Schwidefsky's patch which propose to delay cputime accounting to the tick in order to minimize the calls to account_system_time() and alikes as these functions can carry quite some overhead: http://lkml.kernel.org/r/2016112728.13a0a3db@mschwide The set includes Martin's patch, rebased on top of tip:sched/core and latest s390 changes, and extends it to the other implementations of CONFIG_VIRT_CPU_ACCOUNTING_NATIVE (powerpc and ia64) along with a few core changes to adapt the whole. Only built-tested though as I don't have access to any of these archs. git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git vtime/acc HEAD: ee6c393b212193bc01818c7cf4ae9cba3f469f00 Thanks, Frederic --- Frederic Weisbecker (9): powerpc32: Fix stale scaled stime on context switch ia64: Fix wrong start cputime assignment on task switch cputime: Allow accounting system time using cpustat index cputime: Export account_guest_time powerpc: Prepare accounting structure for cputime flush on tick powerpc: Migrate stolen_time field to accounting structure powerpc/vtime: Accumulate cputime and account only on tick/task switch ia64: Accumulate cputime and account only on tick/task switch vtime: Rename vtime_account_user() to vtime_flush() Martin Schwidefsky (1): s390/cputime: delayed accounting of system time arch/ia64/include/asm/thread_info.h | 6 ++ arch/ia64/kernel/time.c | 66 +++- arch/powerpc/include/asm/accounting.h | 14 +++- arch/powerpc/include/asm/paca.h | 1 - arch/powerpc/kernel/asm-offsets.c | 8 +- arch/powerpc/kernel/time.c| 138 +- arch/powerpc/xmon/xmon.c | 8 +- arch/s390/include/asm/lowcore.h | 65 arch/s390/include/asm/processor.h | 3 + arch/s390/kernel/vtime.c | 116 +--- include/linux/kernel_stat.h | 7 +- include/linux/vtime.h | 7 +- kernel/sched/cputime.c| 25 +++--- 13 files changed, 295 insertions(+), 169 deletions(-)