Re: [PATCH 6.6] Revert "dm-crypt, dm-verity: disable tasklets"

From: Mikulas Patocka
Date: Mon Apr 15 2024 - 11:05:47 EST




On Fri, 12 Apr 2024, Li Lingfeng wrote:

> Hi
>
> I'm having difficulty understanding "Workqueues and ksoftirqd may be scheduled
> arbitrarily".
> This is my understanding:
> kcryptd_queue_crypt
>  tasklet_schedule
>   __tasklet_schedule
>    __tasklet_schedule_common
>     raise_softirq_irqoff
>      wakeup_softirqd
>       wake_up_process // ksoftirqd
>
> run_ksoftirqd
>  __do_softirq
>   softirq_handle_begin
>    __local_bh_disable_ip // Turn off preemption
> <---------- [1] ---------->
>   tasklet_action // h->action
>    tasklet_action_common
>     tasklet_trylock
>      kcryptd_crypt_tasklet // t->func(t->data)
>      ...
>       queue_work(cc->io_queue, &io->work)
> <---------- [2] ---------->
>     tasklet_unlock
>
> // workqueue process
> kcryptd_io_bio_endio
>  ...
>  // free tasklet_struct
>
> Since preemption has been turned off at [1], I'm confused about how the CPU
> can be scheduled out to do work first at [2].
> Would you mind explaining it to me?
>
> Thanks

Yes, you are right that scheduling is disabled when ksoftirqd processes a
softirq task.

But the upstream kernel switched to bh workqueues anyway, so there is no
need to submit a different solution to the stable kernels.

Mikulas