lkml.org 
[lkml]   [2003]   [Mar]   [9]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] small fixes in brlock.h
FromRobert Love <>
Date09 Mar 2003 19:00:01 -0500
On Sun, 2003-03-09 at 18:44, Zwane Mwaikambo wrote:

> --- linux-2.5.64-unwashed/include/linux/brlock.h	5 Mar 2003 05:07:54 -0000	1.1.1.1
> +++ linux-2.5.64-unwashed/include/linux/brlock.h	9 Mar 2003 23:42:26 -0000
> @@ -85,8 +85,7 @@
>  	if (idx >= __BR_END)
>  		__br_lock_usage_bug();
> 
> -	preempt_disable();
> -	_raw_read_lock(&__brlock_array[smp_processor_id()][idx]);
> +	read_lock(&__brlock_array[smp_processor_id()][idx]);
>  }

This is wrong.

We have to disable preemption prior to reading smp_processor_id(). 
Otherwise we may lock/unlock the wrong processor's brlock.  The above as
you changed it is equivalent to:

	cpu = smp_processor_id();
	/* do not want to preempt here, but we can! */
	preempt_disable();
	_raw_read_lock(&__brlock_array[cpu][idx]);
And what we had, and what we need, is:

	preempt_disable();
	cpu = smp_processor_id();
	_raw_read_lock(&__brlock_array[cpu][idx]);

In other words, we need to ensure preemption is disabled prior to
calling smp_processor_id().

We also do something similar with the write patch in lib/brlock.c, but
for different reason: to disable preemption once and not NR_CPUS times.

The rest of the patch looks fine. :)

	Robert Love

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:33    [from the cache]
©2003-2008