Prompt the account Scheduling O(1)

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Thu Jan 15 12:39:37 EST 2015


On Thu, 15 Jan 2015 18:57:20 +0300, Meyer Lansky said:

if (hardirq_count())
                per_cpu(cpu_hardirq_time, cpu) +Þlta;
else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD))
                per_cpu(cpu_softirq_time, cpu) +Þlta;

> question:  tell me what 's going on here ?

If we're currently in a hardirq, we count the current time delta as hardirq
time. If we're in a softirq, we count it as softirq time.

To minimize stuff like cache thrashing and locking issues, each CPU has its own
set of counters, and then any code that needs to compute the total will loop
across all CPUs later and total them up (as that's *much* less common than
incrementing the counters - often, we can even just export all the values to
userspace, and do the addition there without any locking issues- see /proc/stat
for an example)

The numbers are later used (for example) by 'top' to show hard/soft interrupt
time, and for other uses.

top - 12:33:50 up 49 min,  1 user,  load average: 0.25, 0.44, 0.49
Tasks: 206 total,   1 running, 205 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.0 us,  3.8 sy,  0.0 ni, 91.2 id,  0.0 wa,  0.7 hi,  0.3 si, 0.0 st

See the hi and si times (hard/soft irq)?  That's what the above code is saving
statistics for.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150115/64af3709/attachment.bin 


More information about the Kernelnewbies mailing list