Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor all tasklet users into other APIs #94

Open
kees opened this issue Aug 11, 2020 · 14 comments
Open

refactor all tasklet users into other APIs #94

kees opened this issue Aug 11, 2020 · 14 comments
Labels
[Refactor] tasklet removal Replace tasklet users with threaded IRQs robustness Improve kernel code robustness

Comments

@kees
Copy link

kees commented Aug 11, 2020

During the work to modernize the tasklet API, there was a request to just entirely remove it. This is much more work than just making the API safer, so it is considered the "next step" in dealing with tasklets. In the meantime, comments were added to suggest people quit using tasklets in new code. ;)

https://lore.kernel.org/driverdev-devel/20200716081538.2sivhkj4hcyrusem@linutronix.de/

Example conversions from tasklet into:

@allenpais
Copy link

@kees Can I get this issue assigned to me. I am in the process of rebasing the changes and will send a few out subsystem wise.

@kees
Copy link
Author

kees commented May 5, 2021

Sure! I can't figure out why folks can't do self-assignment in this tracker. Hmmm

@kees
Copy link
Author

kees commented Apr 7, 2022

Hi! Any progress on doing this refactoring? What do some conversion examples look like?

@kees kees changed the title entirely remove the tasklet API convert all tasklet users into threaded IRQs Apr 7, 2022
@kees kees added robustness Improve kernel code robustness [Refactor] tasklet removal Replace tasklet users with threaded IRQs labels Apr 7, 2022
@kees kees changed the title convert all tasklet users into threaded IRQs convert all tasklet users into threaded IRQs or work queues Apr 7, 2022
@kees kees changed the title convert all tasklet users into threaded IRQs or work queues refactor all tasklet users into other APIs Apr 7, 2022
@allenpais
Copy link

@kees I have most of it ready, couple of subsystems and they should be ready for review.

Also, since we are completely removing tasklets and moving to either workqueue or threaded interrupts(in some cases),
The code now heavily uses container_of macro.

Eg:

  •   struct nitrox_q_vector *qvec = (void *)(uintptr_t)(data);
    
  •   struct nitrox_q_vector *qvec = 
    
  •           container_of(work, struct nitrox_q_vector, resp_work);
    

Instead, I was thinking of having a function like from_wq() similar to from_tasklet() which would
be cleaner implementation.

#define from_wq(var, callback_wq, wq_fieldname)
container_of(callback_wq, typeof(*var), wq_fieldname)

@kees
Copy link
Author

kees commented Apr 7, 2022

Yay! That's excellent. Do you have a tree we can link to from this issue?

And since it seems Linus was not excited about the container_of wrapper helpers, so I think it's best to leave them open-coded. I think it looks nicer with a helper, but if it makes it easier to merge, then I guess open-coded is the way to go. :)

@allenpais
Copy link

Sure, I will rebase all the changes and push it out.

Thanks. I will drop the wrapper.

@allenpais
Copy link

I have pushed a branch which will contain the series(cleanup):
https://github.com/allenpais/refactor_takslets.git

Will have other sub-systems pushed in a couple of days.

@kees
Copy link
Author

kees commented Apr 19, 2022

I have pushed a branch which will contain the series(cleanup): https://github.com/allenpais/refactor_takslets.git

Will have other sub-systems pushed in a couple of days.

Nice! Did you do this with coccinelle or manually? Maybe send this one as-is to get any feedback that might be useful for the other subsystems?

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Apr 19, 2022
The tasklet is an old API which will be deprecated, workqueue API
cab be used instead of them.

