diff options
author | Steffen Klassert <steffen.klassert@secunet.com> | 2010-07-27 01:15:06 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-07-31 07:53:04 -0400 |
commit | 65ff577e6b6e482ee9de3569e058edebdc02f069 (patch) | |
tree | 590390375fd44b9c1be49e677a68539883a0463f | |
parent | e6cc11707661770ca2bd4db4b0256d28f48e7541 (diff) |
padata: Rearrange set_cpumask functions
padata_set_cpumask needs to be protected by a lock. We make
__padata_set_cpumasks unlocked and static. So this function
can be used by the exported and locked padata_set_cpumask and
padata_set_cpumasks functions.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | include/linux/padata.h | 6 | ||||
-rw-r--r-- | kernel/padata.c | 117 |
2 files changed, 70 insertions, 53 deletions
diff --git a/include/linux/padata.h b/include/linux/padata.h index 71dfc9d1f856..bb0fc5dd0bbb 100644 --- a/include/linux/padata.h +++ b/include/linux/padata.h | |||
@@ -178,9 +178,9 @@ extern int padata_get_cpumask(struct padata_instance *pinst, | |||
178 | int cpumask_type, struct cpumask *out_mask); | 178 | int cpumask_type, struct cpumask *out_mask); |
179 | extern int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, | 179 | extern int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, |
180 | cpumask_var_t cpumask); | 180 | cpumask_var_t cpumask); |
181 | extern int __padata_set_cpumasks(struct padata_instance *pinst, | 181 | extern int padata_set_cpumasks(struct padata_instance *pinst, |
182 | cpumask_var_t pcpumask, | 182 | cpumask_var_t pcpumask, |
183 | cpumask_var_t cbcpumask); | 183 | cpumask_var_t cbcpumask); |
184 | extern int padata_add_cpu(struct padata_instance *pinst, int cpu, int mask); | 184 | extern int padata_add_cpu(struct padata_instance *pinst, int cpu, int mask); |
185 | extern int padata_remove_cpu(struct padata_instance *pinst, int cpu, int mask); | 185 | extern int padata_remove_cpu(struct padata_instance *pinst, int cpu, int mask); |
186 | extern int padata_start(struct padata_instance *pinst); | 186 | extern int padata_start(struct padata_instance *pinst); |
diff --git a/kernel/padata.c b/kernel/padata.c index 12860bce6b78..4987203770bc 100644 --- a/kernel/padata.c +++ b/kernel/padata.c | |||
@@ -623,6 +623,66 @@ int padata_get_cpumask(struct padata_instance *pinst, | |||
623 | } | 623 | } |
624 | EXPORT_SYMBOL(padata_get_cpumask); | 624 | EXPORT_SYMBOL(padata_get_cpumask); |
625 | 625 | ||
626 | static int __padata_set_cpumasks(struct padata_instance *pinst, | ||
627 | cpumask_var_t pcpumask, | ||
628 | cpumask_var_t cbcpumask) | ||
629 | { | ||
630 | int valid; | ||
631 | struct parallel_data *pd; | ||
632 | |||
633 | valid = padata_validate_cpumask(pinst, pcpumask); | ||
634 | if (!valid) { | ||
635 | __padata_stop(pinst); | ||
636 | goto out_replace; | ||
637 | } | ||
638 | |||
639 | valid = padata_validate_cpumask(pinst, cbcpumask); | ||
640 | if (!valid) | ||
641 | __padata_stop(pinst); | ||
642 | |||
643 | out_replace: | ||
644 | pd = padata_alloc_pd(pinst, pcpumask, cbcpumask); | ||
645 | if (!pd) | ||
646 | return -ENOMEM; | ||
647 | |||
648 | cpumask_copy(pinst->cpumask.pcpu, pcpumask); | ||
649 | cpumask_copy(pinst->cpumask.cbcpu, cbcpumask); | ||
650 | |||
651 | padata_replace(pinst, pd); | ||
652 | |||
653 | if (valid) | ||
654 | __padata_start(pinst); | ||
655 | |||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | /** | ||
660 | * padata_set_cpumasks - Set both parallel and serial cpumasks. The first | ||
661 | * one is used by parallel workers and the second one | ||
662 | * by the wokers doing serialization. | ||
663 | * | ||
664 | * @pinst: padata instance | ||
665 | * @pcpumask: the cpumask to use for parallel workers | ||
666 | * @cbcpumask: the cpumsak to use for serial workers | ||
667 | */ | ||
668 | int padata_set_cpumasks(struct padata_instance *pinst, cpumask_var_t pcpumask, | ||
669 | cpumask_var_t cbcpumask) | ||
670 | { | ||
671 | int err; | ||
672 | |||
673 | mutex_lock(&pinst->lock); | ||
674 | get_online_cpus(); | ||
675 | |||
676 | err = __padata_set_cpumasks(pinst, pcpumask, cbcpumask); | ||
677 | |||
678 | put_online_cpus(); | ||
679 | mutex_unlock(&pinst->lock); | ||
680 | |||
681 | return err; | ||
682 | |||
683 | } | ||
684 | EXPORT_SYMBOL(padata_set_cpumasks); | ||
685 | |||
626 | /** | 686 | /** |
627 | * padata_set_cpumask: Sets specified by @cpumask_type cpumask to the value | 687 | * padata_set_cpumask: Sets specified by @cpumask_type cpumask to the value |
628 | * equivalent to @cpumask. | 688 | * equivalent to @cpumask. |
@@ -636,6 +696,10 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, | |||
636 | cpumask_var_t cpumask) | 696 | cpumask_var_t cpumask) |
637 | { | 697 | { |
638 | struct cpumask *serial_mask, *parallel_mask; | 698 | struct cpumask *serial_mask, *parallel_mask; |
699 | int err = -EINVAL; | ||
700 | |||
701 | mutex_lock(&pinst->lock); | ||
702 | get_online_cpus(); | ||
639 | 703 | ||
640 | switch (cpumask_type) { | 704 | switch (cpumask_type) { |
641 | case PADATA_CPU_PARALLEL: | 705 | case PADATA_CPU_PARALLEL: |
@@ -647,65 +711,18 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, | |||
647 | serial_mask = cpumask; | 711 | serial_mask = cpumask; |
648 | break; | 712 | break; |
649 | default: | 713 | default: |
650 | return -EINVAL; | 714 | goto out; |
651 | } | 715 | } |
652 | 716 | ||
653 | return __padata_set_cpumasks(pinst, parallel_mask, serial_mask); | 717 | err = __padata_set_cpumasks(pinst, parallel_mask, serial_mask); |
654 | } | ||
655 | EXPORT_SYMBOL(padata_set_cpumask); | ||
656 | |||
657 | /** | ||
658 | * __padata_set_cpumasks - Set both parallel and serial cpumasks. The first | ||
659 | * one is used by parallel workers and the second one | ||
660 | * by the wokers doing serialization. | ||
661 | * | ||
662 | * @pinst: padata instance | ||
663 | * @pcpumask: the cpumask to use for parallel workers | ||
664 | * @cbcpumask: the cpumsak to use for serial workers | ||
665 | */ | ||
666 | int __padata_set_cpumasks(struct padata_instance *pinst, | ||
667 | cpumask_var_t pcpumask, cpumask_var_t cbcpumask) | ||
668 | { | ||
669 | int valid; | ||
670 | int err = 0; | ||
671 | struct parallel_data *pd = NULL; | ||
672 | |||
673 | mutex_lock(&pinst->lock); | ||
674 | get_online_cpus(); | ||
675 | |||
676 | valid = padata_validate_cpumask(pinst, pcpumask); | ||
677 | if (!valid) { | ||
678 | __padata_stop(pinst); | ||
679 | goto out_replace; | ||
680 | } | ||
681 | |||
682 | valid = padata_validate_cpumask(pinst, cbcpumask); | ||
683 | if (!valid) | ||
684 | __padata_stop(pinst); | ||
685 | |||
686 | out_replace: | ||
687 | pd = padata_alloc_pd(pinst, pcpumask, cbcpumask); | ||
688 | if (!pd) { | ||
689 | err = -ENOMEM; | ||
690 | goto out; | ||
691 | } | ||
692 | |||
693 | cpumask_copy(pinst->cpumask.pcpu, pcpumask); | ||
694 | cpumask_copy(pinst->cpumask.cbcpu, cbcpumask); | ||
695 | |||
696 | padata_replace(pinst, pd); | ||
697 | |||
698 | if (valid) | ||
699 | __padata_start(pinst); | ||
700 | 718 | ||
701 | out: | 719 | out: |
702 | put_online_cpus(); | 720 | put_online_cpus(); |
703 | mutex_unlock(&pinst->lock); | 721 | mutex_unlock(&pinst->lock); |
704 | 722 | ||
705 | return err; | 723 | return err; |
706 | |||
707 | } | 724 | } |
708 | EXPORT_SYMBOL(__padata_set_cpumasks); | 725 | EXPORT_SYMBOL(padata_set_cpumask); |
709 | 726 | ||
710 | static int __padata_add_cpu(struct padata_instance *pinst, int cpu) | 727 | static int __padata_add_cpu(struct padata_instance *pinst, int cpu) |
711 | { | 728 | { |