public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: Zwane Mwaikambo <zwane@linuxpower.ca>
Cc: dan carpenter <error27@email.com>,
	kernel-janitor-discuss@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: lock_kernel check...
Date: Tue, 09 Jul 2002 10:04:11 -0700	[thread overview]
Message-ID: <3D2B178B.1070903@us.ibm.com> (raw)
In-Reply-To: Pine.LNX.4.44.0207091228250.4869-100000@linux-box.realnet.co.sz

Zwane Mwaikambo wrote:
> On Tue, 9 Jul 2002, Dave Hansen wrote:
> 
> 
>>It isn't absoulutely a bad thing to return while you have a lock held. 
>>    It might be hard to understand, or even crazy, but not immediately 
>>wrong :)
>>
>>// BKL protects both "a", and io port 0xF00D
>>bar()
>>{
>>	lock_kernel();
>>	return inb(0xF00D);
>>}
>>
>>int a;
>>foo()
>>{
>>	a = bar();
>>	a--;
>>	unlock_kernel();
>>}
> 
> But broken nonetheless, that kinda thing just looks ugly. Especially when 
> someone tries to call bar multiple times or consecutively or with the lock 
> already held or...

Yes, it is horribly ugly, but it is not broken.  As a function, if you 
document what you require your caller to do, there shouldn't be a 
problem.

Also, it is valid to have nested holds of the BKL.  You can never 
deadlock with another lock_kernel() which was done in the same process.

-- 
Dave Hansen
haveblue@us.ibm.com


  reply	other threads:[~2002-07-09 17:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020709081059.17951.qmail@email.com>
2002-07-09  9:08 ` lock_kernel check Dave Hansen
2002-07-09 10:31   ` Zwane Mwaikambo
2002-07-09 17:04     ` Dave Hansen [this message]
2002-07-09 17:27 dan carpenter
2002-07-09 17:41 ` Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2002-07-09 18:22 dan carpenter

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=3D2B178B.1070903@us.ibm.com \
    --to=haveblue@us.ibm.com \
    --cc=error27@email.com \
    --cc=kernel-janitor-discuss@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zwane@linuxpower.ca \
    /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