This patch replaces the tasklet usage in drivers/dma/* with a
simple work.

Github: KSPP#94

Signed-off-by: Allen Pais <apais@linux.microsoft.com>
@allenpais
Copy link

@kees It was manual as not all drivers are converted to use workqueues. Some are using threaded_irq.

I have send out the first series for review:
https://lkml.org/lkml/2022/4/19/1411

Networking has the biggest set of changes, which I have split into small sets which makes it easier for the maintainer to review/merge. Changes on the rest of the sub-systems are fairly small and could be carried as a single patch(hopefully).

@kees
Copy link
Author

kees commented Feb 5, 2024

Attention has returned to tasklets!
https://lwn.net/Articles/960041/

@allenpais
Copy link

Attention has returned to tasklets! https://lwn.net/Articles/960041/

Thank Kees. Yes, I have been working with Tejun and have the series tested. The next steps are planned and am working on getting the RFC ready.

@kees
Copy link
Author

kees commented Feb 13, 2024

@allenpais
Copy link

Status of conversions(02/21/2024):

https://github.com/allenpais/for-6.9-bh-conversions

0001-dma-Convert-from-tasklet-to-BH-workqueue.patch
0002-IB-Convert-from-tasklet-to-BH-workqueue.patch
0003-USB-Convert-from-tasklet-to-BH-workqueue.patch
0004-mailbox-Convert-from-tasklet-to-BH-workqueue.patch
0005-ipmi-Convert-from-tasklet-to-BH-workqueue.patch
0006-s390-Convert-from-tasklet-to-BH-workqueue.patch
0007-drivers-media-Convert-from-tasklet-to-BH-workqueue.patch
0008-mmc-Convert-from-tasklet-to-BH-workqueue.patch

@allenpais
Copy link

Status of Conversions(03/11/2024):

I have a series ready for review(a set of 10 patches):
https://github.com/allenpais/for-6.9-bh-conversions/tree/for-6.9

0001-kernel-Introduce-enable_and_queue_work-convenience-f.patch | 64 ++
0002-dma-Convert-from-tasklet-to-BH-workqueue.patch | 1991 ++++++++++++++++++++++++++++++++++--------------------------
0003-IB-Convert-from-tasklet-to-BH-workqueue.patch | 480 ++++++++-------
0004-USB-Convert-from-tasklet-to-BH-workqueue.patch | 356 +++++++----
0005-mailbox-Convert-from-tasklet-to-BH-workqueue.patch | 68 ++-
0006-ipmi-Convert-from-tasklet-to-BH-workqueue.patch | 54 +-
0007-s390-Convert-from-tasklet-to-BH-workqueue.patch | 279 +++++----
0008-drivers-media-Convert-from-tasklet-to-BH-workqueue.patch | 673 ++++++++++++--------
0009-mmc-Convert-from-tasklet-to-BH-workqueue.patch | 491 +++++++++------
0010-hyperv-Convert-from-tasklet-to-BH-workqueue.patch | 392 ++++++++++++

A series that still needs some work(testing and cleanup):
https:/github.com/allenpais/for-6.9-bh-conversions/tree/for-6.9-wip (This
series contains changes to all the files that use tasklets in drivers/*)
0001-dma-Convert-from-tasklet-to-BH-workqueue.patch | 3381 -------------------------------------------------------------------------------------------------
0001-memstick-Convert-from-tasklet-to-BH-workqueue.patch | 150 +++++
0002-IB-Convert-from-tasklet-to-BH-workqueue.patch | 864 -------------------------
0002-tty-Convert-from-tasklet-to-BH-workqueue.patch | 513 +++++++++++++++
0003-USB-Convert-from-tasklet-to-BH-workqueue.patch | 594 ------------------
0003-scsi-Convert-from-tasklet-to-BH-workqueue.patch | 819 ++++++++++++++++++++++++
0004-mailbox-Convert-from-tasklet-to-BH-workqueue.patch | 158 -----
0004-wireless-Convert-from-tasklet-to-BH-workqueue.patch | 4014 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0005-ethernet-Convert-from-tasklet-to-BH-workqueue.patch | 3554 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0005-ipmi-Convert-from-tasklet-to-BH-workqueue.patch | 134 ----
0006-archnet-Convert-from-tasklet-to-BH-workqueue.patch | 99 +++
0006-s390-Convert-from-tasklet-to-BH-workqueue.patch | 842 -------------------------
0007-drivers-media-Convert-from-tasklet-to-BH-workqueue.patch | 1132 ---------------------------------
0007-wwan-Convert-from-tasklet-to-BH-workqueue.patch | 206 ++++++
0008-mmc-Convert-from-tasklet-to-BH-workqueue.patch | 1178 ----------------------------------
0008-net-Convert-from-tasklet-to-BH-workqueue.patch | 1046 ++++++++++++++++++++++++++++++
0009-rapidio-Convert-from-tasklet-to-BH-workqueue.patch | 62 ++
0010-pci-hyperv-Convert-from-tasklet-to-BH-workqueue.patch | 77 +++
0011-input-Convert-from-tasklet-to-BH-workqueue.patch | 105 ++++
0012-md-Convert-from-tasklet-to-BH-workqueue.patch | 138 ++++
0013-firewire-Convert-from-tasklet-to-BH-workqueue.patch | 224 +++++++
0014-misc-Convert-from-tasklet-to-BH-workqueue.patch | 88 +++
0015-hsi-Convert-from-tasklet-to-BH-workqueue.patch | 139 ++++
0016-bus-Convert-from-tasklet-to-BH-workqueue.patch | 62 ++
0017-crypto-Convert-from-tasklet-to-BH-workqueue.patch | 1820 +++++++++++++++++++++++++++++++++++++++++++++++++++++
0018-net-Convert-from-tasklet-to-BH-workqueue.patch | 933 +++++++++++++++++++++++++++
27 files changed, 14382 insertions(+), 8283 deletions(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Refactor] tasklet removal Replace tasklet users with threaded IRQs robustness Improve kernel code robustness
Projects
None yet
Development

No branches or pull requests

2 participants