Skip to content

Commit

Permalink
padata: remove effective cpumasks from the instance
Browse files Browse the repository at this point in the history
A padata instance has effective cpumasks that store the user-supplied
masks ANDed with the online mask, but this middleman is unnecessary.
parallel_data keeps the same information around.  Removing this saves
text and code churn in future changes.

Signed-off-by: Daniel Jordan <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Steffen Klassert <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
danieljordan10 authored and herbertx committed Jul 23, 2020
1 parent cec00e6 commit d69e037
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
2 changes: 0 additions & 2 deletions include/linux/padata.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ struct padata_mt_job {
* @serial_wq: The workqueue used for serial work.
* @pslist: List of padata_shell objects attached to this instance.
* @cpumask: User supplied cpumasks for parallel and serial works.
* @rcpumask: Actual cpumasks based on user cpumask and cpu_online_mask.
* @kobj: padata instance kernel object.
* @lock: padata instance lock.
* @flags: padata flags.
Expand All @@ -179,7 +178,6 @@ struct padata_instance {
struct workqueue_struct *serial_wq;
struct list_head pslist;
struct padata_cpumask cpumask;
struct padata_cpumask rcpumask;
struct kobject kobj;
struct mutex lock;
u8 flags;
Expand Down
30 changes: 3 additions & 27 deletions kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,8 @@ static void padata_init_pqueues(struct parallel_data *pd)
static struct parallel_data *padata_alloc_pd(struct padata_shell *ps)
{
struct padata_instance *pinst = ps->pinst;
const struct cpumask *cbcpumask;
const struct cpumask *pcpumask;
struct parallel_data *pd;

cbcpumask = pinst->rcpumask.cbcpu;
pcpumask = pinst->rcpumask.pcpu;

pd = kzalloc(sizeof(struct parallel_data), GFP_KERNEL);
if (!pd)
goto err;
Expand All @@ -597,8 +592,8 @@ static struct parallel_data *padata_alloc_pd(struct padata_shell *ps)
if (!alloc_cpumask_var(&pd->cpumask.cbcpu, GFP_KERNEL))
goto err_free_pcpu;

cpumask_copy(pd->cpumask.pcpu, pcpumask);
cpumask_copy(pd->cpumask.cbcpu, cbcpumask);
cpumask_and(pd->cpumask.pcpu, pinst->cpumask.pcpu, cpu_online_mask);
cpumask_and(pd->cpumask.cbcpu, pinst->cpumask.cbcpu, cpu_online_mask);

padata_init_pqueues(pd);
padata_init_squeues(pd);
Expand Down Expand Up @@ -668,12 +663,6 @@ static int padata_replace(struct padata_instance *pinst)

pinst->flags |= PADATA_RESET;

cpumask_and(pinst->rcpumask.pcpu, pinst->cpumask.pcpu,
cpu_online_mask);

cpumask_and(pinst->rcpumask.cbcpu, pinst->cpumask.cbcpu,
cpu_online_mask);

list_for_each_entry(ps, &pinst->pslist, list) {
err = padata_replace_one(ps);
if (err)
Expand Down Expand Up @@ -856,8 +845,6 @@ static void __padata_free(struct padata_instance *pinst)

WARN_ON(!list_empty(&pinst->pslist));

free_cpumask_var(pinst->rcpumask.cbcpu);
free_cpumask_var(pinst->rcpumask.pcpu);
free_cpumask_var(pinst->cpumask.pcpu);
free_cpumask_var(pinst->cpumask.cbcpu);
destroy_workqueue(pinst->serial_wq);
Expand Down Expand Up @@ -1033,20 +1020,13 @@ static struct padata_instance *padata_alloc(const char *name,
!padata_validate_cpumask(pinst, cbcpumask))
goto err_free_masks;

if (!alloc_cpumask_var(&pinst->rcpumask.pcpu, GFP_KERNEL))
goto err_free_masks;
if (!alloc_cpumask_var(&pinst->rcpumask.cbcpu, GFP_KERNEL))
goto err_free_rcpumask_pcpu;

INIT_LIST_HEAD(&pinst->pslist);

cpumask_copy(pinst->cpumask.pcpu, pcpumask);
cpumask_copy(pinst->cpumask.cbcpu, cbcpumask);
cpumask_and(pinst->rcpumask.pcpu, pcpumask, cpu_online_mask);
cpumask_and(pinst->rcpumask.cbcpu, cbcpumask, cpu_online_mask);

if (padata_setup_cpumasks(pinst))
goto err_free_rcpumask_cbcpu;
goto err_free_masks;

__padata_start(pinst);

Expand All @@ -1064,10 +1044,6 @@ static struct padata_instance *padata_alloc(const char *name,

return pinst;

err_free_rcpumask_cbcpu:
free_cpumask_var(pinst->rcpumask.cbcpu);
err_free_rcpumask_pcpu:
free_cpumask_var(pinst->rcpumask.pcpu);
err_free_masks:
free_cpumask_var(pinst->cpumask.pcpu);
free_cpumask_var(pinst->cpumask.cbcpu);
Expand Down

0 comments on commit d69e037

Please sign in to comment.