mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Tejun Heo <tj@kernel.org>
Cc: gregkh@suse.de, dhowells@redhat.com, eparis@redhat.com,
	rjw@sisk.pl, kay.sievers@vrfy.org, jmorris@namei.org,
	bp@amd64.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] PM / Usermodehelper: Introduce reference counting to solve usermodehelper_disabled race
Date: Wed, 07 Dec 2011 17:51:44 +0530	[thread overview]
Message-ID: <4EDF5A58.6060905@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111205213832.GM627@google.com>

On 12/06/2011 03:08 AM, Tejun Heo wrote:

> On Tue, Dec 06, 2011 at 02:56:15AM +0530, Srivatsa S. Bhat wrote:
>> This patch adds the necessary synchronization framework to fix the race
>> condition with the 'usermodehelper_disabled' flag, by implementing a
>> refcounting solution. Specifically, it introduces the pair get_usermodehelper()
>> and put_usermodehelper(), which can be used by the readers (those who want to
>> read the value of the usermodehelper_disabled flag, such as _request_firmware()
>> in this case). The writers (those who enable/disable usermodehelpers by
>> setting/resetting that flag) can use the pair umh_control_begin() and
>> umh_control_done().
>>
>> The reason for using a refcounting solution and not just a plain mutex, is
>> that we don't want to unnecessarily serialize all users of request_firmware(),
>> which act as readers. But note that we cannot use reader-writer locks here
>> because the readers sleep (waiting for the firmware load from user-space),
>> and sleeping with spinlocks held is not allowed. So refcounting implemented
>> using mutex locks underneath, seems to be the best fit here.
> 
> I haven't really read the patch yet but, from the description, why not
> use rwsem?
> 

Hey that would be perfect! That hadn't crossed my mind.. Thanks for pointing
it out. I'll respin the patchset using rwsemaphores.

Regards,
Srivatsa S. Bhat


  reply	other threads:[~2011-12-07 12:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 21:25 [PATCH 0/2] PM / Usermodehelper: Fix freezer failures due to racy usermodehelper_is_disabled() Srivatsa S. Bhat
2011-12-05 21:26 ` [PATCH 1/2] PM / Usermodehelper: Introduce reference counting to solve usermodehelper_disabled race Srivatsa S. Bhat
2011-12-05 21:38   ` Tejun Heo
2011-12-07 12:21     ` Srivatsa S. Bhat [this message]
2011-12-06  0:59   ` Namhyung Kim
2011-12-07 12:30     ` Srivatsa S. Bhat
2011-12-07 13:59       ` Namhyung Kim
2011-12-05 21:26 ` [PATCH 2/2] PM / request_firmware(): Use the refcounting solution to fix the race Srivatsa S. Bhat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EDF5A58.6060905@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=bp@amd64.org \
    --cc=dhowells@redhat.com \
    --cc=eparis@redhat.com \
    --cc=gregkh@suse.de \
    --cc=jmorris@namei.org \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome