Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2303591imc; Tue, 12 Mar 2019 10:59:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQXAsr7XKA+tsFtCjHv/1ScnO7X0QHWC709B67+Oc9owywD2Z3z2IF7jR3XxSPpHExwhfW X-Received: by 2002:a63:7444:: with SMTP id e4mr36484825pgn.398.1552413583322; Tue, 12 Mar 2019 10:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552413583; cv=none; d=google.com; s=arc-20160816; b=dqCvc9YRp1gsJPZWIAaoMT2JjhXFxf6wdHaoBy35AUVfmc9hw2cJU/7bfrgS3NwGgi VqEAjHEeyiAmgzaLwOFuIdHObnfIEpsBiOCPiv1Z7ABcdk9SDg8bbAFulWjzG9sd1D/x +wKcLNzgtAwCMaCNN4ivpVY8ktyXiVT4pK6nP74iW3fRIrXXgGtBtQuiGhBGhbSAHwMT oDR1At8Lep88EXZ/FEZUIFCDJXAGSXlfDtv5U7vb6Hr/UIbsXMmsIjNB0tBfLrYdSvYj KU42IaEOHjwhjk3+tTdDahY5ZZ6Uod8mwi1p8hokCKBVk4XZfMS3/Hln7LRGqzMOmgTv 8kYA== 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=gmHsn+oLMzCqOSwVWqpBkkvVvzvjihQnnoWDN99PQ3k=; b=xpC6Dz9dLsnkES/QVW3FA4lMN8t/F7rSKmMZsOURJ24FixtUL7IcPPytTp9M41O63R Oiq8X/VOPWB/6MIJDsa8EHmfs2FQEX7GuQIiQzUxo3JRRPKLJQT+IbaDaxU2Ee3z+9/N ciym8TTfZ3PSBNKUlq5iSddttDpqCx8ETncwxcsiaNpBW099HwjQJqBnRBsHTUZdJzxL jVSVFYPEN7vPlyqxjTYFvHkP4l+B9sODfMAUbwufmTGd8zBYKWuIAzhdcDynNtQ2iy5C v/+Ybvun2kVgFNhOwvPSEXbcC1SsrnYQWpiM179z1k40z+8DZiwgNRlSOpxEgiwQbwGI f8fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MiQKmgAB; 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 m26si8194114pfi.247.2019.03.12.10.59.27; Tue, 12 Mar 2019 10:59:43 -0700 (PDT) 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=MiQKmgAB; 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 S1728211AbfCLR5f (ORCPT + 99 others); Tue, 12 Mar 2019 13:57:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:51214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbfCLRNr (ORCPT ); Tue, 12 Mar 2019 13:13:47 -0400 Received: from localhost (unknown [104.133.8.98]) (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 91D3B2171F; Tue, 12 Mar 2019 17:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552410826; bh=XKj66m+DyBjCG7lfEMwPn0WIxoJIiBrLCxnJZ4p5gp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MiQKmgABS9/sJOKwSxxteb98fgYBibN+1JRKYl4dw6lDPwy7Vkqr0O+0qFJeh2xDx Z587nv+PWYWYTloXpA+doz1/yd6PCXqc97iwpG3fOLiXkpjeJCklDbFvLHIRhrt1ST 37t5/OHt5OsJ3tDSkzAcUKWDXjr/WSkGP+G5vhXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Arnaldo Carvalho de Melo , Jiri Olsa , Sasha Levin Subject: [PATCH 4.19 003/149] perf script: Fix crash with printing mixed trace point and other events Date: Tue, 12 Mar 2019 10:07:01 -0700 Message-Id: <20190312170349.735068011@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170349.421581206@linuxfoundation.org> References: <20190312170349.421581206@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 96167167b6e17b25c0e05ecc31119b73baeab094 ] 'perf script' crashes currently when printing mixed trace points and other events because the trace format does not handle events without trace meta data. Add a simple check to avoid that. % cat > test.c main() { printf("Hello world\n"); } ^D % gcc -g -o test test.c % sudo perf probe -x test 'test.c:3' % perf record -e '{cpu/cpu-cycles,period=10000/,probe_test:main}:S' ./test % perf script Committer testing: Before: # perf probe -x /lib64/libc-2.28.so malloc Added new event: probe_libc:malloc (on malloc in /usr/lib64/libc-2.28.so) You can now use it in all perf tools, such as: perf record -e probe_libc:malloc -aR sleep 1 # perf probe -l probe_libc:malloc (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.28.so) # perf record -e '{cpu/cpu-cycles,period=10000/,probe_libc:*}:S' sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.023 MB perf.data (40 samples) ] # perf script Segmentation fault (core dumped) ^C # After: # perf script | head -6 sleep 2888 94796.944981: 16198 cpu/cpu-cycles,period=10000/: ffffffff925dc04f get_random_u32+0x1f (/lib/modules/5.0.0-rc2+/build/vmlinux) sleep 2888 [-01] 94796.944981: probe_libc:malloc: sleep 2888 94796.944983: 4713 cpu/cpu-cycles,period=10000/: ffffffff922763af change_protection+0xcf (/lib/modules/5.0.0-rc2+/build/vmlinux) sleep 2888 [-01] 94796.944983: probe_libc:malloc: sleep 2888 94796.944986: 9934 cpu/cpu-cycles,period=10000/: ffffffff922777e0 move_page_tables+0x0 (/lib/modules/5.0.0-rc2+/build/vmlinux) sleep 2888 [-01] 94796.944986: probe_libc:malloc: # Signed-off-by: Andi Kleen Tested-by: Arnaldo Carvalho de Melo Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20190117194834.21940-1-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6c1e7ceedcf3..ce2aee11e360 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1658,7 +1658,7 @@ static void process_event(struct perf_script *script, return; } - if (PRINT_FIELD(TRACE)) { + if (PRINT_FIELD(TRACE) && sample->raw_data) { event_format__fprintf(evsel->tp_format, sample->cpu, sample->raw_data, sample->raw_size, fp); } -- 2.19.1