aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <robdclark@chromium.org>2023-03-20 07:43:38 -0700
committerChanwoo Choi <cw00.choi@samsung.com>2023-03-21 06:01:03 +0900
commitdfb3d4a9e2bdb5e89ec73147c838f15a235cc0dd (patch)
tree4b2f820949a1e3d82266fdafcb941b489a0c729e
parent6945f2925f0fbc45d9567574f8079f4587ae4fb2 (diff)
downloadlinux-devfreq-testing.tar.gz
PM / devfreq: Teach lockdep about locking orderdevfreq-testing
This will make it easier to catch places doing allocations that can trigger reclaim under devfreq->lock. Because devfreq->lock is held over various devfreq_dev_profile callbacks, there might be some fallout if those callbacks do allocations that can trigger reclaim, but I've looked through the various callback implementations and don't see anything obvious. If it does trigger any lockdep splats, those should be fixed. Signed-off-by: Rob Clark <robdclark@chromium.org>
-rw-r--r--drivers/devfreq/devfreq.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 11b774048bd2fd..5ce3bf9b59e77e 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -817,6 +817,12 @@ struct devfreq *devfreq_add_device(struct device *dev,
}
mutex_init(&devfreq->lock);
+
+ /* Teach lockdep about lock ordering wrt. shrinker: */
+ fs_reclaim_acquire(GFP_KERNEL);
+ might_lock(&devfreq->lock);
+ fs_reclaim_release(GFP_KERNEL);
+
devfreq->dev.parent = dev;
devfreq->dev.class = devfreq_class;
devfreq->dev.release = devfreq_dev_release;