From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44075 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751697AbdITMPX (ORCPT ); Wed, 20 Sep 2017 08:15:23 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8KC9Uhe152020 for ; Wed, 20 Sep 2017 08:15:22 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2d3nqrakc0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 20 Sep 2017 08:15:22 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Sep 2017 13:15:21 +0100 Date: Wed, 20 Sep 2017 14:15:17 +0200 From: Heiko Carstens To: Martin Schwidefsky Cc: Paul Burton , linux-s390@vger.kernel.org, Christian Borntraeger , Alexey Dobriyan , Andrew Morton , stable Subject: Re: [PATCH] s390: Fix perf event init References: <20170920050757.22857-1-paul.burton@imgtec.com> <20170920085100.6adb0e0d@mschwideX1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170920085100.6adb0e0d@mschwideX1> Message-Id: <20170920121517.GE3583@osiris> Sender: stable-owner@vger.kernel.org List-ID: On Wed, Sep 20, 2017 at 08:51:00AM +0200, Martin Schwidefsky wrote: > Hi Paul, > > On Tue, 19 Sep 2017 22:07:57 -0700 > Paul Burton wrote: > > > Commit c311c797998c ("cpumask: make "nr_cpumask_bits" unsigned") > > modified cpumsf_pmu_event_init() to cast the struct perf_event cpu field > > to an unsigned integer before it is compared with nr_cpumask_bits. This > > is broken because the cpu field may be -1 for events which follow a > > process rather than being affine to a particular CPU. When this is the > > case the cast to an unsigned int results in a value equal to ULONG_MAX, > > which is always greater than nr_cpumask_bits so we always fail > > cpumsf_pmu_event_init() and return -ENODEV. > > > > The check against nr_cpumask_bits seems nonsensical anyway, so this > > patch simply removes it. The cpu field is going to either be 0 or a I assume you meant to write "...either be -1..."? > > valid CPU number. Comparing it with nr_cpumask_bits is effectively > > checking that it's a valid cpu number, but it seems safe to rely on the > > core perf events code to ensure that's the case. Looks like you are right and the nr_cpumask_bits check is not needed. The sanity check is done at the beginning of perf_event_alloc() and everything else can rely on a sane cpu number (-1 or within bounds of nr_cpumask_bits). > Thanks for the patch, there is indeed an issue with nr_cpumask_bits. > But we already have a slightly different fix for this queued on the > fixes branch of s390/linux: > > https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=fixes&id=fc3100d64f0ae383ae8d845989103da06d62763b So we should either use your patch or remove the superfluous check with an addon patch. Martin's call ;)