lkml.org 
[lkml]   [2012]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 1/2] Refine mutex and rcu method in module.c, kernel<3.2.9>
Date
From: Rusty Russell [mailto:rusty@ozlabs.org] 
Sent: Thursday, March 08, 2012 5:18 PM
To: Chen, Dennis (SRDC SW); linux-kernel@vger.kernel.org
Cc: Chen, Dennis (SRDC SW)
Subject: Re: [PATCH 1/2] Refine mutex and rcu method in module.c, kernel<3.2.9>

On Wed, 7 Mar 2012 14:51:06 +0000, "Chen, Dennis (SRDC SW)" <Dennis1.Chen@amd.com> wrote:
> 1. Narrow down the granularity of mutex_lock/ mutex_unlock
> 2. Replace some unnecessary mutex_lock/mutex_unlock pairs with RCU
> 3. Refine the consistent calling style of RCU functioan

Hi Dennis,

This follows a logical evolution, where we wean off the mutex,
but AFAICT this is lost in the noise. Taking the mutex might be naive,
but adding or removing a module is the slow path. Or am I missing
something?

> -
> - /* Now sew it into the lists so we can get lockdep and oops
> - * info during argument parsing. No one should access us, since
> - * strong_try_module_get() will fail.
> - * lockdep/oops can run asynchronous, so use the RCU list insertion
> - * function to insert in a way safe to concurrent readers.
> - * The mutex protects against concurrent writers.
> - */
> - mutex_lock(&module_mutex);
> +
> + /* Concurrent writers for the global modules list are protected by RCU*/
> if (find_module(mod->name)) {
> err = -EEXIST;
> goto unlock;
> }

RCU does not protect concurrent writers:

> -
> +
> /* This has to be done once we're sure module name is unique. */
> dynamic_debug_setup(info.debug, info.num_debug);

Now this is racy...

======================================================================================

Hi Rusty,

I known RCU doesn't protect concurrent writers, so all the writers for the global modules list has been
protected by the original module_mutex in the 2-patch, I just make the scope of module_mutex become smaller
as it can, for example, dynamic_debug_setup doesn't touch modules, so it should not be in the protection of
module_mutex.

I am a person like to see a perfect world, especially in the kernel space:) Maybe I can write a test case
to trigger something you don't expect to see while the original codes will...let's think about it

BRs,
Dennis



\
 
 \ /
  Last update: 2012-03-08 13:21    [W:0.316 / U:0.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site