From patchwork Mon Dec 17 17:21:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 154022 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2715913ljp; Mon, 17 Dec 2018 09:21:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/VLB4fSdYV2Br3Qz+zzD/KGAvjjFQ5BHaPmUDIRdgug93Ecc8EWceyO3zML2AKdDZp4eLTB X-Received: by 2002:a17:902:7614:: with SMTP id k20mr13568630pll.285.1545067313357; Mon, 17 Dec 2018 09:21:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545067313; cv=none; d=google.com; s=arc-20160816; b=ygx+ThXSmLB48mWalLo1WmTL2ALyU08SderhWefkc04VhSAaOAxMPaQJUCvfoUDle5 1sqQDzOh3db1kmwmiC52WkVmKeGth48Fa88L4ea3wZ2ZSXU2uulM+vzgmk+L2hybyNt0 /BNeH9DVDMErJjmB0ich6aklMedEbb7DDi0H7qaYKr5FSuHnzWs9nyfy4ByEXEkJTuor ShKTaECyZBjD/NhruP9SIaWtAQHeiMcodIUSYiRNYZN8Uz3KJs3RObaKm+LlD1UN1qRc a1fhNnxhVOq6zjZmZ1KPWCLKLoRlDA0clwiTBYi0D5gMby1RZjTaBPnGTjkUFKz/b9zC ucVg== 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 :dkim-signature; bh=Yzzy5cbsbIfUDrm2/cUff8ZiTSbnfPoPgDNURDr33A8=; b=oaYKeLLmOKlDiRwsFFzJZJqQuagQrgtWmKj/utIFsSyNVySk2VT/1tneOUwtpq9tKf Edg5Nl1WmeA/Cm/j8+XSTimjHxBUJlnYp3Y0pOxIO1NM/9UmrYM1a1Z2/89niVjfiFGd FK3t+Vtdyh30AzAlqvtBXBHvHBfEFuo07Bw0M7jwN62TAaNB/2s466nbYoKciupcdLkH av9MsNAQQF3dQ8t2RJ3z7yxheAylp9XP0zdNztbOJtqMwEEGoZ8XlvIeFAjfZlo9WEwA C5viC1Fx8Hg5lWcpfxgXOovy8UjbAAnZj5MbkLThBalLsSZ0QCw8NiNdnxCso5CRRuCe CIiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a8jaAhQD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si11206338pgd.567.2018.12.17.09.21.52; Mon, 17 Dec 2018 09:21:53 -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=@linaro.org header.s=google header.b=a8jaAhQD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388298AbeLQRVu (ORCPT + 31 others); Mon, 17 Dec 2018 12:21:50 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41980 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727186AbeLQRVu (ORCPT ); Mon, 17 Dec 2018 12:21:50 -0500 Received: by mail-pl1-f194.google.com with SMTP id u6so6426952plm.8 for ; Mon, 17 Dec 2018 09:21:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Yzzy5cbsbIfUDrm2/cUff8ZiTSbnfPoPgDNURDr33A8=; b=a8jaAhQD+i6hI83fRC+CDzto8wWTF8OEsorQrb7kniPhJVrnU8SfLbMf0Xn7tivg50 Dd5SVxL83lTk0L5TBQVq7NI/6ZMkpy+8B8PXJ6CApfGmcaTwoX6S4o5bSlk8u8qV/dIZ Cg3chmUaZyYosSvogHKE3yi1iVYktWKzRsmQ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Yzzy5cbsbIfUDrm2/cUff8ZiTSbnfPoPgDNURDr33A8=; b=ViIrTjcIE4vk/fpaWCm9oOQwhVH15WAa342E6VEW2je3rUE3/4PvzcOFz/RtCHkaBa EVnGeh22DEV4sPD00XlrHfy1vndEsiCcM2wOIHBcFe3X0uVPjuR55JroGB8BgZCXAb9S gLX2FeuDDsibN56kOsxgDmDMHodJL7+VNHOxqcxObbGAkwdaA1/BMAqofekv+r6hL98J Fr3xo2vWOdDKnOcRJfTeN4OjBTW2YI7Wuc6p/lc5yCV6Jwrc4VRIJJQXSXKzPIhnDYPs RIEQNmaFwlnv+eUXGmNluSYvHH3y6GPZ1fLVaFWZZZjkBLCFceDZ4oPDN7tIym8UiEQN eJPQ== X-Gm-Message-State: AA+aEWZDB5odKVbQPrtsXMK5+i3/k/lckr8ZH7r518jqieM2oR51yPER 0f9Fle08Q0YBevyIl/1W2/5q+ShuZ10= X-Received: by 2002:a17:902:bb98:: with SMTP id m24mr13025374pls.71.1545067309406; Mon, 17 Dec 2018 09:21:49 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j6sm20526648pfg.126.2018.12.17.09.21.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 09:21:48 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: mingo@redhat.com, tglx@linutronix.de, alexander.shishkin@linux.intel.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, will.deacon@arm.com, mark.rutland@arm.com, jolsa@redhat.com, namhyung@kernel.org, adrian.hunter@intel.com, ast@kernel.org, hpa@zytor.com, suzuki.poulosi@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH v5 0/6] perf: Add ioctl for PMU driver configuration Date: Mon, 17 Dec 2018 10:21:40 -0700 Message-Id: <1545067306-31687-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the coresight world there can be more than one sink to aggregate trace data generated by CPUs, hence the need for users to select which one to use from the perf command line. Up until now sysfs was used to communicate sink information to the kernel but that was never the right way to proceed because it breaks when more than one perf session are created at the same time. The situation was manageable when working with per-thread scenarios where a single HW trace event is created but in CPU-wide mode a HW trace event is created for each CPU that is specified on the perf command line, taking us back to the concurrency problem we have when dealing with multiple per-thread session. This work fits in a wider scheme to support CPU-wide trace scenarios on CoreSight that is available here [1]. The first step in that venture is to address sysfs concurrency issues, which this patchset does. The main difference with V4 is the usage of a CoreSight sink's HW start address (u64) to uniquely identify a sink, negating the need to use the component's name (char *). By using a u64 we can theoretically add the sink information to the perf_event_attr structure, avoiding the need to add a new perf ioctl(). On the flip side it would introduce a very specific CoreSight field to a structure that is generic. I have opted for the ioctl() method, let me know if you want me to proceed with the latter. Regards, Mathieu # Before this set: root@juno:/home/linaro# perf record -e cs_etm/@20070000.etr/ -C 2,3 sleep 1 failed to mmap with 12 (Cannot allocate memory) # After this set: root@juno:/home/linaro# perf record -e cs_etm/@20070000.etr/ -C 2,3 sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 4.145 MB perf.data ] [1]. https://git.linaro.org/people/mathieu.poirier/coresight.git/log/?h=cpu-wide-coresight --- Changes for V5: . Went from a char * to a u64 for ioctl argument (GKH). . Added a better description of the problem being fixed to the cover letter (GKH). Changes for V4: . Made passing of information between ioctl() and PMU simpler. Mathieu Poirier (6): perf: Introduce ioctl to communicate driver configuration to kernel perf/core: Use ioctl to communicate driver configuration to kernel perf/aux: Make perf_event accessible to setup_aux() coresight: Use PMU driver configuration for sink selection perf tools: Make perf_evsel accessible to PMU driver configuration code perf tools: Use ioctl function to send sink information to kernel arch/s390/kernel/perf_cpum_sf.c | 6 +- arch/x86/events/intel/bts.c | 4 +- arch/x86/events/intel/pt.c | 5 +- drivers/hwtracing/coresight/coresight-etm-perf.c | 80 +++++++++++++++++----- drivers/perf/arm_spe_pmu.c | 6 +- include/linux/perf_event.h | 40 ++++++++++- include/uapi/linux/perf_event.h | 1 + kernel/events/core.c | 67 +++++++++++++++++++ kernel/events/ring_buffer.c | 2 +- tools/include/uapi/linux/perf_event.h | 1 + tools/perf/arch/arm/util/cs-etm.c | 84 +++++++++++++++++++++++- tools/perf/arch/arm/util/cs-etm.h | 3 +- tools/perf/util/drv_configs.c | 30 ++------- tools/perf/util/evsel.c | 6 ++ tools/perf/util/evsel.h | 1 + tools/perf/util/pmu.h | 3 +- 16 files changed, 287 insertions(+), 52 deletions(-) -- 2.7.4