[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200619083023.GS576905@hirez.programming.kicks-ass.net>
Date: Fri, 19 Jun 2020 10:30:23 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Axel Rasmussen <axelrasmussen@...gle.com>
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 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.
Powered by blists - more mailing lists