linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: Andrew Morton <akpm@zip.com.au>
Cc: torvalds@transmeta.com, riel@conectiva.com.br,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] updated low-latency zap_page_range
Date: 24 Jul 2002 18:16:24 -0700	[thread overview]
Message-ID: <1027559785.17950.3.camel@sinai> (raw)
In-Reply-To: <3D3F4A2F.B1A9F379@zip.com.au>

On Wed, 2002-07-24 at 17:45, Andrew Morton wrote:

> Robert Love wrote:
> >
> > +static inline void cond_resched_lock(spinlock_t * lock)
> > +{
> > +       if (need_resched() && preempt_count() == 1) {
> > +               _raw_spin_unlock(lock);
> > +               preempt_enable_no_resched();
> > +               __cond_resched();
> > +               spin_lock(lock);
> > +       }
> > +}
> 
> Maybe I'm being thick.  How come a simple spin_unlock() in here
> won't do the right thing?

It will, but we will check need_resched twice.  And preempt_count
again.  My original version just did the "unlock; lock" combo and thus
the checking was automatic... but if we want to check before we unlock,
we might as well be optimal about it.

> And this won't _really_ compile to nothing with CONFIG_PREEMPT=n,
> will it?  It just does nothing because preempt_count() is zero?

I hope it compiles to nothing!  There is a false in an if... oh, wait,
to preserve possible side-effects gcc will keep the need_resched() call
so I guess we should reorder it as:

	if (preempt_count() == 1 && need_resched())

Then we get "if (0 && ..)" which should hopefully be evaluated away. 
Then the inline is empty and nothing need be done.

	Robert Love

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

  reply	other threads:[~2002-07-25  1:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-25  0:29 Robert Love
2002-07-25  0:45 ` Andrew Morton
2002-07-25  1:16   ` Robert Love [this message]
2002-07-25  1:19     ` Andrew Morton
2002-07-25  1:21     ` Linus Torvalds
2002-07-25  1:29       ` Robert Love
2002-07-25  1:39       ` george anzinger
2002-07-25  5:19         ` Linus Torvalds

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=1027559785.17950.3.camel@sinai \
    --to=rml@tech9.net \
    --cc=akpm@zip.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@conectiva.com.br \
    --cc=torvalds@transmeta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox