kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Prompt the account Scheduling O(1)
@ 2015-01-15 15:57 Meyer Lansky
  2015-01-15 17:39 ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 2+ messages in thread
From: Meyer Lansky @ 2015-01-15 15:57 UTC (permalink / raw)
  To: kernelnewbies

 Hello!? E xcuse me for my english.
I study source code?scheduler O(1)  code :

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

question:  tell me what 's going on here ?

I have this code in paper form ,  so I can not give you a link to the code .
If there is a need to rewrite your page

please help !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150115/339846f7/attachment.html 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Prompt the account Scheduling O(1)
  2015-01-15 15:57 Prompt the account Scheduling O(1) Meyer Lansky
@ 2015-01-15 17:39 ` Valdis.Kletnieks at vt.edu
  0 siblings, 0 replies; 2+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2015-01-15 17:39 UTC (permalink / raw)
  To: kernelnewbies

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 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-15 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-15 15:57 Prompt the account Scheduling O(1) Meyer Lansky
2015-01-15 17:39 ` Valdis.Kletnieks at vt.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).