* [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3
@ 2023-02-17 20:07 Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 1/6] dm: add cond_resched() to dm_wq_work() Mike Snitzer
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer
Hou Tao (1):
dm ioctl: remove unnecessary check when using dm_get_mdptr()
Mike Snitzer (4):
dm: add cond_resched() to dm_wq_requeue_work()
dm thin: add cond_resched() to various workqueue loops
dm cache: add cond_resched() to various workqueue loops
dm ioctl: assert _hash_lock is held in __hash_remove
Pingfan Liu (1):
dm: add cond_resched() to dm_wq_work()
drivers/md/dm-cache-target.c | 4 ++++
drivers/md/dm-ioctl.c | 10 +++++++---
drivers/md/dm-thin.c | 2 ++
drivers/md/dm.c | 2 ++
4 files changed, 15 insertions(+), 3 deletions(-)
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dm-devel] [PATCH 1/6] dm: add cond_resched() to dm_wq_work()
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
@ 2023-02-17 20:07 ` Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 2/6] dm: add cond_resched() to dm_wq_requeue_work() Mike Snitzer
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer, Pingfan Liu, Ming Lei
From: Pingfan Liu <piliu@redhat.com>
Otherwise the while() loop in dm_wq_work() can result in a "dead
loop" on systems that have preemption disabled. This is particularly
problematic on single cpu systems.
Cc: stable@vger.kernel.org
Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 90b64bfc63b0..15b91959e433 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2570,6 +2570,7 @@ static void dm_wq_work(struct work_struct *work)
break;
submit_bio_noacct(bio);
+ cond_resched();
}
}
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dm-devel] [PATCH 2/6] dm: add cond_resched() to dm_wq_requeue_work()
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 1/6] dm: add cond_resched() to dm_wq_work() Mike Snitzer
@ 2023-02-17 20:07 ` Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 3/6] dm thin: add cond_resched() to various workqueue loops Mike Snitzer
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer
Otherwise the while() loop in dm_wq_requeue_work() can result in a
"dead loop" on systems that have preemption disabled. This is
particularly problematic on single cpu systems.
Fixes: 8b211aaccb915 ("dm: add two stage requeue mechanism")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 15b91959e433..adb002b8648d 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1009,6 +1009,7 @@ static void dm_wq_requeue_work(struct work_struct *work)
io->next = NULL;
__dm_io_complete(io, false);
io = next;
+ cond_resched();
}
}
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dm-devel] [PATCH 3/6] dm thin: add cond_resched() to various workqueue loops
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 1/6] dm: add cond_resched() to dm_wq_work() Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 2/6] dm: add cond_resched() to dm_wq_requeue_work() Mike Snitzer
@ 2023-02-17 20:07 ` Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 4/6] dm cache: " Mike Snitzer
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer
Otherwise on resource constrained systems these workqueues may be too
greedy.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm-thin.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index affd91a53042..6cd105c1cef3 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2209,6 +2209,7 @@ static void process_thin_deferred_bios(struct thin_c *tc)
throttle_work_update(&pool->throttle);
dm_pool_issue_prefetches(pool->pmd);
}
+ cond_resched();
}
blk_finish_plug(&plug);
}
@@ -2291,6 +2292,7 @@ static void process_thin_deferred_cells(struct thin_c *tc)
else
pool->process_cell(tc, cell);
}
+ cond_resched();
} while (!list_empty(&cells));
}
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dm-devel] [PATCH 4/6] dm cache: add cond_resched() to various workqueue loops
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
` (2 preceding siblings ...)
2023-02-17 20:07 ` [dm-devel] [PATCH 3/6] dm thin: add cond_resched() to various workqueue loops Mike Snitzer
@ 2023-02-17 20:07 ` Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 5/6] dm ioctl: assert _hash_lock is held in __hash_remove Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 6/6] dm ioctl: remove unnecessary check when using dm_get_mdptr() Mike Snitzer
5 siblings, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer
Otherwise on resource constrained systems these workqueues may be too
greedy.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm-cache-target.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 23195701dc15..dbbcfa580078 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -1829,6 +1829,7 @@ static void process_deferred_bios(struct work_struct *ws)
else
commit_needed = process_bio(cache, bio) || commit_needed;
+ cond_resched();
}
if (commit_needed)
@@ -1852,6 +1853,7 @@ static void requeue_deferred_bios(struct cache *cache)
while ((bio = bio_list_pop(&bios))) {
bio->bi_status = BLK_STS_DM_REQUEUE;
bio_endio(bio);
+ cond_resched();
}
}
@@ -1892,6 +1894,8 @@ static void check_migrations(struct work_struct *ws)
r = mg_start(cache, op, NULL);
if (r)
break;
+
+ cond_resched();
}
}
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dm-devel] [PATCH 5/6] dm ioctl: assert _hash_lock is held in __hash_remove
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
` (3 preceding siblings ...)
2023-02-17 20:07 ` [dm-devel] [PATCH 4/6] dm cache: " Mike Snitzer
@ 2023-02-17 20:07 ` Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 6/6] dm ioctl: remove unnecessary check when using dm_get_mdptr() Mike Snitzer
5 siblings, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer
Also update dm_early_create() to take _hash_lock when calling both
__get_name_cell and __hash_remove -- given dm_early_create()'s early
boot usecase this locking isn't about correctness but it allows
lockdep_assert_held() to be added to __hash_remove.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm-ioctl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index f34d36a4b4a1..067dfc08d4c3 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -310,6 +310,8 @@ static struct dm_table *__hash_remove(struct hash_cell *hc)
struct dm_table *table;
int srcu_idx;
+ lockdep_assert_held(&_hash_lock);
+
/* remove from the dev trees */
__unlink_name(hc);
__unlink_uuid(hc);
@@ -2263,7 +2265,9 @@ int __init dm_early_create(struct dm_ioctl *dmi,
err_destroy_table:
dm_table_destroy(t);
err_hash_remove:
+ down_write(&_hash_lock);
(void) __hash_remove(__get_name_cell(dmi->name));
+ up_write(&_hash_lock);
/* release reference from __get_name_cell */
dm_put(md);
err_destroy_dm:
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [dm-devel] [PATCH 6/6] dm ioctl: remove unnecessary check when using dm_get_mdptr()
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
` (4 preceding siblings ...)
2023-02-17 20:07 ` [dm-devel] [PATCH 5/6] dm ioctl: assert _hash_lock is held in __hash_remove Mike Snitzer
@ 2023-02-17 20:07 ` Mike Snitzer
5 siblings, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2023-02-17 20:07 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer, Hou Tao
From: Hou Tao <houtao1@huawei.com>
__hash_remove() removes hash_cell with _hash_lock locked, so acquiring
_hash_lock can guarantee no-NULL hc returned from dm_get_mdptr() must
have not been removed and hc->md must still be md.
__hash_remove() also acquires dm_hash_cells_mutex before setting mdptr
as NULL. So in dm_copy_name_and_uuid(), after acquiring
dm_hash_cells_mutex and ensuring returned hc is not NULL, the returned
hc must still be alive and hc->md must still be md.
Remove the unnecessary hc->md != md checks when using dm_get_mdptr()
with _hash_lock or dm_hash_cells_mutex acquired.
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm-ioctl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 067dfc08d4c3..50a1259294d1 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -789,7 +789,7 @@ static struct dm_table *dm_get_inactive_table(struct mapped_device *md, int *src
down_read(&_hash_lock);
hc = dm_get_mdptr(md);
- if (!hc || hc->md != md) {
+ if (!hc) {
DMERR("device has been removed from the dev hash table.");
goto out;
}
@@ -1500,7 +1500,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
/* stage inactive table */
down_write(&_hash_lock);
hc = dm_get_mdptr(md);
- if (!hc || hc->md != md) {
+ if (!hc) {
DMERR("device has been removed from the dev hash table.");
up_write(&_hash_lock);
r = -ENXIO;
@@ -2152,7 +2152,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
mutex_lock(&dm_hash_cells_mutex);
hc = dm_get_mdptr(md);
- if (!hc || hc->md != md) {
+ if (!hc) {
r = -ENXIO;
goto out;
}
--
2.37.0 (Apple Git-136)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-02-17 20:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 1/6] dm: add cond_resched() to dm_wq_work() Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 2/6] dm: add cond_resched() to dm_wq_requeue_work() Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 3/6] dm thin: add cond_resched() to various workqueue loops Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 4/6] dm cache: " Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 5/6] dm ioctl: assert _hash_lock is held in __hash_remove Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 6/6] dm ioctl: remove unnecessary check when using dm_get_mdptr() Mike Snitzer
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.