Re: [PATCH 0/4] cputime: Virtual cputime accounting small cleanupsand consolidation

From: Frederic Weisbecker
Date: Wed Jun 20 2012 - 20:46:25 EST


2012/6/21 Peter Zijlstra <peterz@xxxxxxxxxxxxx>:
> On Tue, 2012-06-19 at 15:43 +0200, Frederic Weisbecker wrote:
>>
>> I wish we could do more vtime cputime accounting consolidation
>> but archs do the things pretty differently although I bet the
>> behaviour could be more unified.
>>
> Yes.. so s390,ia64 use thread_info, ppc uses their paca (arch private
> precursor to per-cpu data).
>
> So I understand why s390,ia64 want the sched hook, but I don't see why
> ppc would need it, their account_process_tick() can fold whatever they
> need on the tick.

I think in any case you need to flush the time on a descheduling task otherwise
its pending time will be accounted later to the next task when it
receives an irq.

So I fear we still need that sched switch hook even with per cpu data. This
may be a simple account_system_vtime() call.

> So I think reworking s390,ia64 to use per-cpu storage should get rid of
> this switch hook altogether.
>
>
> Now everybody using VIRT_CPU_ACCOUNTING has the
> syscall/__irq_{enter,exit} hooks and uses 64bit cputime_t.
>
> IRQ_TIME_ACCOUNTING only has the __irq_{enter,exit} hook and uses
> unsigned long cputime_t, it adds cputime_one_jiffy every tick when the
> per-cpu counter is ahead of the cputime.
>
>
> We could merge both and do away with the 64bit cputime thing by keeping
> a (2nd) per-cpu kernel_cpustat which we fill with optional syscall/irq
> hooks and have account_process_tick() first check if any of the
> fine-grained fields overflow and if not, fall back to the regular tick
> accounting (much like an extended irqtime_account_process_tick).
>
>
> This would merge the fine-grain and tick based code-paths and do away
> with the whole cputime_t mess, it would also merge the VIRT and IRQ
> paths and make Frederic's optional syscall accounting trivial.
>
> Or am I missing something obvious here? -- its late after all.

No that looks pretty sensible.

> I'll try and write some code tomorrow.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/