Re: cpuinfo_x86 and apicid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 6 Jul 2006, Stephane Eranian wrote:

> Hello,
>
>
> In the context of the perfmon2 subsystem for processor with HyperThreading,
> we need to know on which thread we are currently running. This comes from
> the fact that the performance counters are shared between the two threads.
>
> We use the thread id (smt_id) because we split the counters in half
> between the two threads such that two threads on the same core can run
> with monitoring on.  We are currently computing the smt_id from the
> apicid as returned by a CPUID instruction. This is not very efficient.
>
> I looked through the i386 code and could not find a function nor
> structure that would return this smt_id. In the cpuinfo_x86 structure
> there is an apicid field that looks good, yet it does not seem to be
> initialized nor used.
>
> Is cpuinfo_x86->apicid field obsolete?
> If so, what is replacing it?
>
> Thanks.
>
> --
> -Stephane
> -

Does the attached file help? It is supposed to tell which CPU
execution is occurring on. This might be modified to fill your
needs.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.4 on an i686 machine (5592.88 BogoMips).
New book: http://www.AbominableFirebug.com/
_



****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
/*
 *  This program tells you what CPU your process is executing on.
 *  If you comment-out the usleep(10000), so you are eating all the
 *  CPU time in your time-slice, and you execute this from two tasks,
 *  you will note that each task gets its own CPU if you have two
 *  CPUs.
 *  If you leave in the usleep(), you will note that both tasks may
 *  use the same CPU. This happens if, and only if, they are not
 *  executing at the same time.
 */ 


#include <stdio.h>
int main(void);

int main()
{
    int cpu, prv;
    prv = -1; 
    for(;;)
    {
        __asm__ __volatile__ (
		"xorl %%eax,%%eax\n"
		"str %%ax\n"
		"subl $0x60, %%eax\n"
		"shrl $0x05, %%eax\n"
		: "=a"(cpu));
        if(cpu != prv)
        {
            prv = cpu;
            printf("CPU %d\n", cpu);
        }
        usleep(10000);
    }
    return 0;
}


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux