From: george anzinger <george@mvista.com>
To: Jason Wohlgemuth <jwohlgem@mindspring.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: lock_kernel() / unlock_kernel inconsistency Don't do this!
Date: Fri, 15 Dec 2000 16:19:33 -0800 [thread overview]
Message-ID: <3A3AB515.26227812@mvista.com> (raw)
In-Reply-To: <3A3940DA.4050001@mindspring.com>
Jason Wohlgemuth wrote:
>
> In an effort to stay consistent with the community, I migrated some code
> to a driver to use the daemonize() routine in the function specified by
> the kernel_thread() call.
>
> However, in looking at a few drivers in the system (drivers/usb/hub.c ,
> drivers/md/md.c, drivers/media/video/msp3400.c), I noticed some
> inconsistencies. Specifically with the use of lock_kernel() /
> unlock_kernel().
>
> drivers/md/md.c looks like:
> int md_thread(void * arg)
> {
> md_lock_kernel();
>
> daemonize();
> .
> .
> .
> //md_unlock_kernel();
> }
>
> this is similiar to drivers/usb/hub.c (which doesn't call unlock_kernel
> following lock_kernel)
>
> however drivers/media/video/msp3400.c looks like:
> static int msp3400c_thread(void *data)
> {
> .
> .
> .
> #ifdef CONFIG_SMP
> lock_kernel();
> #endif
> daemonize();
> .
> .
> .
> #ifdef CONFIG_SMP
> unlock_kernel();
> #endif
> }
>
> The latter example seems logically correct to me. Does this imply that
> after the CPU that is responsible for starting the thread in md.c or
> hub.c claims the global lock it will never be released to any other CPU?
>
> If I am incorrect here please just point out my error, however, I
> figured I would bring this to the mailing list's attention if in fact
> this is truely in error.
Both of these methods have problems, especially with the proposed
preemptions changes. The first case causes the thread to run with the
BKL for the whole time. This means that any other task that wants the
BKL will be blocked. Surly the needed protections don't require this.
These locks should be replaced with fine grain locking and once taken,
they should be released ASAP.
The second practice will not provide the needed protection in a
preemptable UP system. The BKL on a UP is just a NOP anyway. On the
other hand we want to use these lock points to disable preemption.
Letting the defining code for the lock decide the SMP/UP issue allows
the preemption code to do the right thing. This said, still, the BKL
should go away, see above.
George
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-12-16 0:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-14 21:51 lock_kernel() / unlock_kernel inconsistency Jason Wohlgemuth
2000-12-16 0:19 ` george anzinger [this message]
2000-12-16 0:37 ` lock_kernel() / unlock_kernel inconsistency Don't do this! Alan Cox
2000-12-16 0:48 ` george anzinger
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=3A3AB515.26227812@mvista.com \
--to=george@mvista.com \
--cc=jwohlgem@mindspring.com \
--cc=linux-kernel@vger.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