Get local CPU id
Hi,
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
How should I do that?
Quoted 9 lines · Matwey V. Kornilov
Hi,
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
How should I do that?
I didn't remember off hand but looked into the scheduler code where this is common. When I looked there the marco, smp_professor_id in the file include/linux/smp. h seems to be the best way to handle your task. The only concern and I am pretty certain it is, is if this marco is able to work in interrupt context a.k.a it is guaranteed to never sleep. You can either test this out and see if the system hangs or do more research into what functions and marcos work interrupt context.
Hope this helps,
Nick
Quoted 4 lines
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 7 lines · Matwey V. Kornilov
Hi,
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
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, that already provide the informations you are looking for.
Maxime
Signature · 10 lines
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/20150308/864d20b8/attachment.bin
Quoted 9 lines · Maxime Ripard
Quoted 7 lines · Matwey V. Kornilov
Hi,
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
How should I do that?
Quoted 7 lines
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, that already provide the informations you are looking for.Maxime
Good point,
I totally forgot about that file in the proc
directory. ? That was my fault.
Nick
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 6 lines · Maxime Ripard
Quoted 3 lines · Matwey V. Kornilov
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
Quoted 7 lines
Quoted 1 line
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, 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... :)
-------------- 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/20150308/80f231b9/attachment.bin
Quoted 14 lines · Valdis.Kletnieks at vt.edu
Quoted 4 lines · Maxime Ripard
Quoted 2 lines · Matwey V. Kornilov
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 7 lines
Quoted 3 lines
among different CPU cores under different conditions.
How should I do that?
To answer strictly your question, like Nick said,
smp_processor_id()will work fine.
Quoted 9 lines
Quoted 1 line
However, you can do exactly what you want be reading
/proc/interrupts,Quoted 1 line
that already provide the informations you are looking for.
Clarification:
/proc/interruptswill 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. Just my opinion,
Nick
Quoted 6 lines
------------------------------------------------------------------------
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
You can use ftrace and such.
Quoted 15 lines · Matwey V. Kornilov
Hi,
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
How should I do that?
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Quoted 4 lines · Anish Kumar
You can use ftrace and such.
That only traces file related calls and not interrupts. I stand by either using the proc/interrupts file and updating the refresh rate to 1 second if possible. There may also debugging features that you may use for monitoring interrupts when setting the kernel's compile options in the menu for debugging. I am afraid I don't remember the exact configurations to set through Matwey. Please don't let all the ideas scare you Marley as your question was rather valid and we are trying to answer with only the information given to us. If can try to resend a more detailed question this would help a lot. Also thanks for helping through Anish and good idea but it doesn't trace interrupts directly.
Nick
Quoted 21 lines
Quoted 1 line
On Mar 8, 2015, at 12:06 PM, Matwey V. Kornilov
Quoted 7 lines · <[email protected]> wrote:
Hi,
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
Quoted 7 lines
How should I do that?
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 13 lines · Valdis.Kletnieks at vt.edu
Quoted 11 lines · Maxime Ripard
Quoted 5 lines · Matwey V. Kornilov
I would like to somehow obtain local CPU core ID in the interrupt handler function. I want to see how my interruptions are distributed among different CPU cores under different conditions.
How should I do that?
To answer strictly your question, like Nick said,
smp_processor_id()will work fine.
Quoted 6 lines
Quoted 2 lines
However, you can do exactly what you want be reading
/proc/interrupts, that already provide the informations you are looking for.Clarification:
/proc/interruptswill give userspace that information. It is *not* recommended you try to read it from kernel space, much less from an interrupt context... :)
Hmmm, yes, it was a little too obvious in my mind :)
Thanks for the clarification!
Maxime
Signature · 10 lines
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/d0fa3796/attachment.bin
Quoted 25 lines · Nicholas Krause
Quoted 14 lines · Valdis.Kletnieks at vt.edu
Quoted 4 lines · Maxime Ripard
Quoted 2 lines · Matwey V. Kornilov
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 7 lines
Quoted 3 lines
among different CPU cores under different conditions.
How should I do that?
To answer strictly your question, like Nick said,
smp_processor_id()will work fine.Quoted 8 lines
Quoted 1 line
However, you can do exactly what you want be reading
/proc/interrupts,Quoted 1 line
that already provide the informations you are looking for.
Clarification:
/proc/interruptswill give userspace that information. It is *not* recommended you try to read it from kernel space, much less from an interrupt context... :)
Quoted 8 lines
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
Signature · 10 lines
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
Many thanks for all answers. smp_processor_id() works just fine in interrupt context.
Unfortunately /proc/interrupts is not what I was looking for. My idea was to print a line to dmesg at every interrupt to have a timestamp like the following:
[ 926.440799] Enter intr at 0 [ 926.441059] Exit intr at 0
-----Original Message-----
From: [email protected] [mailto:kernelnewbies-bounces at kernelnewbies.org] On Behalf Of Matwey V. Kornilov
Sent: Monday, March 09, 2015 8:35 AM
To: kernelnewbies at kernelnewbies.org
Subject: Re: Get local CPU id
Many thanks for all answers. smp_processor_id() works just fine in interrupt context.
Unfortunately /proc/interrupts is not what I was looking for. My idea was to print a line to dmesg at every interrupt to have a timestamp like the following:
[ 926.440799] Enter intr at 0 [ 926.441059] Exit intr at 0
Every interrupt? You might want to spend some time thinking about which interrupts you don't want to do the above printing for.
Jeff Haran
Quoted 16 lines · Jeff Haran
-----Original Message-----
From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-bounces at kernelnewbies.org] On Behalf Of Matwey V. Kornilov
Sent: Monday, March 09, 2015 8:35 AM
To: kernelnewbies at kernelnewbies.org
Subject: Re: Get local CPU idMany thanks for all answers.
smp_processor_id()works just fine in interrupt context.Unfortunately
/proc/interruptsis not what I was looking for. My idea was to print a line to dmesg at every interrupt to have a timestamp like the following:[ 926.440799] Enter intr at 0 [ 926.441059] Exit intr at 0Every interrupt? You might want to spend some time thinking about which interrupts you don't want to do the above printing for.
Quoted 7 lines
Jeff Haran
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Jeff,
He can just limit the dmesg output by using console_limit I believe. Nick
Quoted 1 line · Nick Krause
He can just limit the dmesg output by using
console_limitI believe.
Won't fly.
Hint:
How high to you have to set that limit to get through boot?
What happens if the message is logged to a console?
-------------- 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/20150309/bbcfba5d/attachment.bin
Quoted 10 lines · Valdis.Kletnieks at vt.edu
Quoted 1 line · Nick Krause
He can just limit the dmesg output by using
console_limitI believe.Won't fly.
Hint:
How high to you have to set that limit to get through boot?
What happens if the message is logged to a console?
I thought there was a way to limit messages to the console, however I don't remember the exact way. So yes you do have a valid point about rate limiting console messages. Nick
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.