From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Hugh Dickins <hughd@google.com>
Cc: Luis Henriques <luis.henrix@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: RE: [RFC] "mustnotsleep"
Date: Sun, 5 Jun 2011 12:28:18 -0700 (PDT) [thread overview]
Message-ID: <703fddf1-223f-409c-a8d1-bc9468537429@default> (raw)
In-Reply-To: <BANLkTiko0AUtGYqXcYxv1KpUKY8t+tvqf1bczSN-qa9uSWtPTg@mail.gmail.com>
> Luis is surely on the right lines, but maybe CONFIG_DEBUG_PREEMPT was
> not the crucial option.
>
> You should be building with CONFIG_PREEMPT and
> CONFIG_DEBUG_SPINLOCK_SLEEP for best testing, and it would be good to
> throw in CONFIG_DEBUG_PREEMPT too.
>
> You need to preempt_disable() instead of mustnotsleep_start(), and
> preempt_enable() instead of mustnotsleep_done(). You cannot even
> safely use their smp_processor_id() without disabling preemption -
> otherwise that task might on a different cpu by the time you get to
> use the cpu it told you. It's essential to disable preemption if you
> cannot bear to be rescheduled.
>
> Then, if I've read the ifdefs correctly (please verify),
> cond_resched() will include a __might_sleep() to report "BUG: sleeping
> function called from invalid context..." from cond_resched() and other
> useful places.
Excellent! Thanks, I will give it a try! In my case,
preemption is indeed already disabled for all this code
(but irq's and bottom halves are enabled).
> But please don't disable preemption unnecessarily, nor for very long:
> it's better to remain preemptible wherever possible.
Sure, but what I'm arguing is that in many cases (and contrary
to conventional wisdom), a "somewhat fast" access to a page of data
with preemption DISabled is better than a "slow" disk read
with preemption ENabled. Naturally this depends on if
all of the CPUs have useful work to do while waiting for the
disk read to complete... but as cores proliferate, CPU saturation
is becoming less likely.
Thanks again!
Dan
prev parent reply other threads:[~2011-06-05 19:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-02 21:46 [RFC] "mustnotsleep" Dan Magenheimer
2011-06-02 23:36 ` Luis Henriques
2011-06-03 0:00 ` Dan Magenheimer
2011-06-04 3:04 ` Hugh Dickins
2011-06-05 19:28 ` Dan Magenheimer [this message]
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=703fddf1-223f-409c-a8d1-bc9468537429@default \
--to=dan.magenheimer@oracle.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luis.henrix@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.