Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2593711ybl; Mon, 20 Jan 2020 05:57:49 -0800 (PST) X-Google-Smtp-Source: APXvYqyrH4hGpkKBEmYOatI+SINZGbTvf4+ydWn6hz3SlMwbte1jKVZkg8ciJpolOv+lLuEE2jda X-Received: by 2002:aca:d985:: with SMTP id q127mr12403401oig.132.1579528669563; Mon, 20 Jan 2020 05:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579528669; cv=none; d=google.com; s=arc-20160816; b=g5M7ZV0IZbRkMNaVF3ONKphTrGJSnvq+D1vszKpN5O1O9WzZ09wDm9wYIp1oIvtQ7i XjmK6wd5NRkQL4oe1XFOJprr+DG56dBVWFJoM4IHBaE6cHPcfTkDeIZyvM0ix3h4q1uq oiUIiMUAYHOJ5EXTl2og8m63ORPCFIFzZ/Zfs/Fg943g5Pe1o7fGCwjH/ZhFDh42L1lj nKtuNwMvtKVr/zCGTljbuwuryDvGk0wXE4QJQdt3mb/biQ7QP9mmAdIVgRwFJee/Yi+I HqC77TGjfw+0q7JELdZ67W2UxLZg3u481GyPF/lfHyfhcfcpy7tX0AyY02MB5mrpJsT+ 1cwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=PlQXqnpVxLMcztV+EVSYHFIdWPheSvj4bzBOFgDrl7g=; b=Q4G6H3gGXkxwf2CPOdiLrAlubPN0k6rUK1YubN+4ybbJJQUZ0US3MYGuJNSj4ZPN6L USW/n48XZO3dPtcIC6qQfPVfr3Dp+XYgTUaHTSBavJif53DDOjD0iJ+oCNvUz+qXMYeC vf4oxc6VnVvXCAPyWVp6TA88jtiGNrCt/Myi4EJA0zeGsWI3mUsidGHkEo3lXuewhNDl 7nT1uANF74FF0U00PSztsmKcThPofWqQXrI8vJ/bNfjAo8c+qR3+T4e6+0pjxfuuJ55r FC9ZZNvB+eb1A9Q6Z2nNzpm5sIOe8Aa8VM9WPHcPvql8GS9XEVJgGtTyeuokRs04hhiK gXcg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t130si18138686oib.202.2020.01.20.05.57.38; Mon, 20 Jan 2020 05:57:49 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbgATN4m (ORCPT + 99 others); Mon, 20 Jan 2020 08:56:42 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:8202 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726738AbgATN4m (ORCPT ); Mon, 20 Jan 2020 08:56:42 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00KDIpd3072358 for ; Mon, 20 Jan 2020 08:20:25 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xmgh9s7ty-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 20 Jan 2020 08:20:24 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Jan 2020 13:20:23 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 20 Jan 2020 13:20:20 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00KDKIZA38010888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jan 2020 13:20:18 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA0A3A4068; Mon, 20 Jan 2020 13:20:18 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87267A4054; Mon, 20 Jan 2020 13:20:18 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jan 2020 13:20:18 +0000 (GMT) From: Thomas Richter To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: gor@linux.ibm.com, sumanthk@linux.ibm.com, heiko.carstens@de.ibm.com, Thomas Richter Subject: [PATCH v2] perf probe: Add ustring support for perf probe command Date: Mon, 20 Jan 2020 14:20:10 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200120132011.64698-1-tmricht@linux.ibm.com> References: <20200120132011.64698-1-tmricht@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20012013-0016-0000-0000-000002DF123B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20012013-0017-0000-0000-00003341B5FD Message-Id: <20200120132011.64698-2-tmricht@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-20_02:2020-01-20,2020-01-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001200115 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kernel commit 88903c464321 ("tracing/probe: Add ustring type for user-space string") adds support for user-space strings when type 'ustring' is specified. Here is an example using sysfs command line interface for kprobes: Function to probe: struct filename * getname_flags(const char __user *filename, int flags, int *empty) Setup: # cd /sys/kernel/debug/tracing/ # echo 'p:tmr1 getname_flags +0(%r2):ustring' > kprobe_events # cat events/kprobes/tmr1/format | fgrep print print fmt: "(%lx) arg1=\"%s\"", REC->__probe_ip, REC->arg1 # echo 1 > events/kprobes/tmr1/enable # touch /tmp/111 # echo 0 > events/kprobes/tmr1/enable # cat trace|fgrep /tmp/111 touch-5846 [005] d..2 255520.717960: tmr1:\ (getname_flags+0x0/0x400) arg1="/tmp/111" Doing the same with the perf tool fails. Using type 'string' succeeds: # perf probe "vfs_getname=getname_flags:72 pathname=filename:string" Added new event: probe:vfs_getname (on getname_flags:72 with pathname=filename:string) .... # perf probe -d probe:vfs_getname Removed event: probe:vfs_getname However using type 'ustring' fails (output before): # perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring" Failed to write event: Invalid argument Error: Failed to add events. # Fix this by adding type 'ustring' in function convert_variable_type(). Using ustring succeeds (output after): # ./perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring" Added new event: probe:vfs_getname (on getname_flags:72 with pathname=filename:ustring) You can now use it in all perf tools, such as: perf record -e probe:vfs_getname -aR sleep 1 # Note: This issue also exists on x86, it is not s390 specific. Signed-off-by: Thomas Richter --- tools/perf/util/probe-finder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index c470c49a804f..1c817add6ca4 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -303,7 +303,8 @@ static int convert_variable_type(Dwarf_Die *vr_die, char prefix; /* TODO: check all types */ - if (cast && strcmp(cast, "string") != 0 && strcmp(cast, "x") != 0 && + if (cast && strcmp(cast, "string") != 0 && strcmp(cast, "ustring") && + strcmp(cast, "x") != 0 && strcmp(cast, "s") != 0 && strcmp(cast, "u") != 0) { /* Non string type is OK */ /* and respect signedness/hexadecimal cast */ -- 2.21.0