Skip to content

Commit

Permalink
padata: remove padata_parallel_queue
Browse files Browse the repository at this point in the history
Only its reorder field is actually used now, so remove the struct and
embed @reorder directly in parallel_data.

No functional change, just a cleanup.

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 3f25719 commit f601c72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 39 deletions.
15 changes: 2 additions & 13 deletions include/linux/padata.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ struct padata_serial_queue {
struct parallel_data *pd;
};

/**
* struct padata_parallel_queue - The percpu padata parallel queue
*
* @reorder: List to wait for reordering after parallel processing.
* @num_obj: Number of objects that are processed by this cpu.
*/
struct padata_parallel_queue {
struct padata_list reorder;
atomic_t num_obj;
};

/**
* struct padata_cpumask - The cpumasks for the parallel/serial workers
*
Expand All @@ -93,7 +82,7 @@ struct padata_cpumask {
* that depends on the cpumask in use.
*
* @ps: padata_shell object.
* @pqueue: percpu padata queues used for parallelization.
* @reorder_list: percpu reorder lists
* @squeue: percpu padata queues used for serialuzation.
* @refcnt: Number of objects holding a reference on this parallel_data.
* @seq_nr: Sequence number of the parallelized data object.
Expand All @@ -105,7 +94,7 @@ struct padata_cpumask {
*/
struct parallel_data {
struct padata_shell *ps;
struct padata_parallel_queue __percpu *pqueue;
struct padata_list __percpu *reorder_list;
struct padata_serial_queue __percpu *squeue;
atomic_t refcnt;
unsigned int seq_nr;
Expand Down
46 changes: 20 additions & 26 deletions kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,11 @@ EXPORT_SYMBOL(padata_do_parallel);
static struct padata_priv *padata_find_next(struct parallel_data *pd,
bool remove_object)
{
struct padata_parallel_queue *next_queue;
struct padata_priv *padata;
struct padata_list *reorder;
int cpu = pd->cpu;

next_queue = per_cpu_ptr(pd->pqueue, cpu);
reorder = &next_queue->reorder;
reorder = per_cpu_ptr(pd->reorder_list, cpu);

spin_lock(&reorder->lock);
if (list_empty(&reorder->list)) {
Expand Down Expand Up @@ -291,7 +289,7 @@ static void padata_reorder(struct parallel_data *pd)
int cb_cpu;
struct padata_priv *padata;
struct padata_serial_queue *squeue;
struct padata_parallel_queue *next_queue;
struct padata_list *reorder;

/*
* We need to ensure that only one cpu can work on dequeueing of
Expand Down Expand Up @@ -339,9 +337,8 @@ static void padata_reorder(struct parallel_data *pd)
*/
smp_mb();

next_queue = per_cpu_ptr(pd->pqueue, pd->cpu);
if (!list_empty(&next_queue->reorder.list) &&
padata_find_next(pd, false))
reorder = per_cpu_ptr(pd->reorder_list, pd->cpu);
if (!list_empty(&reorder->list) && padata_find_next(pd, false))
queue_work(pinst->serial_wq, &pd->reorder_work);
}

Expand Down Expand Up @@ -401,17 +398,16 @@ void padata_do_serial(struct padata_priv *padata)
{
struct parallel_data *pd = padata->pd;
int hashed_cpu = padata_cpu_hash(pd, padata->seq_nr);
struct padata_parallel_queue *pqueue = per_cpu_ptr(pd->pqueue,
hashed_cpu);
struct padata_list *reorder = per_cpu_ptr(pd->reorder_list, hashed_cpu);
struct padata_priv *cur;

spin_lock(&pqueue->reorder.lock);
spin_lock(&reorder->lock);
/* Sort in ascending order of sequence number. */
list_for_each_entry_reverse(cur, &pqueue->reorder.list, list)
list_for_each_entry_reverse(cur, &reorder->list, list)
if (cur->seq_nr < padata->seq_nr)
break;
list_add(&padata->list, &cur->list);
spin_unlock(&pqueue->reorder.lock);
spin_unlock(&reorder->lock);

/*
* Ensure the addition to the reorder list is ordered correctly
Expand Down Expand Up @@ -553,17 +549,15 @@ static void padata_init_squeues(struct parallel_data *pd)
}
}

/* Initialize all percpu queues used by parallel workers */
static void padata_init_pqueues(struct parallel_data *pd)
/* Initialize per-CPU reorder lists */
static void padata_init_reorder_list(struct parallel_data *pd)
{
int cpu;
struct padata_parallel_queue *pqueue;
struct padata_list *list;

for_each_cpu(cpu, pd->cpumask.pcpu) {
pqueue = per_cpu_ptr(pd->pqueue, cpu);

__padata_list_init(&pqueue->reorder);
atomic_set(&pqueue->num_obj, 0);
list = per_cpu_ptr(pd->reorder_list, cpu);
__padata_list_init(list);
}
}

Expand All @@ -577,13 +571,13 @@ static struct parallel_data *padata_alloc_pd(struct padata_shell *ps)
if (!pd)
goto err;

pd->pqueue = alloc_percpu(struct padata_parallel_queue);
if (!pd->pqueue)
pd->reorder_list = alloc_percpu(struct padata_list);
if (!pd->reorder_list)
goto err_free_pd;

pd->squeue = alloc_percpu(struct padata_serial_queue);
if (!pd->squeue)
goto err_free_pqueue;
goto err_free_reorder_list;

pd->ps = ps;

Expand All @@ -595,7 +589,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_shell *ps)
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_reorder_list(pd);
padata_init_squeues(pd);
pd->seq_nr = -1;
atomic_set(&pd->refcnt, 1);
Expand All @@ -609,8 +603,8 @@ static struct parallel_data *padata_alloc_pd(struct padata_shell *ps)
free_cpumask_var(pd->cpumask.pcpu);
err_free_squeue:
free_percpu(pd->squeue);
err_free_pqueue:
free_percpu(pd->pqueue);
err_free_reorder_list:
free_percpu(pd->reorder_list);
err_free_pd:
kfree(pd);
err:
Expand All @@ -621,7 +615,7 @@ static void padata_free_pd(struct parallel_data *pd)
{
free_cpumask_var(pd->cpumask.pcpu);
free_cpumask_var(pd->cpumask.cbcpu);
free_percpu(pd->pqueue);
free_percpu(pd->reorder_list);
free_percpu(pd->squeue);
kfree(pd);
}
Expand Down

0 comments on commit f601c72

Please sign in to comment.