On Mon, Feb 27 2023 at 1:03P -0500, Mike Snitzer <snitzer@xxxxxxxxxx> wrote: > On Mon, Feb 27 2023 at 12:55P -0500, > Mike Snitzer <snitzer@xxxxxxxxxx> wrote: > > > On Sun, Feb 26 2023 at 8:31P -0500, > > yangerkun <yangerkun@xxxxxxxxxxxxxxx> wrote: > > > > > > > > > > > 在 2023/2/26 10:01, Bart Van Assche 写道: > > > > On 2/22/23 19:19, yangerkun wrote: > > > > > @@ -1924,6 +1926,10 @@ static int dmcrypt_write(void *data) > > > > > BUG_ON(rb_parent(write_tree.rb_node)); > > > > > + if (time_is_before_jiffies(start_time + HZ)) { > > > > > + schedule(); > > > > > + start_time = jiffies; > > > > > + } > > > > > > > > Why schedule() instead of cond_resched()? > > > > > > cond_resched may not really schedule, which may trigger the problem too, but > > > it seems after 1 second, it may never happend? > > > > I had the same question as Bart when reviewing your homegrown > > conditional schedule(). Hopefully you can reproduce this issue? If > > so, please see if simply using cond_resched() fixes the issue. > > This seems like a more appropriate patch: > > diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c > index 87c5706131f2..faba1be572f9 100644 > --- a/drivers/md/dm-crypt.c > +++ b/drivers/md/dm-crypt.c > @@ -1937,6 +1937,7 @@ static int dmcrypt_write(void *data) > io = crypt_io_from_node(rb_first(&write_tree)); > rb_erase(&io->rb_node, &write_tree); > kcryptd_io_write(io); > + cond_resched(); > } while (!RB_EMPTY_ROOT(&write_tree)); > blk_finish_plug(&plug); > } or: diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 87c5706131f2..3ba2fd3e4358 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1934,6 +1934,7 @@ static int dmcrypt_write(void *data) */ blk_start_plug(&plug); do { + cond_resched(); io = crypt_io_from_node(rb_first(&write_tree)); rb_erase(&io->rb_node, &write_tree); kcryptd_io_write(io); -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel