diff mbox series

powerpc/xive: Use cpumask_intersects()

Message ID 20240906174941.1147197-2-costa.shul@redhat.com (mailing list archive)
State New
Headers show
Series powerpc/xive: Use cpumask_intersects() | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 5 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 21 jobs.

Commit Message

Costa Shulyupin Sept. 6, 2024, 5:49 p.m. UTC
Replace `cpumask_any_and(a, b) >= nr_cpu_ids`
with the more readable `!cpumask_intersects(a, b)`.

Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
 arch/powerpc/sysdev/xive/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ming Lei Sept. 7, 2024, 1:36 a.m. UTC | #1
On Sat, Sep 7, 2024 at 1:50 AM Costa Shulyupin <costa.shul@redhat.com> wrote:
>
> Replace `cpumask_any_and(a, b) >= nr_cpu_ids`
> with the more readable `!cpumask_intersects(a, b)`.
>
> Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
> ---
>  arch/powerpc/sysdev/xive/common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
> index fa01818c1972c..a6c388bdf5d08 100644
> --- a/arch/powerpc/sysdev/xive/common.c
> +++ b/arch/powerpc/sysdev/xive/common.c
> @@ -726,7 +726,7 @@ static int xive_irq_set_affinity(struct irq_data *d,
>         pr_debug("%s: irq %d/0x%x\n", __func__, d->irq, hw_irq);
>
>         /* Is this valid ? */
> -       if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids)
> +       if (!cpumask_intersects(cpumask, cpu_online_mask))
>                 return -EINVAL;

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Michael Ellerman Sept. 9, 2024, 5:28 a.m. UTC | #2
Costa Shulyupin <costa.shul@redhat.com> writes:
> Replace `cpumask_any_and(a, b) >= nr_cpu_ids`
> with the more readable `!cpumask_intersects(a, b)`.

I agree it's more readable.

It would be nice if the change log told me that both functions have
similar performance behaviour. I'm not saying this is a super hot path,
but CPU masks can get pretty big, and some cpumask routines compute the
full mask while others short-circuit.

cheers

> diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
> index fa01818c1972c..a6c388bdf5d08 100644
> --- a/arch/powerpc/sysdev/xive/common.c
> +++ b/arch/powerpc/sysdev/xive/common.c
> @@ -726,7 +726,7 @@ static int xive_irq_set_affinity(struct irq_data *d,
>  	pr_debug("%s: irq %d/0x%x\n", __func__, d->irq, hw_irq);
>  
>  	/* Is this valid ? */
> -	if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids)
> +	if (!cpumask_intersects(cpumask, cpu_online_mask))
>  		return -EINVAL;
>  
>  	/*
> -- 
> 2.45.0
diff mbox series

Patch

diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index fa01818c1972c..a6c388bdf5d08 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -726,7 +726,7 @@  static int xive_irq_set_affinity(struct irq_data *d,
 	pr_debug("%s: irq %d/0x%x\n", __func__, d->irq, hw_irq);
 
 	/* Is this valid ? */
-	if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids)
+	if (!cpumask_intersects(cpumask, cpu_online_mask))
 		return -EINVAL;
 
 	/*