svn commit: r314771 - head/sys/compat/linuxkpi/common/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Mar 6 12:20:58 UTC 2017
Author: hselasky
Date: Mon Mar 6 12:20:56 2017
New Revision: 314771
URL: https://svnweb.freebsd.org/changeset/base/314771
Log:
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
Modified:
head/sys/compat/linuxkpi/common/include/linux/rwsem.h
Modified: head/sys/compat/linuxkpi/common/include/linux/rwsem.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/rwsem.h Mon Mar 6 09:34:31 2017 (r314770)
+++ head/sys/compat/linuxkpi/common/include/linux/rwsem.h Mon Mar 6 12:20:56 2017 (r314771)
@@ -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_ */
More information about the svn-src-head
mailing list