aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-03-06 12:20:56 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-03-06 12:20:56 +0000
commit684bcfec8994ed608775ecd3f848406253be60b1 (patch)
tree58ac1c00e2b939070811ec6e9066f9d0d7096b42 /sys/compat/linuxkpi/common/include/linux
parentf4531c91abbbc3d2e64f36665abec29308bbbc10 (diff)
downloadsrc-684bcfec8994ed608775ecd3f848406253be60b1.tar.gz
src-684bcfec8994ed608775ecd3f848406253be60b1.zip
Give LinuxKPI Read-Write semaphores better debug names when
WITNESS_ALL is defined. The lock name is based on the filename and line number where the initialisation happens. MFC after: 1 week Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=314771
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/rwsem.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/rwsem.h b/sys/compat/linuxkpi/common/include/linux/rwsem.h
index 7ca066125a48..db9457a9aa4d 100644
--- a/sys/compat/linuxkpi/common/include/linux/rwsem.h
+++ b/sys/compat/linuxkpi/common/include/linux/rwsem.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -48,13 +48,25 @@ struct rw_semaphore {
#define down_write_trylock(_rw) !!sx_try_xlock(&(_rw)->sx)
#define downgrade_write(_rw) sx_downgrade(&(_rw)->sx)
#define down_read_nested(_rw, _sc) down_read(_rw)
+#define init_rwsem(_rw) linux_init_rwsem(_rw, rwsem_name("lnxrwsem"))
+
+#ifdef WITNESS_ALL
+/* NOTE: the maximum WITNESS name is 64 chars */
+#define __rwsem_name(name, file, line) \
+ (((const char *){file ":" #line "-" name}) + \
+ (sizeof(file) > 16 ? sizeof(file) - 16 : 0))
+#else
+#define __rwsem_name(name, file, line) name
+#endif
+#define _rwsem_name(...) __rwsem_name(__VA_ARGS__)
+#define rwsem_name(name) _rwsem_name(name, __FILE__, __LINE__)
static inline void
-init_rwsem(struct rw_semaphore *rw)
+linux_init_rwsem(struct rw_semaphore *rw, const char *name)
{
- memset(&rw->sx, 0, sizeof(rw->sx));
- sx_init_flags(&rw->sx, "lnxrwsem", SX_NOWITNESS);
+ memset(rw, 0, sizeof(*rw));
+ sx_init_flags(&rw->sx, name, SX_NOWITNESS);
}
-#endif /* _LINUX_RWSEM_H_ */
+#endif /* _LINUX_RWSEM_H_ */