From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: linux-scsi@vger.kernel.org, martin.petersen@oracle.com,
ejb@linux.ibm.com, tglx@linutronix.de,
Bradley Grove <linuxdrivers@attotech.com>
Subject: Re: [PATCH 07/10] scsi/esas2r: Replace tasklet with workqueue
Date: Thu, 9 Jun 2022 14:14:15 +0200 [thread overview]
Message-ID: <YqHkF+bJWNhsQa1N@linutronix.de> (raw)
In-Reply-To: <20220530231512.9729-8-dave@stgolabs.net>
On 2022-05-30 16:15:09 [-0700], Davidlohr Bueso wrote:
> diff --git a/drivers/scsi/esas2r/esas2r_int.c b/drivers/scsi/esas2r/esas2r_int.c
> index 5281d9356327..1b1b8b65539d 100644
> --- a/drivers/scsi/esas2r/esas2r_int.c
> +++ b/drivers/scsi/esas2r/esas2r_int.c
> @@ -86,7 +86,7 @@ void esas2r_polled_interrupt(struct esas2r_adapter *a)
>
> /*
> * Legacy and MSI interrupt handlers. Note that the legacy interrupt handler
> - * schedules a TASKLET to process events, whereas the MSI handler just
> + * schedules work to process events, whereas the MSI handler just
> * processes interrupt events directly.
Yeah, and why? What is special about the legacy vs MSI that different
behaviour is needed. Why not do the tasklet/workqueue thingy for MSI,
too?
> */
> irqreturn_t esas2r_interrupt(int irq, void *dev_id)
> diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
> index 7a4eadad23d7..abe45a934cce 100644
> --- a/drivers/scsi/esas2r/esas2r_main.c
> +++ b/drivers/scsi/esas2r/esas2r_main.c
> @@ -1540,10 +1550,10 @@ void esas2r_complete_request_cb(struct esas2r_adapter *a,
> esas2r_free_request(a, rq);
> }
>
> -/* Run tasklet to handle stuff outside of interrupt context. */
> -void esas2r_adapter_tasklet(unsigned long context)
> +/* Handle stuff outside of interrupt context. */
> +void esas2r_adapter_work(struct work_struct *work)
> {
> - struct esas2r_adapter *a = (struct esas2r_adapter *)context;
> + struct esas2r_adapter *a = (struct esas2r_adapter *)work;
container_of()
>
> if (unlikely(test_bit(AF2_TIMER_TICK, &a->flags2))) {
> clear_bit(AF2_TIMER_TICK, &a->flags2);
> @@ -1555,16 +1565,16 @@ void esas2r_adapter_tasklet(unsigned long context)
> esas2r_adapter_interrupt(a);
> }
>
> - if (esas2r_is_tasklet_pending(a))
> - esas2r_do_tasklet_tasks(a);
> + if (esas2r_is_work_pending(a))
> + esas2r_do_work_tasks(a);
>
> - if (esas2r_is_tasklet_pending(a)
> + if (esas2r_is_work_pending(a)
> || (test_bit(AF2_INT_PENDING, &a->flags2))
> || (test_bit(AF2_TIMER_TICK, &a->flags2))) {
> - clear_bit(AF_TASKLET_SCHEDULED, &a->flags);
> - esas2r_schedule_tasklet(a);
> + clear_bit(AF_WORK_SCHEDULED, &a->flags);
> + esas2r_schedule_work(a);
This AF_TASKLET_SCHEDULED bit is odd and shouldn't be needed. What you
usually do is set_bit() + schedule_tasklet() and clear_bit() within the
tasklet. If the tasklet is already running then it will be scheduled
again which is intended. If it is not yet running then it will run once.
> } else {
> - clear_bit(AF_TASKLET_SCHEDULED, &a->flags);
> + clear_bit(AF_WORK_SCHEDULED, &a->flags);
> }
> }
>
> @@ -1586,7 +1596,7 @@ static void esas2r_timer_callback(struct timer_list *t)
>
> set_bit(AF2_TIMER_TICK, &a->flags2);
>
> - esas2r_schedule_tasklet(a);
> + esas2r_schedule_work(a);
>
> esas2r_kickoff_timer(a);
It appears that the timer is always scheduled (except in degraded
mode) and the timer re-arms itself and schedules the tasklet. The timer
and the tasklet are synchronized and the tasklet will always after the
timer and one can not interrupt the other. But with the workqueue you
can get the following depending on how much the workqueue was delayed:
worker timer
esas2r_adapter_work();
-> test_bit(AF2_TIMER_TICK, &a->flags2) -> false
esas2r_timer_callback
set_bit(AF2_TIMER_TICK, &a->flags2);
esas2r_schedule_tasklet()
-> if (!test_and_set_bit(AF_TASKLET_SCHEDULED, &a->flags)) (bit set)
no schedule since bit was set
esas2r_kickoff_timer();
clear_bit(AF_TASKLET_SCHEDULED, &a->flags);
No more tasklets. So another reason to get rid of this
AF_TASKLET_SCHEDULED bit ;)
> }
Sebastian
next prev parent reply other threads:[~2022-06-09 12:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 23:15 [PATCH 00/10] scsi: Replace tasklets as BH Davidlohr Bueso
2022-05-30 23:15 ` [PATCH 01/10] scsi/mvsas: Kill CONFIG_SCSI_MVSAS_TASKLET Davidlohr Bueso
2022-05-31 8:05 ` John Garry
2022-05-31 14:52 ` Davidlohr Bueso
2022-05-31 15:12 ` John Garry
2022-05-31 15:17 ` Sebastian Andrzej Siewior
2022-05-31 15:26 ` John Garry
2022-05-31 15:31 ` Sebastian Andrzej Siewior
2022-06-01 1:04 ` Davidlohr Bueso
2022-06-01 8:12 ` John Garry
2022-05-30 23:15 ` [PATCH 02/10] scsi/megaraid: Replace adapter->dpc_h tasklet with threaded irq Davidlohr Bueso
2022-06-02 8:36 ` Sebastian Andrzej Siewior
2022-05-30 23:15 ` [PATCH 03/10] scsi/megaraid_sas: Replace instance->tasklet " Davidlohr Bueso
2022-06-02 10:11 ` Sebastian Andrzej Siewior
2022-05-30 23:15 ` [PATCH 04/10] scsi/aic94xx: Replace the donelist tasklet " Davidlohr Bueso
2022-06-02 10:31 ` Sebastian Andrzej Siewior
2022-05-30 23:15 ` [PATCH 05/10] scsi/isci: Replace completion_tasklet " Davidlohr Bueso
2022-06-02 18:19 ` Sebastian Andrzej Siewior
2022-06-06 10:24 ` Artur Paszkiewicz
2022-06-07 9:13 ` Sebastian Andrzej Siewior
2022-05-30 23:15 ` [PATCH 06/10] scsi/ibmvscsi_tgt: Replace work tasklet " Davidlohr Bueso
2022-06-03 11:05 ` Sebastian Andrzej Siewior
2022-05-30 23:15 ` [PATCH 07/10] scsi/esas2r: Replace tasklet with workqueue Davidlohr Bueso
2022-06-09 12:14 ` Sebastian Andrzej Siewior [this message]
2022-05-30 23:15 ` [PATCH 08/10] scsi/ibmvfc: Replace tasklet with work Davidlohr Bueso
2022-06-09 12:30 ` Sebastian Andrzej Siewior
2022-06-28 15:18 ` Davidlohr Bueso
2022-05-30 23:15 ` [PATCH 09/10] scsi/ibmvscsi: Replace srp " Davidlohr Bueso
2022-06-09 15:02 ` Sebastian Andrzej Siewior
2022-06-09 15:46 ` David Laight
2022-06-14 13:25 ` 'Sebastian Andrzej Siewior'
2022-06-14 13:34 ` David Laight
2022-05-30 23:15 ` [PATCH 10/10] scsi/lpfc: Remove bogus references to discovery tasklet Davidlohr Bueso
2022-06-09 15:21 ` Sebastian Andrzej Siewior
2022-06-02 7:57 ` [PATCH 00/10] scsi: Replace tasklets as BH Sebastian Andrzej Siewior
2022-06-07 15:59 ` Davidlohr Bueso
2022-06-07 16:20 ` Sebastian Andrzej Siewior
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=YqHkF+bJWNhsQa1N@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=dave@stgolabs.net \
--cc=ejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxdrivers@attotech.com \
--cc=martin.petersen@oracle.com \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox