Skip to content

Commit 67d5404

Browse files
committed
torture: Add a kthread-creation callback to _torture_create_kthread()
This commit adds a kthread-creation callback to the _torture_create_kthread() function, which allows callers of a new torture_create_kthread_cb() macro to specify a function to be invoked after the kthread is created but before it is awakened for the first time. Signed-off-by: Paul E. McKenney <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: Josh Triplett <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: [email protected] Reviewed-by: Joel Fernandes (Google) <[email protected]> Acked-by: John Stultz <[email protected]>
1 parent e2a0b78 commit 67d5404

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

include/linux/torture.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,15 @@ bool torture_must_stop(void);
108108
bool torture_must_stop_irq(void);
109109
void torture_kthread_stopping(char *title);
110110
int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
111-
char *f, struct task_struct **tp);
111+
char *f, struct task_struct **tp, void (*cbf)(struct task_struct *tp));
112112
void _torture_stop_kthread(char *m, struct task_struct **tp);
113113

114114
#define torture_create_kthread(n, arg, tp) \
115115
_torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
116-
"Failed to create " #n, &(tp))
116+
"Failed to create " #n, &(tp), NULL)
117+
#define torture_create_kthread_cb(n, arg, tp, cbf) \
118+
_torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
119+
"Failed to create " #n, &(tp), cbf)
117120
#define torture_stop_kthread(n, tp) \
118121
_torture_stop_kthread("Stopping " #n " task", &(tp))
119122

kernel/torture.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ EXPORT_SYMBOL_GPL(torture_kthread_stopping);
932932
* it starts, you will need to open-code your own.
933933
*/
934934
int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
935-
char *f, struct task_struct **tp)
935+
char *f, struct task_struct **tp, void (*cbf)(struct task_struct *tp))
936936
{
937937
int ret = 0;
938938

@@ -944,6 +944,10 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
944944
*tp = NULL;
945945
return ret;
946946
}
947+
948+
if (cbf)
949+
cbf(*tp);
950+
947951
wake_up_process(*tp); // Process is sleeping, so ordering provided.
948952
torture_shuffle_task_register(*tp);
949953
return ret;

0 commit comments

Comments
 (0)