Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1984033imu; Fri, 14 Dec 2018 04:05:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/WjElSIvrqnaVAdixxVED4UpFjZwpr4i0REfPmSB8sn/WWmsyle2d6pcmUnBJOh7TIazk5f X-Received: by 2002:a17:902:b78b:: with SMTP id e11mr2651619pls.90.1544789100665; Fri, 14 Dec 2018 04:05:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789100; cv=none; d=google.com; s=arc-20160816; b=IdoZhir15POzZ4kpu6e+x4LDoBFL4vudHtBPrDUtcCGbhfdriB5wSO4SfwWY4krIy6 E7haW8r+bviXdVsCdO13D/T+/vnikVBffff7I/EP+TIcdh3rECIJNdl0zcgjZ9M2KZur mDXyL0iuOURepKn9TvQ/pPWuPSrj9gWb0MaBSjBi4yIZibfaRT25U9QRUjrJGxrfci42 HAoA5mn9zzF/uSIgG+h4oEzbns4mwwWNyISBDPorD4KSvQfIFE4F6rYDbRJXznZJClSC 3w7ymM/8oogXGjIOrTgRRTLRItlIpndFxgnD0XERdhPxIfa0+np3w3LpBismoc8t5OnG 2SVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gOh+IeB/QVVckeXB6pefdXfC0yP03x1kJynEDtx96ZE=; b=SdOYc6yrWJXgze984rqODc13eZreAkQshT10zDZA4GLQZRv1JK4ImMjuKTVoDbvsLs u07ZezNOpZsPV4wMTeqYr++i7xN1Jrc4/LbVTnTYKmf7g/jxqoW3miLRJ/xMZRD5wG9g tluHmgZScSnh7nmIvE6AZb5Q6M7KG7V2Z87f4+633EnCXJWWnyve09FC40TTY/RTk8hC FqV4/9Od3LRSL6XnfXFDwTK8dZOAeUuPICSnfCK4CodjRU3G7zgMUmJ3n27zueQ5iFrt zM6MY59CN+Pasb4nDsSu9xz78mR4e+dyPhE6DIaBwCfVbu/8CY9Iy6lF+vS0ORihWy09 zH6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uDKwEPfY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si4037851ple.185.2018.12.14.04.04.46; Fri, 14 Dec 2018 04:05:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uDKwEPfY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730159AbeLNMCu (ORCPT + 99 others); Fri, 14 Dec 2018 07:02:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:45818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730125AbeLNMCr (ORCPT ); Fri, 14 Dec 2018 07:02:47 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC32E2145D; Fri, 14 Dec 2018 12:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544788966; bh=FzFZP16ho17kgrSDolqrJ7unx6SjpmR8KxC/Nlmdn64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uDKwEPfYBZJx32d6lGT8MB6XFcVObslGCh9uJ80IXAF4yhGcgEg5BnVeiia11IatE qWzN3TCM22iv403L6mA9JY9y9XBFHqMLd1TKdYBoxwudp8O00T/epe6iEWB51kQvZi GQGDPd2Ipp+/n4+n+xWojtbThg8qX7vS6hujGOio= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yongxin Liu , Jiri Olsa , Adam Lee , Alexander Shishkin , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 041/142] perf tools: Fix crash on synthesizing the unit Date: Fri, 14 Dec 2018 12:58:46 +0100 Message-Id: <20181214115748.694920023@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit fb50c09e923870a358d68b0d58891bd145b8d7c7 ] Adam reported a record command crash for simple session like: $ perf record -e cpu-clock ls with following backtrace: Program received signal SIGSEGV, Segmentation fault. 3543 ev = event_update_event__new(size + 1, PERF_EVENT_UPDATE__UNIT, evsel->id[0]); (gdb) bt #0 perf_event__synthesize_event_update_unit #1 0x000000000051e469 in perf_event__synthesize_extra_attr #2 0x00000000004445cb in record__synthesize #3 0x0000000000444bc5 in __cmd_record ... We synthesize an update event that needs to touch the evsel id array, which is not defined at that time. Fix this by forcing the id allocation for events with their unit defined. Reflecting possible read_format ID bit in the attr tests. Reported-by: Yongxin Liu Signed-off-by: Jiri Olsa Cc: Adam Lee Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201477 Fixes: bfd8f72c2778 ("perf record: Synthesize unit/scale/... in event update") Link: http://lkml.kernel.org/r/20181112130012.5424-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/attr/base-record | 2 +- tools/perf/util/evsel.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record index 37940665f736..efd0157b9d22 100644 --- a/tools/perf/tests/attr/base-record +++ b/tools/perf/tests/attr/base-record @@ -9,7 +9,7 @@ size=112 config=0 sample_period=* sample_type=263 -read_format=0 +read_format=0|4 disabled=1 inherit=1 pinned=0 diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 03a72310315f..e7dbdcc8d465 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1088,7 +1088,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, attr->exclude_user = 1; } - if (evsel->own_cpus) + if (evsel->own_cpus || evsel->unit) evsel->attr.read_format |= PERF_FORMAT_ID; /* -- 2.19.1