Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 196730
b: refs/heads/master
c: d46a5ac
h: refs/heads/master
v: v3
  • Loading branch information
Steffen Klassert authored and Herbert Xu committed May 19, 2010
1 parent b29795c commit 75b90ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 18eb8ea6ee4cc9ed39b45f95b734f523bcfb586b
refs/heads/master: d46a5ac7a7e2045e33c6ad6ffb8cf18a7e86a15a
2 changes: 2 additions & 0 deletions trunk/include/linux/padata.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/timer.h>

struct padata_priv {
struct list_head list;
Expand Down Expand Up @@ -60,6 +61,7 @@ struct parallel_data {
unsigned int max_seq_nr;
cpumask_var_t cpumask;
spinlock_t lock;
struct timer_list timer;
};

struct padata_instance {
Expand Down
25 changes: 18 additions & 7 deletions trunk/kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ static struct padata_priv *padata_get_next(struct parallel_data *pd)
goto out;
}

if (next_nr % num_cpus == next_queue->cpu_index) {
queue = per_cpu_ptr(pd->queue, smp_processor_id());
if (queue->cpu_index == next_queue->cpu_index) {
padata = ERR_PTR(-ENODATA);
goto out;
}
Expand All @@ -247,9 +248,8 @@ static void padata_reorder(struct parallel_data *pd)
struct padata_queue *queue;
struct padata_instance *pinst = pd->pinst;

try_again:
if (!spin_trylock_bh(&pd->lock))
goto out;
return;

while (1) {
padata = padata_get_next(pd);
Expand All @@ -258,8 +258,9 @@ static void padata_reorder(struct parallel_data *pd)
break;

if (PTR_ERR(padata) == -ENODATA) {
del_timer(&pd->timer);
spin_unlock_bh(&pd->lock);
goto out;
return;
}

queue = per_cpu_ptr(pd->queue, padata->cb_cpu);
Expand All @@ -273,13 +274,22 @@ static void padata_reorder(struct parallel_data *pd)

spin_unlock_bh(&pd->lock);

if (atomic_read(&pd->reorder_objects))
goto try_again;
if (atomic_read(&pd->reorder_objects)
&& !(pinst->flags & PADATA_RESET))
mod_timer(&pd->timer, jiffies + HZ);
else
del_timer(&pd->timer);

out:
return;
}

static void padata_reorder_timer(unsigned long arg)
{
struct parallel_data *pd = (struct parallel_data *)arg;

padata_reorder(pd);
}

static void padata_serial_worker(struct work_struct *work)
{
struct padata_queue *queue;
Expand Down Expand Up @@ -383,6 +393,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
num_cpus = cpumask_weight(pd->cpumask);
pd->max_seq_nr = (MAX_SEQ_NR / num_cpus) * num_cpus - 1;

setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
atomic_set(&pd->seq_nr, -1);
atomic_set(&pd->reorder_objects, 0);
atomic_set(&pd->refcnt, 0);
Expand Down

0 comments on commit 75b90ec

Please sign in to comment.