@@ -805,6 +805,7 @@ static void __padata_free(struct padata_instance *pinst)
805805 padata_free_pd (pinst -> pd );
806806 free_cpumask_var (pinst -> cpumask .pcpu );
807807 free_cpumask_var (pinst -> cpumask .cbcpu );
808+ destroy_workqueue (pinst -> wq );
808809 kfree (pinst );
809810}
810811
@@ -938,13 +939,13 @@ static struct kobj_type padata_attr_type = {
938939 * padata_alloc - allocate and initialize a padata instance and specify
939940 * cpumasks for serial and parallel workers.
940941 *
941- * @wq: workqueue to use for the allocated padata instance
942+ * @name: used to identify the instance
942943 * @pcpumask: cpumask that will be used for padata parallelization
943944 * @cbcpumask: cpumask that will be used for padata serialization
944945 *
945946 * Must be called from a cpus_read_lock() protected region
946947 */
947- static struct padata_instance * padata_alloc (struct workqueue_struct * wq ,
948+ static struct padata_instance * padata_alloc (const char * name ,
948949 const struct cpumask * pcpumask ,
949950 const struct cpumask * cbcpumask )
950951{
@@ -955,11 +956,16 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
955956 if (!pinst )
956957 goto err ;
957958
958- if (!alloc_cpumask_var (& pinst -> cpumask .pcpu , GFP_KERNEL ))
959+ pinst -> wq = alloc_workqueue ("%s" , WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE ,
960+ 1 , name );
961+ if (!pinst -> wq )
959962 goto err_free_inst ;
963+
964+ if (!alloc_cpumask_var (& pinst -> cpumask .pcpu , GFP_KERNEL ))
965+ goto err_free_wq ;
960966 if (!alloc_cpumask_var (& pinst -> cpumask .cbcpu , GFP_KERNEL )) {
961967 free_cpumask_var (pinst -> cpumask .pcpu );
962- goto err_free_inst ;
968+ goto err_free_wq ;
963969 }
964970 if (!padata_validate_cpumask (pinst , pcpumask ) ||
965971 !padata_validate_cpumask (pinst , cbcpumask ))
@@ -971,8 +977,6 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
971977
972978 rcu_assign_pointer (pinst -> pd , pd );
973979
974- pinst -> wq = wq ;
975-
976980 cpumask_copy (pinst -> cpumask .pcpu , pcpumask );
977981 cpumask_copy (pinst -> cpumask .cbcpu , cbcpumask );
978982
@@ -990,6 +994,8 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
990994err_free_masks :
991995 free_cpumask_var (pinst -> cpumask .pcpu );
992996 free_cpumask_var (pinst -> cpumask .cbcpu );
997+ err_free_wq :
998+ destroy_workqueue (pinst -> wq );
993999err_free_inst :
9941000 kfree (pinst );
9951001err :
@@ -1001,14 +1007,14 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
10011007 * Use the cpu_possible_mask for serial and
10021008 * parallel workers.
10031009 *
1004- * @wq: workqueue to use for the allocated padata instance
1010+ * @name: used to identify the instance
10051011 *
10061012 * Must be called from a cpus_read_lock() protected region
10071013 */
1008- struct padata_instance * padata_alloc_possible (struct workqueue_struct * wq )
1014+ struct padata_instance * padata_alloc_possible (const char * name )
10091015{
10101016 lockdep_assert_cpus_held ();
1011- return padata_alloc (wq , cpu_possible_mask , cpu_possible_mask );
1017+ return padata_alloc (name , cpu_possible_mask , cpu_possible_mask );
10121018}
10131019EXPORT_SYMBOL (padata_alloc_possible );
10141020
0 commit comments