From: Valdis.Kletnieks@vt.edu (Valdis.Kletnieks at vt.edu)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Prompt the account Scheduling O(1)
Date: Thu, 15 Jan 2015 12:39:37 -0500 [thread overview]
Message-ID: <5901.1421343577@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Thu, 15 Jan 2015 18:57:20 +0300." <1421337440.78541172@f152.i.mail.ru>
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
prev parent reply other threads:[~2015-01-15 17:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 15:57 Prompt the account Scheduling O(1) Meyer Lansky
2015-01-15 17:39 ` Valdis.Kletnieks at vt.edu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5901.1421343577@turing-police.cc.vt.edu \
--to=valdis.kletnieks@vt.edu \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).