@@ -1030,33 +1030,26 @@ int kthread_worker_fn(void *worker_ptr)
1030
1030
EXPORT_SYMBOL_GPL (kthread_worker_fn );
1031
1031
1032
1032
static __printf (3 , 0 ) struct kthread_worker *
1033
- __kthread_create_worker ( int cpu , unsigned int flags ,
1034
- const char namefmt [], va_list args )
1033
+ __kthread_create_worker_on_node ( unsigned int flags , int node ,
1034
+ const char namefmt [], va_list args )
1035
1035
{
1036
1036
struct kthread_worker * worker ;
1037
1037
struct task_struct * task ;
1038
- int node = NUMA_NO_NODE ;
1039
1038
1040
1039
worker = kzalloc (sizeof (* worker ), GFP_KERNEL );
1041
1040
if (!worker )
1042
1041
return ERR_PTR (- ENOMEM );
1043
1042
1044
1043
kthread_init_worker (worker );
1045
1044
1046
- if (cpu >= 0 )
1047
- node = cpu_to_node (cpu );
1048
-
1049
1045
task = __kthread_create_on_node (kthread_worker_fn , worker ,
1050
- node , namefmt , args );
1046
+ node , namefmt , args );
1051
1047
if (IS_ERR (task ))
1052
1048
goto fail_task ;
1053
1049
1054
- if (cpu >= 0 )
1055
- kthread_bind (task , cpu );
1056
-
1057
1050
worker -> flags = flags ;
1058
1051
worker -> task = task ;
1059
- wake_up_process ( task );
1052
+
1060
1053
return worker ;
1061
1054
1062
1055
fail_task :
@@ -1067,32 +1060,57 @@ __kthread_create_worker(int cpu, unsigned int flags,
1067
1060
/**
1068
1061
* kthread_create_worker - create a kthread worker
1069
1062
* @flags: flags modifying the default behavior of the worker
1063
+ * @node: task structure for the thread is allocated on this node
1070
1064
* @namefmt: printf-style name for the kthread worker (task).
1071
1065
*
1072
1066
* Returns a pointer to the allocated worker on success, ERR_PTR(-ENOMEM)
1073
1067
* when the needed structures could not get allocated, and ERR_PTR(-EINTR)
1074
1068
* when the caller was killed by a fatal signal.
1075
1069
*/
1076
1070
struct kthread_worker *
1077
- kthread_create_worker (unsigned int flags , const char namefmt [], ...)
1071
+ kthread_create_worker_on_node (unsigned int flags , int node , const char namefmt [], ...)
1072
+ {
1073
+ struct kthread_worker * worker ;
1074
+ va_list args ;
1075
+
1076
+ va_start (args , namefmt );
1077
+ worker = __kthread_create_worker_on_node (flags , node , namefmt , args );
1078
+ va_end (args );
1079
+
1080
+ if (worker )
1081
+ wake_up_process (worker -> task );
1082
+
1083
+ return worker ;
1084
+ }
1085
+ EXPORT_SYMBOL (kthread_create_worker_on_node );
1086
+
1087
+ static __printf (3 , 4 ) struct kthread_worker *
1088
+ __kthread_create_worker_on_cpu (int cpu , unsigned int flags ,
1089
+ const char namefmt [], ...)
1078
1090
{
1079
1091
struct kthread_worker * worker ;
1080
1092
va_list args ;
1081
1093
1082
1094
va_start (args , namefmt );
1083
- worker = __kthread_create_worker (-1 , flags , namefmt , args );
1095
+ worker = __kthread_create_worker_on_node (flags , cpu_to_node (cpu ),
1096
+ namefmt , args );
1084
1097
va_end (args );
1085
1098
1099
+ if (worker ) {
1100
+ kthread_bind (worker -> task , cpu );
1101
+ wake_up_process (worker -> task );
1102
+ }
1103
+
1086
1104
return worker ;
1087
1105
}
1088
- EXPORT_SYMBOL (kthread_create_worker );
1089
1106
1090
1107
/**
1091
1108
* kthread_create_worker_on_cpu - create a kthread worker and bind it
1092
1109
* to a given CPU and the associated NUMA node.
1093
1110
* @cpu: CPU number
1094
1111
* @flags: flags modifying the default behavior of the worker
1095
- * @namefmt: printf-style name for the kthread worker (task).
1112
+ * @namefmt: printf-style name for the thread. Format is restricted
1113
+ * to "name.*%u". Code fills in cpu number.
1096
1114
*
1097
1115
* Use a valid CPU number if you want to bind the kthread worker
1098
1116
* to the given CPU and the associated NUMA node.
@@ -1124,16 +1142,9 @@ EXPORT_SYMBOL(kthread_create_worker);
1124
1142
*/
1125
1143
struct kthread_worker *
1126
1144
kthread_create_worker_on_cpu (int cpu , unsigned int flags ,
1127
- const char namefmt [], ... )
1145
+ const char namefmt [])
1128
1146
{
1129
- struct kthread_worker * worker ;
1130
- va_list args ;
1131
-
1132
- va_start (args , namefmt );
1133
- worker = __kthread_create_worker (cpu , flags , namefmt , args );
1134
- va_end (args );
1135
-
1136
- return worker ;
1147
+ return __kthread_create_worker_on_cpu (cpu , flags , namefmt , cpu );
1137
1148
}
1138
1149
EXPORT_SYMBOL (kthread_create_worker_on_cpu );
1139
1150
0 commit comments