lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 4 May 2022 17:17:36 +0900 From: Byungchul Park <byungchul.park@....com> To: torvalds@...ux-foundation.org Cc: damien.lemoal@...nsource.wdc.com, linux-ide@...r.kernel.org, adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org, mingo@...hat.com, linux-kernel@...r.kernel.org, peterz@...radead.org, will@...nel.org, tglx@...utronix.de, rostedt@...dmis.org, joel@...lfernandes.org, sashal@...nel.org, daniel.vetter@...ll.ch, chris@...is-wilson.co.uk, duyuyang@...il.com, johannes.berg@...el.com, tj@...nel.org, tytso@....edu, willy@...radead.org, david@...morbit.com, amir73il@...il.com, bfields@...ldses.org, gregkh@...uxfoundation.org, kernel-team@....com, linux-mm@...ck.org, akpm@...ux-foundation.org, mhocko@...nel.org, minchan@...nel.org, hannes@...xchg.org, vdavydov.dev@...il.com, sj@...nel.org, jglisse@...hat.com, dennis@...nel.org, cl@...ux.com, penberg@...nel.org, rientjes@...gle.com, vbabka@...e.cz, ngupta@...are.org, linux-block@...r.kernel.org, paolo.valente@...aro.org, josef@...icpanda.com, linux-fsdevel@...r.kernel.org, viro@...iv.linux.org.uk, jack@...e.cz, jack@...e.com, jlayton@...nel.org, dan.j.williams@...el.com, hch@...radead.org, djwong@...nel.org, dri-devel@...ts.freedesktop.org, airlied@...ux.ie, rodrigosiqueiramelo@...il.com, melissa.srw@...il.com, hamohammed.sa@...il.com, 42.hyeyoo@...il.com Subject: [PATCH RFC v6 08/21] dept: Apply Dept to rwsem Makes Dept able to track dependencies by rwsem. Signed-off-by: Byungchul Park <byungchul.park@....com> --- include/linux/lockdep.h | 24 ++++++++++++++++++++---- include/linux/percpu-rwsem.h | 4 +++- include/linux/rwsem.h | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b59d8f3..b0e097f 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -634,10 +634,26 @@ static inline void print_irqtrace_events(struct task_struct *curr) dept_mutex_unlock(&(l)->dmap, i); \ } while (0) -#define rwsem_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) -#define rwsem_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i) -#define rwsem_acquire_read(l, s, t, i) lock_acquire_shared(l, s, t, NULL, i) -#define rwsem_release(l, i) lock_release(l, i) +#define rwsem_acquire(l, s, t, i) \ +do { \ + lock_acquire_exclusive(l, s, t, NULL, i); \ + dept_rwsem_lock(&(l)->dmap, s, t, NULL, "up_write", i); \ +} while (0) +#define rwsem_acquire_nest(l, s, t, n, i) \ +do { \ + lock_acquire_exclusive(l, s, t, n, i); \ + dept_rwsem_lock(&(l)->dmap, s, t, (n) ? &(n)->dmap : NULL, "up_write", i);\ +} while (0) +#define rwsem_acquire_read(l, s, t, i) \ +do { \ + lock_acquire_shared(l, s, t, NULL, i); \ + dept_rwsem_lock(&(l)->dmap, s, t, NULL, "up_read", i); \ +} while (0) +#define rwsem_release(l, i) \ +do { \ + lock_release(l, i); \ + dept_rwsem_unlock(&(l)->dmap, i); \ +} while (0) #define lock_map_acquire(l) lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_) #define lock_map_acquire_read(l) lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_) diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 5fda40f..9a0603d 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -21,7 +21,9 @@ struct percpu_rw_semaphore { }; #ifdef CONFIG_DEBUG_LOCK_ALLOC -#define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname }, +#define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map = { \ + .name = #lockname, \ + .dmap = DEPT_MAP_INITIALIZER(lockname) }, #else #define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) #endif diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index efa5c32..ed4c34e 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -21,6 +21,7 @@ .dep_map = { \ .name = #lockname, \ .wait_type_inner = LD_WAIT_SLEEP, \ + .dmap = DEPT_MAP_INITIALIZER(lockname) \ }, #else # define __RWSEM_DEP_MAP_INIT(lockname) @@ -32,6 +33,27 @@ #include <linux/osq_lock.h> #endif +#ifdef CONFIG_DEPT +#define dept_rwsem_lock(m, ne, t, n, e_fn, ip) \ +do { \ + if (t) { \ + dept_ecxt_enter(m, 1UL, ip, __func__, e_fn, ne); \ + } else if (n) { \ + dept_ecxt_enter_nokeep(m); \ + } else { \ + dept_wait(m, 1UL, ip, __func__, ne); \ + dept_ecxt_enter(m, 1UL, ip, __func__, e_fn, ne); \ + } \ +} while (0) +#define dept_rwsem_unlock(m, ip) \ +do { \ + dept_ecxt_exit(m, 1UL, ip); \ +} while (0) +#else +#define dept_rwsem_lock(m, ne, t, n, e_fn, ip) do { } while (0) +#define dept_rwsem_unlock(m, ip) do { } while (0) +#endif + /* * For an uncontended rwsem, count and owner are the only fields a task * needs to touch when acquiring the rwsem. So they are put next to each -- 1.9.1
Powered by blists - more mailing lists