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: 10734077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA5786C2 for ; Mon, 17 Dec 2018 17:22:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6F462A2F5 for ; Mon, 17 Dec 2018 17:22:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB5942A301; Mon, 17 Dec 2018 17:22:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3F87B2A2F5 for ; Mon, 17 Dec 2018 17:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=FHYzb4BmMpCGaRQTD45lqNaDoy24AizD/brqK2F+Yus=; b=q0V u7noa6lyoONsTdSIEpN8UGcyzB+X1/QGdRCvmmVBQd97QTZSV0Um3+mEqhhq7FAqcF194CKU29+54 EKhz5zvBQDhuQDd04ByhsvZLH3doLAZ8o2RxmQ/xm3QZEbLiTo0rz1RyEL2NyVKcaDucNryHDqHUZ 3V6vQ2tejQQrfU7VsSS0ZOgQc6W1hL6rsguTM7VCEGYq35guBoXbN7NLskhUicHe34tBleBC4G/9E L0EOY/7LRqYZNEep9KolVZGxg8BJysh/4zDp+1gb+K2Vb/vIr2XbOgujPW1faXQVjC4qdkaweYFvq 0IY9mhlJ6UtBhsnLMEmI93D8FTWI2xg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYwai-0003pF-EC; Mon, 17 Dec 2018 17:22:04 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYwae-0003m5-CZ for linux-arm-kernel@lists.infradead.org; Mon, 17 Dec 2018 17:22:02 +0000 Received: by mail-pl1-x643.google.com with SMTP id e11so5786370plt.11 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=tUxP0bVjZMXuOoXZ7Nj4sqEk1y+eZ9QQNmFs4qqPoy7NEdRFN6m/9ka6RWGyeHo1fH iMX2dfHx5dPOBhBl4e7mKMVjy+o4cqLIm6oNT8PDb0uGFLwJZauyq2pd+fOeqp390bH+ 3DIpAUXXmpnHPZmDL3IzE+u5FCnNPz3ZX4kZQEPR7+VYd7O8ONXQeGhyma1MnncTZ8vx ZWakrU665G4GFPXm/QYiMCl0iFhzrgbJDgS2sW07knarTQnnoUAukDh6Nv15UGq8n+KN qJut/8hXrmtP0qcxWU6HFLTGuNWkfRYdGLi6cXbfdml3w4MolUguM1GGSqDo6nlwjJ4x PEFg== X-Gm-Message-State: AA+aEWbY9ltbnOUP5LlMMqXfbELTV9TYttsvnxHqwgp1KT1mJLpYpq+D mgeVvmZg/JX/6aXCiHfGjGq9pw== X-Google-Smtp-Source: AFSGD/XtxLtYNGU6F2etgMtW/QNN4Y30g40zJ4FRuwbT98GtB9DaK6bz/qhHNyHDNZ99mR+gArtWHw== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181217_092200_428404_8BCD2843 X-CRM114-Status: GOOD ( 15.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-s390@vger.kernel.org, alexander.shishkin@linux.intel.com, will.deacon@arm.com, heiko.carstens@de.ibm.com, adrian.hunter@intel.com, ast@kernel.org, mingo@redhat.com, linux-arm-kernel@lists.infradead.org, hpa@zytor.com, schwidefsky@de.ibm.com, namhyung@kernel.org, tglx@linutronix.de, suzuki.poulosi@arm.com, jolsa@redhat.com, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-)