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

On Wed, 7 Jan 2009, Linus Torvalds wrote:
>
> So we can do all that locklessly and optimistically, just going back and
> verifying the results later. This is why "thread_info" is actually a
> better thing to use than "task_struct" - we can look up the cpu in it with
> a simple dereference. We knew the pointer _used_ to be valid, so in any
> normal situation, it will never page fault (and if you have
> CONFIG_DEBUG_PAGEALLOC and hit a very unlucky race, then performance isn't
> your concern anyway: we just need to make the page fault be non-lethal ;)

Wow, and I thought I do some crazy things with side effects of different
kernel characteristics. So basically, since the owner use to be valid and
we take the cpu number directly from the thread_info struct, we do not
need to worry about page faulting.

Next comes the issue to know if the owner is still running. Wouldn't we
need to do something like

if (task_thread_info(cpu_rq(cpu)->curr) == owner)

I guess that would have the same characteristic, that even if the task
struct of cpu_rq(cpu)->curr was freed, we can still reference the
thread_info. Although, we might get garbage, but we don't care.

I understand that this should not be a problem, but I'm afraid it will
give me nightmares at night. ;-)

God that code had better be commented well.

-- Steve


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