All of lore.kernel.org
 help / color / mirror / Atom feed
* looking for a function
@ 2008-09-16 12:34 Xu Yang
  0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 12:34 UTC (permalink / raw)
  To: linux-smp

Hi guys,

I am looking for a function that can show me the current thread is
running on which cpu.

e.g I am using pthread to write a multithreaded program, in each
thread I would like to insert such kind of function so that I can know
on which cpu this thread is running on.

which function should be used?

thanks for the help!!

best regards,


Yang

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

* looking for a function
@ 2008-09-16 12:50 Xu Yang
  2008-09-16 14:00 ` Bernd Petrovitsch
  0 siblings, 1 reply; 13+ messages in thread
From: Xu Yang @ 2008-09-16 12:50 UTC (permalink / raw)
  To: linux-kernel

Hi guys,

I am looking for a function that can show me the current thread is
running on which cpu.

e.g I am using pthread to write a multithreaded program, in each
thread I would like to insert such kind of function so that I can know
on which cpu this thread is running on.

which function should be used?

thanks for the help!!

best regards,



Yang

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

* looking for a function
@ 2008-09-16 12:54 Xu Yang
  0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 12:54 UTC (permalink / raw)
  To: linux-smp

Hi guys,

I am looking for a function that can show me the current thread is
running on which cpu.

e.g I am using pthread to write a multithreaded program, in each
thread I would like to insert such kind of function so that I can know
on which cpu this thread is running on.

which function should be used?

thanks for the help!!

best regards,



Yang

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

* looking for a function
@ 2008-09-16 13:26 Xu Yang
  2008-09-16 14:03 ` Steve Graegert
       [not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
  0 siblings, 2 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 13:26 UTC (permalink / raw)
  To: linux-c-programming

Hi guys,

I am looking for a function that can show me the current thread is
running on which cpu.

e.g I am using pthread to write a multithreaded program, in each
thread I would like to insert such kind of function so that I can know
on which cpu this thread is running on.

which function should be used?

thanks for the help!!

best regards,



Yang

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

* Re: looking for a function
  2008-09-16 12:50 looking for a function Xu Yang
@ 2008-09-16 14:00 ` Bernd Petrovitsch
  2008-09-16 14:11   ` Xu Yang
  0 siblings, 1 reply; 13+ messages in thread
From: Bernd Petrovitsch @ 2008-09-16 14:00 UTC (permalink / raw)
  To: Xu Yang; +Cc: linux-kernel

Hi!

On Tue, 2008-09-16 at 14:50 +0200, Xu Yang wrote:
> Hi guys,
> 
> I am looking for a function that can show me the current thread is
> running on which cpu.

> e.g I am using pthread to write a multithreaded program, in each
> thread I would like to insert such kind of function so that I can know
> on which cpu this thread is running on.

That doesn't make much sense as the same thread can run on a different
CPU after each scheduling decision. And - as it is in userspace -
scheduling can happen before any assembler op.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services



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

* Re: looking for a function
  2008-09-16 13:26 Xu Yang
@ 2008-09-16 14:03 ` Steve Graegert
       [not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
  1 sibling, 0 replies; 13+ messages in thread
From: Steve Graegert @ 2008-09-16 14:03 UTC (permalink / raw)
  To: Xu Yang; +Cc: linux-c-programming

Xu Yang,

On Linux sched_getcpu(3) comes to mind.  This function is not
particularly useful since the information returned by the function
might not be correct at the point of its return as threads can be
switched to other CPUs (read: cores) at anytime (although CPU/core
switching can be quite expensive due to cache line bouncing for
instance)

So, once the information has been obtained it might already be
obsolete.  Anyway, I hope that is what you're looking for.

        \Steve

--

Steve Grägert


On Tue, Sep 16, 2008 at 3:26 PM, Xu Yang <risingsunxy@googlemail.com> wrote:
>
> Hi guys,
>
> I am looking for a function that can show me the current thread is
> running on which cpu.
>
> e.g I am using pthread to write a multithreaded program, in each
> thread I would like to insert such kind of function so that I can know
> on which cpu this thread is running on.
>
> which function should be used?
>
> thanks for the help!!
>
> best regards,
>
>
>
> Yang
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: looking for a function
  2008-09-16 14:00 ` Bernd Petrovitsch
@ 2008-09-16 14:11   ` Xu Yang
  2008-09-16 14:18     ` Arjan van de Ven
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 14:11 UTC (permalink / raw)
  To: Bernd Petrovitsch; +Cc: linux-kernel

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I
would like to observe. I would like to learn about the thread
migration of some specific scheduling algorithm. so ....

any idea about the function?

Best regards,

Yang

2008/9/16, Bernd Petrovitsch <bernd@firmix.at>:
> Hi!
>
> On Tue, 2008-09-16 at 14:50 +0200, Xu Yang wrote:
> > Hi guys,
> >
> > I am looking for a function that can show me the current thread is
> > running on which cpu.
>
> > e.g I am using pthread to write a multithreaded program, in each
> > thread I would like to insert such kind of function so that I can know
> > on which cpu this thread is running on.
>
> That doesn't make much sense as the same thread can run on a different
> CPU after each scheduling decision. And - as it is in userspace -
> scheduling can happen before any assembler op.
>
>        Bernd
> --
> Firmix Software GmbH                   http://www.firmix.at/
> mobil: +43 664 4416156                 fax: +43 1 7890849-55
>          Embedded Linux Development and Services
>
>
>

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

* Re: looking for a function
       [not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
@ 2008-09-16 14:14   ` Xu Yang
  0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 14:14 UTC (permalink / raw)
  To: Steve Graegert; +Cc: linux-c-programming

Hi Steve,

thanks for your reply :-)

I will try this. I am evaluating some scheduling algorithm, so I would
like to learn about how the threads migrate. That is why I am asking
for such kind of function.

thank for your help!

Bes regards,

Yang

2008/9/16, Steve Graegert <graegerts@gmail.com>:
> Xu Yang,
>
> On Linux sched_getcpu(3) comes to mind.  This function is not particularly
> useful since the information returned by the function might not be correct
> at the point of its return as threads can be switched to other CPUs (read:
> cores) at anytime (although CPU/core switching can be quite expensive due to
> cache line bouncing for instance)
>
> So, once the information has been obtained it might already be obsolete.
> Anyway, I hope that is what you're looking for.
>
>         \Steve
>
> --
>
> Steve Grägert
>
>
>
> On Tue, Sep 16, 2008 at 3:26 PM, Xu Yang <risingsunxy@googlemail.com> wrote:
> >
> > Hi guys,
> >
> > I am looking for a function that can show me the current thread is
> > running on which cpu.
> >
> > e.g I am using pthread to write a multithreaded program, in each
> > thread I would like to insert such kind of function so that I can know
> > on which cpu this thread is running on.
> >
> > which function should be used?
> >
> > thanks for the help!!
> >
> > best regards,
> >
> >
> >
> > Yang
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> >
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: looking for a function
  2008-09-16 14:11   ` Xu Yang
@ 2008-09-16 14:18     ` Arjan van de Ven
  2008-09-16 14:32       ` Xu Yang
  2008-09-16 14:29     ` Frédéric Weisbecker
  2008-09-16 19:04     ` Chris Snook
  2 siblings, 1 reply; 13+ messages in thread
From: Arjan van de Ven @ 2008-09-16 14:18 UTC (permalink / raw)
  To: Xu Yang; +Cc: Bernd Petrovitsch, linux-kernel

On Tue, 16 Sep 2008 16:11:10 +0200
"Xu Yang" <risingsunxy@googlemail.com> wrote:

> Hi Bernd,
> 
> thanks for you reply.
> 
> yes, I know the thread migrates all the time, this is exactly what I
> would like to observe. I would like to learn about the thread
> migration of some specific scheduling algorithm. so ....
> 
> any idea about the function?

the getcpu() system call will do what you want.



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

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

* Re: looking for a function
  2008-09-16 14:11   ` Xu Yang
  2008-09-16 14:18     ` Arjan van de Ven
@ 2008-09-16 14:29     ` Frédéric Weisbecker
  2008-09-16 14:33       ` Xu Yang
  2008-09-16 19:04     ` Chris Snook
  2 siblings, 1 reply; 13+ messages in thread
From: Frédéric Weisbecker @ 2008-09-16 14:29 UTC (permalink / raw)
  To: Xu Yang; +Cc: Bernd Petrovitsch, linux-kernel

2008/9/16 Xu Yang <risingsunxy@googlemail.com>:
> Hi Bernd,
>
> thanks for you reply.
>
> yes, I know the thread migrates all the time, this is exactly what I
> would like to observe. I would like to learn about the thread
> migration of some specific scheduling algorithm. so ....
>
> any idea about the function?
>

And perhaps you should have a look at the sched_switch tracer which
will log for you the different context switches.

Regards,

Frederic.

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

* Re: looking for a function
  2008-09-16 14:18     ` Arjan van de Ven
@ 2008-09-16 14:32       ` Xu Yang
  0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 14:32 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: Bernd Petrovitsch, linux-kernel

Hi Arjan,

thanks,
I will try that!

Best regards,

Yang

2008/9/16, Arjan van de Ven <arjan@infradead.org>:
> On Tue, 16 Sep 2008 16:11:10 +0200
> "Xu Yang" <risingsunxy@googlemail.com> wrote:
>
> > Hi Bernd,
> >
> > thanks for you reply.
> >
> > yes, I know the thread migrates all the time, this is exactly what I
> > would like to observe. I would like to learn about the thread
> > migration of some specific scheduling algorithm. so ....
> >
> > any idea about the function?
>
> the getcpu() system call will do what you want.
>
>
>
> --
> Arjan van de Ven        Intel Open Source Technology Centre
> For development, discussion and tips for power savings,
> visit http://www.lesswatts.org
>

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

* Re: looking for a function
  2008-09-16 14:29     ` Frédéric Weisbecker
@ 2008-09-16 14:33       ` Xu Yang
  0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2008-09-16 14:33 UTC (permalink / raw)
  To: Frédéric Weisbecker; +Cc: Bernd Petrovitsch, linux-kernel

Hi Frederic,

thank you very much!
this is very useful for me. :-)

Best regards,

Yang

2008/9/16, Frédéric Weisbecker <fweisbec@gmail.com>:
> 2008/9/16 Xu Yang <risingsunxy@googlemail.com>:
> > Hi Bernd,
> >
> > thanks for you reply.
> >
> > yes, I know the thread migrates all the time, this is exactly what I
> > would like to observe. I would like to learn about the thread
> > migration of some specific scheduling algorithm. so ....
> >
> > any idea about the function?
> >
>
> And perhaps you should have a look at the sched_switch tracer which
> will log for you the different context switches.
>
> Regards,
>
> Frederic.
>

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

* Re: looking for a function
  2008-09-16 14:11   ` Xu Yang
  2008-09-16 14:18     ` Arjan van de Ven
  2008-09-16 14:29     ` Frédéric Weisbecker
@ 2008-09-16 19:04     ` Chris Snook
  2 siblings, 0 replies; 13+ messages in thread
From: Chris Snook @ 2008-09-16 19:04 UTC (permalink / raw)
  To: Xu Yang; +Cc: Bernd Petrovitsch, linux-kernel

Xu Yang wrote:
> Hi Bernd,
> 
> thanks for you reply.
> 
> yes, I know the thread migrates all the time, this is exactly what I
> would like to observe. I would like to learn about the thread
> migration of some specific scheduling algorithm. so ....
> 
> any idea about the function?
> 
> Best regards,
> 
> Yang

getcpu() should do what you want.

-- Chris

> 2008/9/16, Bernd Petrovitsch <bernd@firmix.at>:
>> Hi!
>>
>> On Tue, 2008-09-16 at 14:50 +0200, Xu Yang wrote:
>>> Hi guys,
>>>
>>> I am looking for a function that can show me the current thread is
>>> running on which cpu.
>>> e.g I am using pthread to write a multithreaded program, in each
>>> thread I would like to insert such kind of function so that I can know
>>> on which cpu this thread is running on.
>> That doesn't make much sense as the same thread can run on a different
>> CPU after each scheduling decision. And - as it is in userspace -
>> scheduling can happen before any assembler op.
>>
>>        Bernd
>> --
>> Firmix Software GmbH                   http://www.firmix.at/
>> mobil: +43 664 4416156                 fax: +43 1 7890849-55
>>          Embedded Linux Development and Services
>>
>>
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

end of thread, other threads:[~2008-09-16 19:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-16 12:50 looking for a function Xu Yang
2008-09-16 14:00 ` Bernd Petrovitsch
2008-09-16 14:11   ` Xu Yang
2008-09-16 14:18     ` Arjan van de Ven
2008-09-16 14:32       ` Xu Yang
2008-09-16 14:29     ` Frédéric Weisbecker
2008-09-16 14:33       ` Xu Yang
2008-09-16 19:04     ` Chris Snook
  -- strict thread matches above, loose matches on Subject: below --
2008-09-16 13:26 Xu Yang
2008-09-16 14:03 ` Steve Graegert
     [not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
2008-09-16 14:14   ` Xu Yang
2008-09-16 12:54 Xu Yang
2008-09-16 12:34 Xu Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.