Thread (4 messages) 4 messages, 3 authors, 2015-03-09

Get local CPU id

From: Maxime Ripard <hidden>
Date: 2015-03-09 14:39:31

Possibly related (same subject, not in this thread)

On Sun, Mar 08, 2015 at 07:10:09PM -0400, Nicholas Krause wrote:

On March 8, 2015 6:30:47 PM EDT, Valdis.Kletnieks at vt.edu wrote:
quoted
On Sun, 08 Mar 2015 22:49:00 +0100, Maxime Ripard said:
quoted
On Sun, Mar 08, 2015 at 10:06:23PM +0300, Matwey V. Kornilov wrote:
quoted
quoted
I would like to somehow obtain local CPU core ID in the interrupt
handler function. I want to see how my interruptions are
distributed
quoted
quoted
among different CPU cores under different conditions.
quoted
quoted
How should I do that?
To answer strictly your question, like Nick said, smp_processor_id()
will work fine.

However, you can do exactly what you want be reading
/proc/interrupts,
quoted
that already provide the informations you are looking for.
Clarification:  /proc/interrupts will give userspace that information.
It is *not* recommended you try to read it from kernel space, much less
from an interrupt context... :)
Does that matter through as all Matwey is interested in getting are
the load balancing among multiple cores on a smp based system under
various workloads . I wouldn't mind recommending to just read
proc/interrupts expect for it only being refreshed every 3 seconds
to my knowledge by default and therefore not valid for getting per
second data. Also this file doesn't explain the kernel's decision to
put what work on which core on a smp capable system during interrupt
context , which may also interest Matwey too.
The kernel decision is:
  - For SPIs, the default affinity is always on CPU0. That can be
    changed if someone calls irq_set_affinity.
  - For PPIs, the interrupt will be triggered on a particular
    processor, without any intervention of the kernel.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150309/fef4482c/attachment.bin 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help