[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJHvVciGnK9Ve7NeZ=LUbWT3PGhG7hRWh+J80ncR6Mgwk316fw@mail.gmail.com>
Date: Fri, 19 Jun 2020 09:28:24 -0700
From: Axel Rasmussen <axelrasmussen@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Michel Lespinasse <walken@...gle.com>,
David Howells <dhowells@...hat.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Jonathan Adams <jwadams@...gle.com>,
David Rientjes <rientjes@...gle.com>,
Ying Han <yinghan@...gle.com>
Subject: Re: [RFC PATCH v3 1/1] mmap_lock: add tracepoints around mmap_lock acquisition
On Fri, Jun 19, 2020 at 1:30 AM Peter Zijlstra <peterz@...radead.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. :)
Powered by blists - more mailing lists