Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301762

Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of running thread

From Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of running thread
Date 2016-01-05 18:50 +0100
Message-ID <qNDU8-65D-53@gated-at.bofh.it> (permalink)
References <qNtUK-6Zq-7@gated-at.bofh.it> <qNtUK-6Zq-11@gated-at.bofh.it> <qNyB5-2yO-27@gated-at.bofh.it> <qNDKq-61Z-15@gated-at.bofh.it> <qNDU7-65D-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


----- On Jan 5, 2016, at 12:40 PM, Russell King - ARM Linux linux@arm.linux.org.uk wrote:

> On Tue, Jan 05, 2016 at 05:31:45PM +0000, Mathieu Desnoyers wrote:
>> For instance, an application could create a linked list or hash map
>> of thread control structures, which could contain the current CPU
>> number of each thread. A dispatch thread could then traverse or
>> lookup this structure to see on which CPU each thread is running and
>> do work queue dispatch or scheduling decisions accordingly.
> 
> So, what happens if the linked list is walked from thread X, and we
> discover that thread Y is allegedly running on CPU1.  We decide that
> we want to dispatch some work on that thread due to it being on CPU1,
> so we send an event to thread Y.
> 
> Thread Y becomes runnable, and the scheduler decides to schedule the
> thread on CPU3 instead of CPU1.
> 
> My point is that the above idea is inherently racy.  The only case
> where it isn't racy is when thread Y is bound to CPU1, and so can't
> move - but then you'd know that thread Y is on CPU1 and there
> wouldn't be a need for the inherent complexity suggested above.

I agree that this is inherently racy. The goal of such a scheme would
be to make statistically better dispatch decisions based on the
assumption that migration is not performed too often.

> 
> The behaviour I've seen on ARM from the scheduler (on a quad CPU
> platform, observing the system activity with top reporting the last
> CPU number used by each thread) is that threads often migrate
> between CPUs - especially in the case of (eg) one or two threads
> running in a quad-CPU system.

That seems rather odd. I have no doubt that this might be happening
right now, but having the scheduler do frequent migrations don't
appear to be in the best interest of access locality.

> 
> Given that, I'm really not sure what the use of reading and making
> decisions on the current CPU number would be within a program -
> unless the thread is bound to a particular CPU or group of CPUs,
> it seems that you can't rely on being on the reported CPU by the
> time the system call returns.

I completely agree that you can't rely on that information, but it
seems rather odd that migration would happen so often that it would
make this information statistically irrelevant.

Perhaps others could shed some light on this scheduler behavior ?

Thanks!

Mathieu

> 
> --
> RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 1/3] getcpu_cache system call: cache CPU number of running thread Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-01-05 08:10 +0100
  Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread Will Deacon <will.deacon@arm.com> - 2016-01-05 13:10 +0100
    Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-01-05 18:40 +0100
    Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-01-05 18:40 +0100
      Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-01-05 18:50 +0100
        Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-01-05 18:50 +0100
        Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-01-05 22:50 +0100
          Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-01-05 23:40 +0100
            Re: [RFC PATCH 1/3] getcpu_cache system call: cache CPU number of  running thread "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-01-06 00:00 +0100

csiph-web