Thread (284 messages) 284 messages, 35 authors, 2009-01-12

Re: [PATCH -v5][RFC]: mutex: implement adaptive spinning

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2009-01-07 20:40:12
Also in: linux-fsdevel, lkml

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help