Return-Path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54444 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751289AbdILKfF (ORCPT ); Tue, 12 Sep 2017 06:35:05 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8CAYSH4077782 for ; Tue, 12 Sep 2017 06:35:05 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cx8bu2ks2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 12 Sep 2017 06:35:04 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Sep 2017 06:35:03 -0400 Subject: Re: [PATCH] perf s390: Fix bug when creating per-thread event Cc: stable@vger.kernel.org, Alexey Dobriyan References: <20170912102437.908-1-bjhoupu@linux.vnet.ibm.com> From: Pu Hou Date: Tue, 12 Sep 2017 18:34:58 +0800 MIME-Version: 1.0 In-Reply-To: <20170912102437.908-1-bjhoupu@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Message-Id: To: unlisted-recipients:; (no To-header on input) Sender: stable-owner@vger.kernel.org List-ID: 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 > 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: # v4.12+ > Cc: Alexey Dobriyan > Acked-by: Heiko Carstens > Signed-off-by: Pu Hou > --- > 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 >