[lkml]   [2009]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH -v5][RFC]: mutex: implement adaptive spinning

* Linus Torvalds <> wrote:

> On Wed, 7 Jan 2009, Matthew Wilcox wrote:
> >
> > I appreciate this is sample code, but using __get_user() on
> > non-userspace pointers messes up architectures which have separate
> > user/kernel spaces (eg the old 4G/4G split for x86-32). Do we have an
> > appropriate function for kernel space pointers? Is this a good reason
> > to add one?
> Yes, you're right.
> We could do the whole "oldfs = get_fs(); set_fs(KERNEL_DS); ..
> set_fs(oldfs);" crud, but it would probably be better to just add an
> architected accessor. Especially since it's going to generally just be a
> #define get_kernel_careful(val,p) __get_user(val,p)
> for most architectures.
> We've needed that before (and yes, we've simply mis-used __get_user() on
> x86 before rather than add it).

for the oldfs stuff we already have probe_kernel_read(). OTOH, that
involves pagefault_disable() which is an atomic op, so
__get_user_careful() should be much more lightweight - and we already know
that the memory range at least _used to_ be a valid kernel address.

(Theoretical race: with memory hotplug that kernel pointer address could
have gotten unmapped and we could get device memory there - with
side-effects if accessed. Wont happen in practice.)


 \ /
  Last update: 2009-01-07 22:35    [W:0.197 / U:2.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site