All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf s390: Fix bug when creating per-thread event
@ 2017-09-12 10:24 Pu Hou
  2017-09-12 10:34 ` Pu Hou
  0 siblings, 1 reply; 2+ messages in thread
From: Pu Hou @ 2017-09-12 10:24 UTC (permalink / raw)
  To: bjhoupu; +Cc: stable, Alexey Dobriyan

A per-thread event could not be created correctly like below:

    perf record --per-thread -e rB0000 -- sleep 1
    Error:
    The sys_perf_event_open() syscall returned with 19 (No such device) for event (rB0000).
    /bin/dmesg may provide additional information.
    No CONFIG_PERF_EVENTS=y kernel support configured?

This bug was introduced by:

    commit c311c797998c1e70eade463dd60b843da4f1a203
    Author: Alexey Dobriyan <adobriyan@gmail.com>
    Date:   Mon May 8 15:56:15 2017 -0700

    cpumask: make "nr_cpumask_bits" unsigned

If a per-thread event is not attached to any CPU, the cpu field
in struct perf_event is -1. The above commit converts the CPU number
to unsigned int, which result in an illegal CPU number.

Fixes: c311c797998c ("cpumask: make "nr_cpumask_bits" unsigned")
Cc: <stable@vger.kernel.org> # v4.12+
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Pu Hou <bjhoupu@linux.vnet.ibm.com>
---
 arch/s390/kernel/perf_cpum_sf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index c1bf75f..69be2c6 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -823,8 +823,9 @@ static int cpumsf_pmu_event_init(struct perf_event *event)
 	}
 
 	/* Check online status of the CPU to which the event is pinned */
-	if ((unsigned int)event->cpu >= nr_cpumask_bits ||
-	    (event->cpu >= 0 && !cpu_online(event->cpu)))
+	if (event->cpu >= 0 &&
+	    ((unsigned int)event->cpu >= nr_cpumask_bits ||
+	     !cpu_online(event->cpu)))
 		return -ENODEV;
 
 	/* Force reset of idle/hv excludes regardless of what the
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf s390: Fix bug when creating per-thread event
  2017-09-12 10:24 [PATCH] perf s390: Fix bug when creating per-thread event Pu Hou
@ 2017-09-12 10:34 ` Pu Hou
  0 siblings, 0 replies; 2+ messages in thread
From: Pu Hou @ 2017-09-12 10:34 UTC (permalink / raw)
  Cc: stable, Alexey Dobriyan

Dears,

Sorry, please ignore this mail.

On 12/09/2017 6:24 PM, Pu Hou wrote:
> A per-thread event could not be created correctly like below:
> 
>      perf record --per-thread -e rB0000 -- sleep 1
>      Error:
>      The sys_perf_event_open() syscall returned with 19 (No such device) for event (rB0000).
>      /bin/dmesg may provide additional information.
>      No CONFIG_PERF_EVENTS=y kernel support configured?
> 
> This bug was introduced by:
> 
>      commit c311c797998c1e70eade463dd60b843da4f1a203
>      Author: Alexey Dobriyan <adobriyan@gmail.com>
>      Date:   Mon May 8 15:56:15 2017 -0700
> 
>      cpumask: make "nr_cpumask_bits" unsigned
> 
> If a per-thread event is not attached to any CPU, the cpu field
> in struct perf_event is -1. The above commit converts the CPU number
> to unsigned int, which result in an illegal CPU number.
> 
> Fixes: c311c797998c ("cpumask: make "nr_cpumask_bits" unsigned")
> Cc: <stable@vger.kernel.org> # v4.12+
> Cc: Alexey Dobriyan <adobriyan@gmail.com>
> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Pu Hou <bjhoupu@linux.vnet.ibm.com>
> ---
>   arch/s390/kernel/perf_cpum_sf.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index c1bf75f..69be2c6 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -823,8 +823,9 @@ static int cpumsf_pmu_event_init(struct perf_event *event)
>   	}
> 
>   	/* Check online status of the CPU to which the event is pinned */
> -	if ((unsigned int)event->cpu >= nr_cpumask_bits ||
> -	    (event->cpu >= 0 && !cpu_online(event->cpu)))
> +	if (event->cpu >= 0 &&
> +	    ((unsigned int)event->cpu >= nr_cpumask_bits ||
> +	     !cpu_online(event->cpu)))
>   		return -ENODEV;
> 
>   	/* Force reset of idle/hv excludes regardless of what the
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-12 10:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 10:24 [PATCH] perf s390: Fix bug when creating per-thread event Pu Hou
2017-09-12 10:34 ` Pu Hou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.