Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

driver core: bus: move lock_class_key into dynamic structure

Move the lock_class_key structure out of struct bus_type and into the
dynamic structure we create already for all bus_types registered with
the kernel. This saves on static space and removes one more writable
field in struct bus_type.

In the future, the same field can be moved out of the struct class logic
because it shares this same private structure.

Most everyone will never notice this change, as lockdep is not enabled
in real systems so no memory or logic changes are happening for them.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230201083349.4038660-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+6 -2
+2
drivers/base/base.h
··· 52 52 53 53 struct kset glue_dirs; 54 54 struct class *class; 55 + 56 + struct lock_class_key lock_key; 55 57 }; 56 58 #define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj) 57 59
+4 -1
drivers/base/bus.c
··· 154 154 struct subsys_private *priv = to_subsys_private(kobj); 155 155 struct bus_type *bus = priv->bus; 156 156 157 + lockdep_unregister_key(&priv->lock_key); 157 158 kfree(priv); 158 159 bus->p = NULL; 159 160 } ··· 744 743 { 745 744 int retval; 746 745 struct subsys_private *priv; 747 - struct lock_class_key *key = &bus->lock_key; 746 + struct lock_class_key *key; 748 747 749 748 priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL); 750 749 if (!priv) ··· 786 785 } 787 786 788 787 INIT_LIST_HEAD(&priv->interfaces); 788 + key = &priv->lock_key; 789 + lockdep_register_key(key); 789 790 __mutex_init(&priv->mutex, "subsys mutex", key); 790 791 klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put); 791 792 klist_init(&priv->klist_drivers, NULL, NULL);
-1
include/linux/device/bus.h
··· 112 112 const struct iommu_ops *iommu_ops; 113 113 114 114 struct subsys_private *p; 115 - struct lock_class_key lock_key; 116 115 117 116 bool need_parent_lock; 118 117 };