All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	Rob Clark <robdclark@chromium.org>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	linux-pm@vger.kernel.org (open list:DEVICE FREQUENCY (DEVFREQ)),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v4 2/9] PM / devfreq: Teach lockdep about locking order
Date: Mon,  7 Aug 2023 10:11:36 -0700	[thread overview]
Message-ID: <20230807171148.210181-3-robdclark@gmail.com> (raw)
In-Reply-To: <20230807171148.210181-1-robdclark@gmail.com>

From: Rob Clark <robdclark@chromium.org>

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>
---
 drivers/devfreq/devfreq.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index e5558ec68ce8..81add6064406 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;
-- 
2.41.0


WARNING: multiple messages have this Message-ID (diff)
From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@chromium.org>,
	"open list:DEVICE FREQUENCY DEVFREQ" <linux-pm@vger.kernel.org>,
	linux-arm-msm@vger.kernel.org,
	open list <linux-kernel@vger.kernel.org>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	freedreno@lists.freedesktop.org
Subject: [PATCH v4 2/9] PM / devfreq: Teach lockdep about locking order
Date: Mon,  7 Aug 2023 10:11:36 -0700	[thread overview]
Message-ID: <20230807171148.210181-3-robdclark@gmail.com> (raw)
In-Reply-To: <20230807171148.210181-1-robdclark@gmail.com>

From: Rob Clark <robdclark@chromium.org>

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>
---
 drivers/devfreq/devfreq.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index e5558ec68ce8..81add6064406 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;
-- 
2.41.0


  parent reply	other threads:[~2023-08-07 17:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 17:11 [PATCH v4 0/9] drm/msm+PM+icc: Make job_run() reclaim-safe Rob Clark
2023-08-07 17:11 ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 1/9] PM / devfreq: Drop unneed locking to appease lockdep Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` Rob Clark [this message]
2023-08-07 17:11   ` [PATCH v4 2/9] PM / devfreq: Teach lockdep about locking order Rob Clark
2023-08-07 17:11 ` [PATCH v4 3/9] PM / QoS: Fix constraints alloc vs reclaim locking Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 4/9] PM / QoS: Decouple request alloc from dev_pm_qos_mtx Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 5/9] PM / QoS: Teach lockdep about dev_pm_qos_mtx locking order Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 6/9] interconnect: Fix locking for runpm vs reclaim Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 7/9] interconnect: Teach lockdep about icc_bw_lock order Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 8/9] drm/sched: Add (optional) fence signaling annotation Rob Clark
2023-08-07 17:11   ` Rob Clark
2023-08-07 17:11 ` [PATCH v4 9/9] drm/msm: Enable fence signalling annotations Rob Clark
2023-08-07 17:11   ` Rob Clark

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=20230807171148.210181-3-robdclark@gmail.com \
    --to=robdclark@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=robdclark@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.