mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh MacDonald <jmacd@CS.Berkeley.EDU>
To: Marcelo Tosatti <marcelo@conectiva.com.br>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Locking comment on shrink_caches()
Date: Tue, 25 Sep 2001 13:40:09 -0700	[thread overview]
Message-ID: <20010925134009.B14537@helen.CS.Berkeley.EDU> (raw)
In-Reply-To: <20010925.125758.94556009.davem@redhat.com> <Pine.LNX.4.21.0109251539150.2193-100000@freak.distro.conectiva>
In-Reply-To: <Pine.LNX.4.21.0109251539150.2193-100000@freak.distro.conectiva>; from marcelo@conectiva.com.br on Tue, Sep 25, 2001 at 03:40:23PM -0300

Quoting Marcelo Tosatti (marcelo@conectiva.com.br):
> 
> 
> On Tue, 25 Sep 2001, David S. Miller wrote:
> 
> >    From: Marcelo Tosatti <marcelo@conectiva.com.br>
> >    Date: Tue, 25 Sep 2001 14:49:40 -0300 (BRT)
> >    
> >    Do you really need to do this ? 
> >    
> >                    if (unlikely(!spin_trylock(&pagecache_lock))) {
> >                            /* we hold the page lock so the page cannot go away from under us */
> >                            spin_unlock(&pagemap_lru_lock);
> >    
> >                            spin_lock(&pagecache_lock);
> >                            spin_lock(&pagemap_lru_lock);
> >                    }
> >    
> >    Have you actually seen bad hold times of pagecache_lock by
> >    shrink_caches() ? 
> > 
> > Marcelo, this is needed because of the spin lock ordering rules.
> > The pagecache_lock must be obtained before the pagemap_lru_lock
> > or else deadlock is possible.  The spin_trylock is an optimization.
> 
> Not, it is not.
> 
> We can simply lock the pagecachelock and the pagemap_lru_lock at the
> beginning of the cleaning function. page_launder() use to do that.

Since your main concern seems to be simplicity, the code can remain
the way it is and be far more readable with, e.g.,

/* Aquire lock1 while holding lock2--reverse order. */
#define spin_reverse_lock(lock1,lock2)     \
    if (unlikely(!spin_trylock(&lock1))) { \           
            spin_unlock(&lock2);           \        
            spin_lock(&lock1);             \          
            spin_lock(&lock2);             \        
    }                                                          

You can't argue for simple in favor of increasing lock contention,
but you can keep it readable.

-josh

  reply	other threads:[~2001-09-25 20:41 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-25 17:49 Marcelo Tosatti
2001-09-25 19:57 ` David S. Miller
2001-09-25 18:40   ` Marcelo Tosatti
2001-09-25 20:40     ` Josh MacDonald [this message]
2001-09-25 19:25       ` Marcelo Tosatti
2001-09-25 20:15   ` David S. Miller
2001-09-25 19:02     ` Marcelo Tosatti
2001-09-25 20:24     ` Rik van Riel
2001-09-25 22:26       ` David S. Miller
2001-09-26 17:42         ` Ingo Molnar
2001-09-25 20:28     ` David S. Miller
2001-09-25 21:05       ` Andrew Morton
2001-09-25 21:48       ` David S. Miller
2001-09-25 20:29     ` David S. Miller
2001-09-25 21:00       ` Benjamin LaHaise
2001-09-25 22:03         ` Andrea Arcangeli
2001-09-25 21:55       ` David S. Miller
2001-09-25 22:16         ` Benjamin LaHaise
2001-09-25 22:28         ` David S. Miller
2001-09-26 16:40           ` Alan Cox
2001-09-26 17:25             ` Linus Torvalds
2001-09-26 17:40               ` Alan Cox
2001-09-26 17:44                 ` Linus Torvalds
2001-09-26 18:01                   ` Benjamin LaHaise
2001-09-26 18:01                 ` Dave Jones
2001-09-26 20:20                 ` Vojtech Pavlik
2001-09-26 20:24                   ` Vojtech Pavlik
2001-09-26 17:45               ` Dave Jones
2001-09-26 17:50               ` Alan Cox
2001-09-26 17:59                 ` Dave Jones
2001-09-26 18:07                   ` Alan Cox
2001-09-26 18:09                   ` Padraig Brady
2001-09-26 18:22                     ` Dave Jones
2001-09-26 18:24                   ` Linus Torvalds
2001-09-26 18:40                     ` Dave Jones
2001-09-26 19:12                       ` Linus Torvalds
2001-09-27 12:22                         ` CPU frequency shifting "problems" Padraig Brady
2001-09-27 12:44                           ` Dave Jones
2001-09-27 23:23                           ` Linus Torvalds
2001-09-28  0:55                             ` Alan Cox
2001-09-28  2:12                               ` Stefan Smietanowski
2001-09-28  8:55                             ` Jamie Lokier
2001-09-28 16:11                               ` Linus Torvalds
2001-09-28 20:29                                 ` Eric W. Biederman
2001-09-28 22:24                                   ` Jamie Lokier
2001-09-26 19:04                     ` Locking comment on shrink_caches() George Greer
2001-09-26 18:59                 ` George Greer
2001-09-26 17:43             ` Richard Gooch
2001-09-26 18:24               ` Benjamin LaHaise
2001-09-26 18:48               ` Richard Gooch
2001-09-26 18:58                 ` Davide Libenzi
2001-09-26 23:26             ` David S. Miller
2001-09-27 12:10               ` Alan Cox
2001-09-27 15:38                 ` Linus Torvalds
2001-09-27 17:44                   ` Ingo Molnar
2001-09-27 19:41               ` David S. Miller
2001-09-27 22:59                 ` Alan Cox
2001-09-25 22:01     ` Andrea Arcangeli
2001-09-25 22:03     ` David S. Miller
2001-09-25 22:59       ` Andrea Arcangeli
2001-09-25 21:57   ` Andrea Arcangeli
2001-09-26  5:04 Dipankar Sarma
2001-09-26  5:31 ` Andrew Morton
2001-09-26  7:08   ` Dipankar Sarma
2001-09-26 16:52   ` John Hawkes
2001-09-26  6:57 ` David S. Miller
     [not found] <fa.cbgmt3v.192gc8r@ifi.uio.no>
     [not found] ` <fa.cd0mtbv.1aigc0v@ifi.uio.no>
     [not found]   ` <i1m66a5o1zc.fsf@verden.pvv.ntnu.no>
2001-09-27  1:34     ` Vojtech Pavlik

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=20010925134009.B14537@helen.CS.Berkeley.EDU \
    --to=jmacd@cs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /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

all inboxes | Powered by JetHome®