linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Axel Rasmussen <axelrasmussen@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Michel Lespinasse <walken@google.com>,
	David Howells <dhowells@redhat.com>,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	Jonathan Adams <jwadams@google.com>,
	 David Rientjes <rientjes@google.com>,
	Ying Han <yinghan@google.com>
Subject: Re: [RFC PATCH v3 1/1] mmap_lock: add tracepoints around mmap_lock acquisition
Date: Fri, 19 Jun 2020 09:28:24 -0700	[thread overview]
Message-ID: <CAJHvVciGnK9Ve7NeZ=LUbWT3PGhG7hRWh+J80ncR6Mgwk316fw@mail.gmail.com> (raw)
In-Reply-To: <20200619083023.GS576905@hirez.programming.kicks-ass.net>

On Fri, Jun 19, 2020 at 1:30 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Thu, Jun 18, 2020 at 03:22:25PM -0700, Axel Rasmussen wrote:
> > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> > index f11b9bd3431d..6aabea1cbc5d 100644
> > --- a/kernel/locking/rwsem.c
> > +++ b/kernel/locking/rwsem.c
> > @@ -1495,6 +1495,20 @@ void __sched down_read(struct rw_semaphore *sem)
> >  }
> >  EXPORT_SYMBOL(down_read);
> >
> > +/*
> > + * lock for reading
> > + */
> > +void __sched down_read_contended_hook(struct rw_semaphore *sem,
> > +                                   void (*pre)(void *),
> > +                                   void (*post)(void *), void *arg)
> > +{
> > +     might_sleep();
> > +     rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
> > +     LOCK_CONTENDED_HOOK(sem, __down_read_trylock, __down_read, pre, post,
> > +                         arg);
> > +}
> > +EXPORT_SYMBOL(down_read_contended_hook);
> > +
> >  int __sched down_read_killable(struct rw_semaphore *sem)
> >  {
> >       might_sleep();
> > @@ -1509,6 +1523,24 @@ int __sched down_read_killable(struct rw_semaphore *sem)
> >  }
> >  EXPORT_SYMBOL(down_read_killable);
> >
> > +int __sched down_read_killable_contended_hook(struct rw_semaphore *sem,
> > +                                           void (*pre)(void *),
> > +                                           void (*post)(void *, int),
> > +                                           void *arg)
> > +{
> > +     might_sleep();
> > +     rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
> > +
> > +     if (LOCK_CONTENDED_HOOK_RETURN(sem, __down_read_trylock,
> > +                                    __down_read_killable, pre, post, arg)) {
> > +             rwsem_release(&sem->dep_map, _RET_IP_);
> > +             return -EINTR;
> > +     }
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(down_read_killable_contended_hook);
> > +
> >  /*
> >   * trylock for reading -- returns 1 if successful, 0 if contention
> >   */
> > @@ -1533,6 +1565,20 @@ void __sched down_write(struct rw_semaphore *sem)
> >  }
> >  EXPORT_SYMBOL(down_write);
> >
> > +/*
> > + * lock for writing
> > + */
> > +void __sched down_write_contended_hook(struct rw_semaphore *sem,
> > +                                    void (*pre)(void *),
> > +                                    void (*post)(void *), void *arg)
> > +{
> > +     might_sleep();
> > +     rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_);
> > +     LOCK_CONTENDED_HOOK(sem, __down_write_trylock, __down_write, pre, post,
> > +                         arg);
> > +}
> > +EXPORT_SYMBOL(down_write_contended_hook);
> > +
> >  /*
> >   * lock for writing
> >   */
> > @@ -1551,6 +1597,24 @@ int __sched down_write_killable(struct rw_semaphore *sem)
> >  }
> >  EXPORT_SYMBOL(down_write_killable);
> >
> > +int __sched down_write_killable_contended_hook(struct rw_semaphore *sem,
> > +                                            void (*pre)(void *),
> > +                                            void (*post)(void *, int),
> > +                                            void *arg)
> > +{
> > +     might_sleep();
> > +     rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
> > +
> > +     if (LOCK_CONTENDED_HOOK_RETURN(sem, __down_write_trylock,
> > +                                    __down_write_killable, pre, post, arg)) {
> > +             rwsem_release(&sem->dep_map, _RET_IP_);
> > +             return -EINTR;
> > +     }
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(down_write_killable_contended_hook);
> > +
> >  /*
> >   * trylock for writing -- returns 1 if successful, 0 if contention
> >   */
>
> NAK, absolutely not going to happen. This is an atrocious API to expose,
> worse you're exporting.

Ack about splitting this up.

Thanks for taking a look. :)


  reply	other threads:[~2020-06-19 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 22:22 [RFC PATCH v3 0/1] Add rwsem "contended hook" API and mmap_lock histograms Axel Rasmussen
2020-06-18 22:22 ` [RFC PATCH v3 1/1] mmap_lock: add tracepoints around mmap_lock acquisition Axel Rasmussen
2020-06-19  8:29   ` Peter Zijlstra
2020-06-19  8:30   ` Peter Zijlstra
2020-06-19 16:28     ` Axel Rasmussen [this message]
2020-06-25 20:25       ` Axel Rasmussen
2020-09-08 11:41   ` Yafang Shao
2020-09-09 16:25     ` Axel Rasmussen

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='CAJHvVciGnK9Ve7NeZ=LUbWT3PGhG7hRWh+J80ncR6Mgwk316fw@mail.gmail.com' \
    --to=axelrasmussen@google.com \
    --cc=dhowells@redhat.com \
    --cc=jwadams@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterz@infradead.org \
    --cc=rientjes@google.com \
    --cc=walken@google.com \
    --cc=yinghan@google.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;
as well as URLs for NNTP newsgroup(s).