From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH] driver core: bus: move lock_class_key into dynamic structure
Date: Wed, 1 Feb 2023 09:33:49 +0100 [thread overview]
Message-ID: <20230201083349.4038660-1-gregkh@linuxfoundation.org> (raw)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/base.h | 2 ++
drivers/base/bus.c | 5 ++++-
include/linux/device/bus.h | 1 -
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 2208af509ce8..0e806f641079 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -52,6 +52,8 @@ struct subsys_private {
struct kset glue_dirs;
struct class *class;
+
+ struct lock_class_key lock_key;
};
#define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index cf1b8f00b4c0..aa70b3a7d778 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -154,6 +154,7 @@ static void bus_release(struct kobject *kobj)
struct subsys_private *priv = to_subsys_private(kobj);
struct bus_type *bus = priv->bus;
+ lockdep_unregister_key(&priv->lock_key);
kfree(priv);
bus->p = NULL;
}
@@ -743,7 +744,7 @@ int bus_register(struct bus_type *bus)
{
int retval;
struct subsys_private *priv;
- struct lock_class_key *key = &bus->lock_key;
+ struct lock_class_key *key;
priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL);
if (!priv)
@@ -785,6 +786,8 @@ int bus_register(struct bus_type *bus)
}
INIT_LIST_HEAD(&priv->interfaces);
+ key = &priv->lock_key;
+ lockdep_register_key(key);
__mutex_init(&priv->mutex, "subsys mutex", key);
klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put);
klist_init(&priv->klist_drivers, NULL, NULL);
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 87e4d029c915..e3094db1e9fa 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -112,7 +112,6 @@ struct bus_type {
const struct iommu_ops *iommu_ops;
struct subsys_private *p;
- struct lock_class_key lock_key;
bool need_parent_lock;
};
--
2.39.1
next reply other threads:[~2023-02-01 8:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 8:33 Greg Kroah-Hartman [this message]
2023-02-01 18:59 ` [PATCH] driver core: bus: move lock_class_key into dynamic structure Rafael J. Wysocki
2023-02-01 19:03 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230201083349.4038660-1-gregkh@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox