Thread (1 message) 1 message, 1 author, 2021-05-12

Re: Qestion about device link

From: "Rafael J. Wysocki" <rafael@kernel.org>
Date: 2021-05-12 11:32:36
Also in: linux-scsi, lkml

On Wed, May 12, 2021 at 8:38 AM Hillf Danton [off-list ref] wrote:
On Tue, 11 May 2021 21:43:40 Rafael J. Wysocki  wrote:
quoted
quoted
 #ifdef CONFIG_SRCU
+static void __device_link_free_fn(struct work_struct *work)
+{
+       device_link_free(container_of(work, struct device_link, srcu.work));
+}
+
 static void __device_link_free_srcu(struct rcu_head *rhead)
 {
-       device_link_free(container_of(rhead, struct device_link, rcu_head));
+       struct device_link *link = container_of(rhead, struct device_link,
+                                               srcu.rhead);
+       struct work_struct *work = &link->srcu.work;
+
+       /*
+        * Because device_link_free() may sleep in some cases, schedule the
+        * execution of it instead of invoking it directly.
+        */
+       INIT_WORK(work, __device_link_free_fn);
+       schedule_work(work);
 }
Nope, you need something like queue_work(system_unbound_wq, work); instead
because of the blocking wq callback.
system_long_wq rather, as it really doesn't matter when it gets completed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help