Skip to contentSkip to conversation

kernel: export task_work_add

PATCH In review Ming Lei 4 participants 6 messages Aug 29, 2022 – Sep 7, 2022 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 kernel: export task_work_add

Firstly task_work_add() is used in several drivers. In ublk driver's usage, request batching submission can only be applied with task_work_add, and usually get better IOPS.

Secondly from this API's definition, the added work is always run in the task context, and when task is exiting, either the work is rejected to be added, or drained in do_exit(). In this way, not see obvious disadvantage or potential issue by exporting it for module's usage.

So export it, then ublk driver can get simplified, meantime with better performance.

Cc Christoph Hellwig <[email protected]>
---
 kernel/task_work.c | 1 +
 1 file changed, 1 insertion(+)
kernel/task_work.c +1 -0
index dff75bcde151..5f9a42a388f1 100644
@@ -73,6 +73,7 @@ int task_work_add(struct task_struct *task, struct callback_head *work,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(task_work_add);
 
 /**
  * task_work_cancel_match - cancel a pending work added by task_work_add()
Signature · 1 line
2.31.1
author
#1 lore raw
Quoted 9 lines · Ming Lei

Firstly task_work_add() is used in several drivers. In ublk driver's usage, request batching submission can only be applied with task_work_add, and usually get better IOPS.

Secondly from this API's definition, the added work is always run in the task context, and when task is exiting, either the work is rejected to be added, or drained in do_exit(). In this way, not see obvious disadvantage or potential issue by exporting it for module's usage.

Quoted 5 lines

So export it, then ublk driver can get simplified, meantime with better performance.

Cc Christoph Hellwig <[email protected]>

Hello Guys,

Gentle ping...

Thanks,
Ming

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ming Lei
Quoted 11 lines · Ming Lei

Firstly task_work_add() is used in several drivers. In ublk driver's usage, request batching submission can only be applied with task_work_add, and usually get better IOPS.

Secondly from this API's definition, the added work is always run in the task context, and when task is exiting, either the work is rejected to be added, or drained in do_exit(). In this way, not see obvious disadvantage or potential issue by exporting it for module's usage.

So export it, then ublk driver can get simplified, meantime with better performance.

If task_work_add() is exported, shouldn't task_work_cancel() be exported too? Anyway:

maintainer
#3 lore raw
Quoted 10 lines · Bart Van Assche
Quoted 9 lines · Ming Lei

Firstly task_work_add() is used in several drivers. In ublk driver's usage, request batching submission can only be applied with task_work_add, and usually get better IOPS.

Secondly from this API's definition, the added work is always run in the task context, and when task is exiting, either the work is rejected to be added, or drained in do_exit(). In this way, not see obvious disadvantage or potential issue by exporting it for module's usage.

Quoted 5 lines
Quoted 2 lines

So export it, then ublk driver can get simplified, meantime with better performance.

If task_work_add() is exported, shouldn't task_work_cancel() be exported too? Anyway:

Not if it isn't currently used...

On the patch itself, it definitely makes sense in the context of ublk. My hesitation is mostly around not really wanting to export this to generic modular users. It's OK for core interfaces, of which ublk is on the way to becoming, but I really don't like the idea of random modules using it. But that's not really something we can manage with the export, it's either exported or it's not...

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 6 lines · Jens Axboe

On the patch itself, it definitely makes sense in the context of ublk. My hesitation is mostly around not really wanting to export this to generic modular users. It's OK for core interfaces, of which ublk is on the way to becoming, but I really don't like the idea of random modules using it. But that's not really something we can manage with the export, it's either exported or it's not...

Yes, I'm really worried about folks doing stupid things with it. Thinking of the whole loop saga..

maintainer
#5 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Jens Axboe

On the patch itself, it definitely makes sense in the context of ublk. My hesitation is mostly around not really wanting to export this to generic modular users. It's OK for core interfaces, of which ublk is on the way to becoming, but I really don't like the idea of random modules using it. But that's not really something we can manage with the export, it's either exported or it's not...

Yes, I'm really worried about folks doing stupid things with it. Thinking of the whole loop saga..

Exactly. But we don't really have any tools outside of clearly marking it as such. It's not like we have an EXPORT_MODULE_CORE_GPL() and with that requiring a driver or modular kernel feature that marks the module as MODULE_IS_CORE_GPL().

Signature · 1 line
Jens Axboe