Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156711242
D55393.id172297.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D55393.id172297.diff
View Options
diff --git a/sys/compat/linuxkpi/common/src/linux_idr.c b/sys/compat/linuxkpi/common/src/linux_idr.c
--- a/sys/compat/linuxkpi/common/src/linux_idr.c
+++ b/sys/compat/linuxkpi/common/src/linux_idr.c
@@ -62,6 +62,8 @@
*/
static MALLOC_DEFINE(M_IDR, "idr", "Linux IDR compat");
+/* #define NO_LKPI_IDR_LOCKING */
+#ifndef NO_LKPI_IDR_LOCKING
#define IDR_LOCK_INIT(_idr) mtx_init(&(_idr)->lock, "idr", NULL, MTX_DEF);
#define IDR_LOCK_DESTROY(_idr) mtx_destroy(&(_idr)->lock);
#define IDR_LOCK(_idr) mtx_lock(&(_idr)->lock);
@@ -69,6 +71,29 @@
#define IDR_LOCK_ASSERT(_idr) mtx_assert(&(_idr)->lock, MA_OWNED);
#define IDR_LOCK_INITALIZED(_idr) mtx_initialized(&(_idr)->lock)
+#define IDR_CHECK_LOCK_DESTROYED0(_idr) \
+ if ((&(_idr)->lock)->mtx_lock == MTX_DESTROYED) { \
+ printf("%s:%d: idr %p\n", __func__, __LINE__, (_idr)); \
+ return; \
+ }
+#define IDR_CHECK_LOCK_DESTROYED(_idr, _ret) \
+ if ((&(_idr)->lock)->mtx_lock == MTX_DESTROYED) { \
+ printf("%s:%d: idr %p\n", __func__, __LINE__, (_idr)); \
+ return (_ret); \
+ }
+
+#else
+#define IDR_LOCK_INIT(_idr)
+#define IDR_LOCK_DESTROY(_idr)
+#define IDR_LOCK(_idr)
+#define IDR_UNLOCK(_idr)
+#define IDR_LOCK_ASSERT(_idr)
+#define IDR_LOCK_INITALIZED(_idr) (-1)
+
+#define IDR_CHECK_LOCK_DESTROYED0(_idr)
+#define IDR_CHECK_LOCK_DESTROYED(_idr, ...)
+#endif
+
static struct idr_layer *
idr_preload_dequeue_locked(struct linux_idr_cache *lic)
{
@@ -222,6 +247,8 @@
idr_remove_all(struct idr *idr)
{
+ IDR_CHECK_LOCK_DESTROYED0(idr);
+
IDR_LOCK(idr);
idr_remove_layer(idr->top, idr->layers - 1);
idr->top = NULL;
@@ -273,6 +300,8 @@
{
void *res;
+ IDR_CHECK_LOCK_DESTROYED(idr, NULL);
+
IDR_LOCK(idr);
res = idr_remove_locked(idr, id);
IDR_UNLOCK(idr);
@@ -305,6 +334,8 @@
void *res;
int idx;
+ IDR_CHECK_LOCK_DESTROYED(idr, ERR_PTR(-ENOENT));
+
IDR_LOCK(idr);
il = idr_find_layer_locked(idr, id);
idx = id & IDR_MASK;
@@ -340,6 +371,8 @@
{
void *res;
+ IDR_CHECK_LOCK_DESTROYED(idr, NULL);
+
IDR_LOCK(idr);
res = idr_find_locked(idr, id);
IDR_UNLOCK(idr);
@@ -352,6 +385,8 @@
void *res = NULL;
int id = *nextidp;
+ IDR_CHECK_LOCK_DESTROYED(idr, NULL);
+
IDR_LOCK(idr);
for (; id <= idr_max(idr); id++) {
res = idr_find_locked(idr, id);
@@ -371,6 +406,8 @@
struct idr_layer *head;
int need;
+ IDR_CHECK_LOCK_DESTROYED(idr, 0);
+
IDR_LOCK(idr);
for (;;) {
need = idr->layers + 1;
@@ -513,6 +550,8 @@
{
int retval;
+ IDR_CHECK_LOCK_DESTROYED(idr, -ENOSPC);
+
IDR_LOCK(idr);
retval = idr_get_new_locked(idr, ptr, idp);
IDR_UNLOCK(idr);
@@ -631,6 +670,8 @@
{
int retval;
+ IDR_CHECK_LOCK_DESTROYED(idr, -ENOSPC);
+
IDR_LOCK(idr);
retval = idr_get_new_above_locked(idr, ptr, starting_id, idp);
IDR_UNLOCK(idr);
@@ -676,6 +717,8 @@
{
int retval;
+ IDR_CHECK_LOCK_DESTROYED(idr, -ENOSPC);
+
IDR_LOCK(idr);
retval = idr_alloc_locked(idr, ptr, start, end);
IDR_UNLOCK(idr);
@@ -687,6 +730,8 @@
{
int retval;
+ IDR_CHECK_LOCK_DESTROYED(idr, -ENOSPC);
+
IDR_LOCK(idr);
retval = idr_alloc_locked(idr, ptr, max(start, idr->next_cyclic_id), end);
if (unlikely(retval == -ENOSPC))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 16, 8:18 PM (14 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28906335
Default Alt Text
D55393.id172297.diff (3 KB)
Attached To
Mode
D55393: EXEMPLIFYING CODE ONLY: LinuxKPI: idr
Attached
Detach File
Event Timeline
Log In to Comment