Exemplo n.º 1
0
Arquivo: padata.c Projeto: Lyude/linux
/*
 * padata_get_next - Get the next object that needs serialization.
 *
 * Return values are:
 *
 * A pointer to the control struct of the next object that needs
 * serialization, if present in one of the percpu reorder queues.
 *
 * -EINPROGRESS, if the next object that needs serialization will
 *  be parallel processed by another cpu and is not yet present in
 *  the cpu's reorder queue.
 *
 * -ENODATA, if this cpu has to do the parallel processing for
 *  the next object.
 */
static struct padata_priv *padata_get_next(struct parallel_data *pd)
{
	int cpu, num_cpus;
	unsigned int next_nr, next_index;
	struct padata_parallel_queue *next_queue;
	struct padata_priv *padata;
	struct padata_list *reorder;

	num_cpus = cpumask_weight(pd->cpumask.pcpu);

	/*
	 * Calculate the percpu reorder queue and the sequence
	 * number of the next object.
	 */
	next_nr = pd->processed;
	next_index = next_nr % num_cpus;
	cpu = padata_index_to_cpu(pd, next_index);
	next_queue = per_cpu_ptr(pd->pqueue, cpu);

	reorder = &next_queue->reorder;

	spin_lock(&reorder->lock);
	if (!list_empty(&reorder->list)) {
		padata = list_entry(reorder->list.next,
				    struct padata_priv, list);

		list_del_init(&padata->list);
		atomic_dec(&pd->reorder_objects);

		pd->processed++;

		spin_unlock(&reorder->lock);
		goto out;
	}
Exemplo n.º 2
0
static int padata_cpu_hash(struct parallel_data *pd)
{
	int cpu_index;


	spin_lock(&pd->seq_lock);
	cpu_index =  pd->seq_nr % cpumask_weight(pd->cpumask.pcpu);
	pd->seq_nr++;
	spin_unlock(&pd->seq_lock);

	return padata_index_to_cpu(pd, cpu_index);
}
Exemplo n.º 3
0
static int padata_cpu_hash(struct padata_priv *padata)
{
	int cpu_index;
	struct parallel_data *pd;

	pd =  padata->pd;

	/*
	 * Hash the sequence numbers to the cpus by taking
	 * seq_nr mod. number of cpus in use.
	 */
	cpu_index =  padata->seq_nr % cpumask_weight(pd->cpumask.pcpu);

	return padata_index_to_cpu(pd, cpu_index);
}
Exemplo n.º 4
0
Arquivo: padata.c Projeto: Lyude/linux
static int padata_cpu_hash(struct parallel_data *pd)
{
	unsigned int seq_nr;
	int cpu_index;

	/*
	 * Hash the sequence numbers to the cpus by taking
	 * seq_nr mod. number of cpus in use.
	 */

	seq_nr = atomic_inc_return(&pd->seq_nr);
	cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);

	return padata_index_to_cpu(pd, cpu_index);
}
Exemplo n.º 5
0
static int padata_cpu_hash(struct parallel_data *pd)
{
	int cpu_index;

	/*
	 * Hash the sequence numbers to the cpus by taking
	 * seq_nr mod. number of cpus in use.
	 */

	spin_lock(&pd->seq_lock);
	cpu_index =  pd->seq_nr % cpumask_weight(pd->cpumask.pcpu);
	pd->seq_nr++;
	spin_unlock(&pd->seq_lock);

	return padata_index_to_cpu(pd, cpu_index);
}