|
@@ -132,6 +132,24 @@ static void sysfs_unlink_sibling(struct sysfs_dirent *sd)
|
|
rb_erase(&sd->s_rb, &sd->s_parent->s_dir.children);
|
|
rb_erase(&sd->s_rb, &sd->s_parent->s_dir.children);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
+
|
|
|
|
+/* Test for attributes that want to ignore lockdep for read-locking */
|
|
|
|
+static bool ignore_lockdep(struct sysfs_dirent *sd)
|
|
|
|
+{
|
|
|
|
+ return sysfs_type(sd) == SYSFS_KOBJ_ATTR &&
|
|
|
|
+ sd->s_attr.attr->ignore_lockdep;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#else
|
|
|
|
+
|
|
|
|
+static inline bool ignore_lockdep(struct sysfs_dirent *sd)
|
|
|
|
+{
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* sysfs_get_active - get an active reference to sysfs_dirent
|
|
* sysfs_get_active - get an active reference to sysfs_dirent
|
|
* @sd: sysfs_dirent to get an active reference to
|
|
* @sd: sysfs_dirent to get an active reference to
|
|
@@ -155,15 +173,17 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
|
|
return NULL;
|
|
return NULL;
|
|
|
|
|
|
t = atomic_cmpxchg(&sd->s_active, v, v + 1);
|
|
t = atomic_cmpxchg(&sd->s_active, v, v + 1);
|
|
- if (likely(t == v)) {
|
|
|
|
- rwsem_acquire_read(&sd->dep_map, 0, 1, _RET_IP_);
|
|
|
|
- return sd;
|
|
|
|
- }
|
|
|
|
|
|
+ if (likely(t == v))
|
|
|
|
+ break;
|
|
if (t < 0)
|
|
if (t < 0)
|
|
return NULL;
|
|
return NULL;
|
|
|
|
|
|
cpu_relax();
|
|
cpu_relax();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (likely(!ignore_lockdep(sd)))
|
|
|
|
+ rwsem_acquire_read(&sd->dep_map, 0, 1, _RET_IP_);
|
|
|
|
+ return sd;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -180,7 +200,8 @@ void sysfs_put_active(struct sysfs_dirent *sd)
|
|
if (unlikely(!sd))
|
|
if (unlikely(!sd))
|
|
return;
|
|
return;
|
|
|
|
|
|
- rwsem_release(&sd->dep_map, 1, _RET_IP_);
|
|
|
|
|
|
+ if (likely(!ignore_lockdep(sd)))
|
|
|
|
+ rwsem_release(&sd->dep_map, 1, _RET_IP_);
|
|
v = atomic_dec_return(&sd->s_active);
|
|
v = atomic_dec_return(&sd->s_active);
|
|
if (likely(v != SD_DEACTIVATED_BIAS))
|
|
if (likely(v != SD_DEACTIVATED_BIAS))
|
|
return;
|
|
return;
|