Received: by 10.223.185.116 with SMTP id b49csp5887341wrg; Tue, 27 Feb 2018 23:54:17 -0800 (PST) X-Google-Smtp-Source: AG47ELvelx/ntSlJ2tZH+fLYi1IYAadYyOQc8tuMfuuJcc6DCa7hCQDelXF91B52/ov8viKRW/kl X-Received: by 2002:a17:902:538f:: with SMTP id c15-v6mr8922226pli.90.1519804457072; Tue, 27 Feb 2018 23:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519804457; cv=none; d=google.com; s=arc-20160816; b=q8+vfM1bAnsEeCBdRqzdvvXMLcnF9Mg2ts7e9t5B5rB22oOcKVYl0jumPwoHAb6LPD 0GdEvvqeIlJ5dX5Kwyd1PJzNY85YcAqTAgKGgFMCJcutcB8KKYVSdkyEnp2bHHftVI/d 2LFky/RD+VzaUhJhfgmg/0x5MAd4CfMO/qDqD16AN75GA+Iw56Y1IcCvw136qJw/bugK 5SxY9bPi2th5W09AV9MUDc0uHn5HNVdXWfDL5HXT70ZaOFqCfhS1zP2txpeBtuu2G4yh 56B/C133Yt9j5qOYyRT5KfR3xuKTsCSCcaAUb684cSwhn3TyxdHqmVW2jgSycPCYfN/r HDEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vGBGouwTpzaltON+8sN+f/9bDq1RYtaaDs4ptkyldW4=; b=YOe29qG9O+FwN+tFqxCUXlycsZ9x7wPGvNvyYuvWzYIhls9Dw4BUQMP09fKaAaDYc6 Ga2x6th6KDMzxKVQzmDVht/4YanpG3shTv+/9ZxRxDy4zuQKSW5uHoVeQrnNfDkMO71S cuCWhNrTg+gl3tF/ySz4ChbpA9m6pJZSmI57eRt9BsYdosOXvydL5hC2Yd0WZG43Ab2B g4B3J+JjxuYWvfRs4caDSSiGLJmxzY1QpnLbPFCzWnZ6VAdrvppZMzkLC7HPkfSI3uFT II6SX8Su+SnK/2/vnsMfE+qoBz18w3C//HwfOGaf8S/5LXfMbc12O/dWdQorszErNqLh TpoA== 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 p9-v6si882900plr.622.2018.02.27.23.54.02; Tue, 27 Feb 2018 23:54:17 -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 S1752084AbeB1Hvt (ORCPT + 99 others); Wed, 28 Feb 2018 02:51:49 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50508 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751646AbeB1Hvr (ORCPT ); Wed, 28 Feb 2018 02:51:47 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1S7p563138852 for ; Wed, 28 Feb 2018 02:51:47 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gdm170cyq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Feb 2018 02:51:47 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Feb 2018 07:51:44 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 28 Feb 2018 07:51:41 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1S7peVm66388202; Wed, 28 Feb 2018 07:51:40 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50FC7A4040; Wed, 28 Feb 2018 07:44:44 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F47FA4051; Wed, 28 Feb 2018 07:44:42 +0000 (GMT) Received: from bangoria.in.ibm.com (unknown [9.124.31.161]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Feb 2018 07:44:41 +0000 (GMT) From: Ravi Bangoria To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, ananth@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com, srikar@linux.vnet.ibm.com, oleg@redhat.com Cc: Ravi Bangoria Subject: [RFC 0/4] trace_uprobe: Support SDT markers having semaphore Date: Wed, 28 Feb 2018 13:23:41 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18022807-0012-0000-0000-000005B64D57 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022807-0013-0000-0000-000019325B28 Message-Id: <20180228075345.674-1-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-28_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802280094 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Userspace Statically Defined Tracepoints[1] are dtrace style markers inside userspace applications. These markers are added by developer at important places in the code. Each marker source expands to a single nop instruction in the compiled code but there may be additional overhead for computing the marker arguments which expands to couple of instructions. If this computaion is quite more, execution of it can be ommited by runtime if() condition when no one is tracing on the marker: if (semaphore > 0) { Execute marker instructions; } Default value of semaphore is 0. Tracer has to increment the semaphore before recording on a marker and decrement it at the end of tracing. Currently, perf tool has limited supports for SDT markers. I.e. it can not trace markers surrounded by semaphore. Also, it's not easy to add semaphore flip logic in userspace tool like perf, so basic idea for this patchset is to add semaphore flip logic in the trace_uprobe infrastructure. Ex,[2] # cat tick.c ... for (i = 0; i < 100; i++) { DTRACE_PROBE1(tick, loop1, i); if (TICK_LOOP2_ENABLED()) { DTRACE_PROBE1(tick, loop2, i); } printf("hi: %d\n", i); sleep(1); } ... Here tick:loop1 is marker without semaphore where as tick:loop2 is surrounded by semaphore. # perf buildid-cache --add /tmp/tick # perf probe sdt_tick:loop1 # perf probe sdt_tick:loop2 # perf stat -e sdt_tick:loop1,sdt_tick:loop2 -- /tmp/tick hi: 0 hi: 1 hi: 2 ^C Performance counter stats for '/tmp/tick': 3 sdt_tick:loop1 0 sdt_tick:loop2 2.747086086 seconds time elapsed Perf failed to record data for tick:loop2. Same experiment with this patch series: # readelf -n ./tick Provider: tick Name: loop2 ... Semaphore: 0x0000000010020036 # readelf -SW ./tick | grep probes [25] .probes PROGBITS 0000000010020034 010034 Semaphore offset is 0x10036. I don't have educated 'perf probe' about semaphore. So instead of using 'perf probe' command, I'm manually adding entry in the /uprobe_events file. Special char * denotes semaphore offset. # echo "p:sdt_tick/loop2 /tmp/tick:0x6e4 *0x10036" > uprobe_events # perf stat -e sdt_tick:loop2 -- /tmp/tick hi: 0 hi: 1 hi: 2 hi: 3 ^C Performance counter stats for '/tmp/tick': 4 sdt_tick:loop2 3.359047827 seconds time elapsed Feedback? TODO: - Educate perf tool about semaphore. - perf_event_open() now suppoers {k,u}probe event creation[3]. If we can supply semaphore offset in perf_event_attr, perf_event_open() can be educated to probe SDT marker having semaphore. Though, both config1 and config2 are already being used for uprobe and I don't see any other attribute which I can use for semaphore offset. Can we introduce one more config there? config3? [1] https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation [2] https://github.com/iovisor/bcc/issues/327#issuecomment-200576506 [3] https://lkml.org/lkml/2017/12/6/976 Ravi Bangoria (4): Uprobe: Rename map_info to uprobe_map_info Uprobe: Export few functions / data structures trace_uprobe: Support SDT markers having semaphore trace_uprobe: Fix multiple update of same semaphores include/linux/uprobes.h | 25 +++++ kernel/events/uprobes.c | 43 ++++---- kernel/trace/trace_uprobe.c | 244 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 290 insertions(+), 22 deletions(-) -- 1.8.3.1