From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752734AbcFNQtu (ORCPT ); Tue, 14 Jun 2016 12:49:50 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47726 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751727AbcFNQts (ORCPT ); Tue, 14 Jun 2016 12:49:48 -0400 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: aravinda@linux.vnet.ibm.com X-IBM-RcptTo: a.p.zijlstra@chello.nl;rostedt@goodmis.org;acme@kernel.org;mingo@redhat.com;paulus@samba.org;linux-kernel@vger.kernel.org;ebiederm@xmission.com Subject: [RFC PATCH 0/2] perf: Container-aware tracing support To: a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mingo@redhat.com, paulus@samba.org, acme@kernel.org, ebiederm@xmission.com From: Aravinda Prasad Cc: hbathini@linux.vnet.ibm.com, ananth@in.ibm.com Date: Tue, 14 Jun 2016 22:19:29 +0530 User-Agent: StGit/0.15 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16061416-0012-0000-0000-00000FEEB5BD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16061416-0013-0000-0000-000042BB4212 Message-Id: <20160614164530.4192.79560.stgit@aravindap> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-14_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606140183 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The RFC patch set supports filtering container specific events when perf tool is executed inside a container. However, unlike the previous approach [1], this requires containers to be created with a new namespace "perf-namespace" (introduced in patch 1). The basic idea is analogous to other namespaces: if event isolation is required when running perf tool inside a container, then the container should be created with perf-namespace. Based on the feedback on the previous approach for container-aware tracing [1] in Plumbers 2015 Containers Microconference [2] we have come-up with a new prototype. The new prototype introduces a new namespace "perf-namespace" (namespace name is just a placeholder. name suggestions are welcome). The perf tool executed inside a container created with perf-namespace reports only those events that are triggered within the container. For example "perf record -a" inside a container reports container-wide events; the "-a" flag which stands for system-wide event collection takes the meaning of container-wide event collection when executed inside a container. We have tested perf-record, perf-stat and perf-top and we are currently working on getting perf-probe (kprobe/uprobe) working. Our previous prototype [1] required the container to be created with PID namesapce and further required processes inside the container grouped into a single perf_event cgroup. However, during the discussion in Plumbers it was mentioned that the requirement of PID namespace is insufficient for containers that need access to the host PID namespace [3]. Work in progress: - Get perf-probe working for containers. We are planning to enhance tracefs to have multiple probe lists instances and then mount different instance of tracefs (using add newinstance mount option) for every perf namespace. Patches are based on 4.7.0-rc2. Suggestions and feedback are welcome. [1] https://lkml.org/lkml/2015/7/15/192 [2] http://linuxplumbersconf.org/2015/ocw/sessions/2667.html [3] Notes for container-aware tracing: https://etherpad.openstack.org/p/LPC2015_Containers Regards, Aravinda & Hari --- Aravinda Prasad (1): perf: Filter events based on perf-namespace Hari Bathini (1): perf/namespaces: Add a new namespace for isolated tracing fs/proc/namespaces.c | 4 include/linux/nsproxy.h | 2 include/linux/perf_event.h | 8 + include/linux/perf_namespace.h | 58 +++++++ include/linux/proc_ns.h | 2 include/uapi/linux/sched.h | 1 init/Kconfig | 7 + kernel/Makefile | 1 kernel/events/core.c | 347 ++++++++++++++++++++++++++++++++++++++++ kernel/fork.c | 3 kernel/nsproxy.c | 20 ++ kernel/perf_namespace.c | 132 +++++++++++++++ 12 files changed, 581 insertions(+), 4 deletions(-) create mode 100644 include/linux/perf_namespace.h create mode 100644 kernel/perf_namespace.c -- Aravinda Prasad