Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 204347
b: refs/heads/master
c: 33e5445
h: refs/heads/master
i:
  204345: 029872c
  204343: da9d2b6
v: v3
  • Loading branch information
Steffen Klassert authored and Herbert Xu committed Jul 14, 2010
1 parent cc690ce commit e973d9f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 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: ee836555120140f770005b8ce6673c913d1b9a98
refs/heads/master: 33e54450683c5e970ac007489d7921ba792d093c
61 changes: 50 additions & 11 deletions trunk/kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,27 @@ static void padata_replace(struct padata_instance *pinst,

synchronize_rcu();

padata_flush_queues(pd_old);
padata_free_pd(pd_old);
if (pd_old) {
padata_flush_queues(pd_old);
padata_free_pd(pd_old);
}

pinst->flags &= ~PADATA_RESET;
}

/* If cpumask contains no active cpu, we mark the instance as invalid. */
static bool padata_validate_cpumask(struct padata_instance *pinst,
const struct cpumask *cpumask)
{
if (!cpumask_intersects(cpumask, cpu_active_mask)) {
pinst->flags |= PADATA_INVALID;
return false;
}

pinst->flags &= ~PADATA_INVALID;
return true;
}

/**
* padata_set_cpumask - set the cpumask that padata should use
*
Expand All @@ -531,11 +546,18 @@ static void padata_replace(struct padata_instance *pinst,
int padata_set_cpumask(struct padata_instance *pinst,
cpumask_var_t cpumask)
{
struct parallel_data *pd;
int valid;
int err = 0;
struct parallel_data *pd = NULL;

mutex_lock(&pinst->lock);

valid = padata_validate_cpumask(pinst, cpumask);
if (!valid) {
__padata_stop(pinst);
goto out_replace;
}

get_online_cpus();

pd = padata_alloc_pd(pinst, cpumask);
Expand All @@ -544,10 +566,14 @@ int padata_set_cpumask(struct padata_instance *pinst,
goto out;
}

out_replace:
cpumask_copy(pinst->cpumask, cpumask);

padata_replace(pinst, pd);

if (valid)
__padata_start(pinst);

out:
put_online_cpus();

Expand All @@ -567,6 +593,9 @@ static int __padata_add_cpu(struct padata_instance *pinst, int cpu)
return -ENOMEM;

padata_replace(pinst, pd);

if (padata_validate_cpumask(pinst, pinst->cpumask))
__padata_start(pinst);
}

return 0;
Expand Down Expand Up @@ -597,16 +626,24 @@ EXPORT_SYMBOL(padata_add_cpu);

static int __padata_remove_cpu(struct padata_instance *pinst, int cpu)
{
struct parallel_data *pd;
struct parallel_data *pd = NULL;

if (cpumask_test_cpu(cpu, cpu_online_mask)) {

if (!padata_validate_cpumask(pinst, pinst->cpumask)) {
__padata_stop(pinst);
padata_replace(pinst, pd);
goto out;
}

pd = padata_alloc_pd(pinst, pinst->cpumask);
if (!pd)
return -ENOMEM;

padata_replace(pinst, pd);
}

out:
return 0;
}

Expand Down Expand Up @@ -732,20 +769,22 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask,
struct workqueue_struct *wq)
{
struct padata_instance *pinst;
struct parallel_data *pd;
struct parallel_data *pd = NULL;

pinst = kzalloc(sizeof(struct padata_instance), GFP_KERNEL);
if (!pinst)
goto err;

get_online_cpus();

pd = padata_alloc_pd(pinst, cpumask);
if (!pd)
if (!alloc_cpumask_var(&pinst->cpumask, GFP_KERNEL))
goto err_free_inst;

if (!alloc_cpumask_var(&pinst->cpumask, GFP_KERNEL))
goto err_free_pd;
if (padata_validate_cpumask(pinst, cpumask)) {
pd = padata_alloc_pd(pinst, cpumask);
if (!pd)
goto err_free_mask;
}

rcu_assign_pointer(pinst->pd, pd);

Expand All @@ -767,8 +806,8 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask,

return pinst;

err_free_pd:
padata_free_pd(pd);
err_free_mask:
free_cpumask_var(pinst->cpumask);
err_free_inst:
kfree(pinst);
put_online_cpus();
Expand Down

0 comments on commit e973d9f

Please sign in to comment.