From patchwork Mon Dec 3 22:54:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 152784 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7388927ljp; Mon, 3 Dec 2018 14:55:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/XCwtzp7fSdbvnZDDVm6kWt077M8rlsxAyfVY7n4EUuG/yW4eQhPug3MO1LaAOWagpHCCSi X-Received: by 2002:a17:902:b707:: with SMTP id d7mr8958628pls.29.1543877702541; Mon, 03 Dec 2018 14:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543877702; cv=none; d=google.com; s=arc-20160816; b=EYLXosfNoX1xgst8H83sha+jRd49nZ5osT+VG52f9BRo3dJ2kZxbIDuafpUERVxVF0 /WwFFivG36QdDaZV66GEywXfkvGrGyeDp2avyV190NB+QZFOHWFSSvYuKAHsGdVgZPOd 1/KomE9HZcohDQQNwWppQRbMHAlZdRCDKCq1vc/KY3e6HgIzhiwQHJQnqTTO8GwMB6La XoWdtRWDcUzptve6X7Ng48RuRmP/+ePGu+BbQAXKqIw1Y0MN2L4PyO+ehEI261XKxWmq oMsUqhsCCYz7y235BD0pCmDzGpF6EdnEOF6kClVDx046OIhvG5ejwYSQomnokUv/QAMh AC8A== 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=ksGSE6Cc9VG/A00Ld7RPZ1CW6RRFzM/pQBtwpovt2X4=; b=A2mkN+IXN+3lcNOaHvs2zFNY+ZX5si+ov3yfZKKyo4akbxKJRcEN19JRSbdOaUGgLM IMvLovfB3BaI1QOOENSm4KoVQG3twhaLsfK4ToxF8plPo5aPs0ZTWEoD6IDcp/7ZcVkb FdVtGZ4yQXvpRLWpdyuYnitVmdhDeUFVQ8pZ8Y19QTMFzzqC8ZLf1OSraXK1IonHS+NF lsEcODKmISjtbx1KyPwew/M6bt1TF4J/wRECfHqVL2E7/JPkvu2leFLDYac1UK1FPZzJ FnKxS9Yz4YTvwm0kD4R7eQ6NetWYMxXhTS0IGFIpK+8/Bu6ZxiSWNFTKsnxx8vpOCbhA JQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EjElAK8T; 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 e7si13222246pgi.263.2018.12.03.14.55.02; Mon, 03 Dec 2018 14:55:02 -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=EjElAK8T; 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 S1726059AbeLCWzA (ORCPT + 32 others); Mon, 3 Dec 2018 17:55:00 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45669 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbeLCWy7 (ORCPT ); Mon, 3 Dec 2018 17:54:59 -0500 Received: by mail-pl1-f193.google.com with SMTP id a14so7202767plm.12 for ; Mon, 03 Dec 2018 14:54:59 -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=ksGSE6Cc9VG/A00Ld7RPZ1CW6RRFzM/pQBtwpovt2X4=; b=EjElAK8T7sc3RlBItuETx3nTXgWFHr9nCABkxA218Abq/dx48F5iaSIeddLSCPX6nq +PQuDPIWvlxSJNwzkIQBGwDXQle5xlG8fOxi9EwD8Ysj6GeW7niyPBHvC1lPLsQcUf++ MZw2sN8I+m2IsI/ajfl2KSM38fiILd8Xx2Wkw= 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=ksGSE6Cc9VG/A00Ld7RPZ1CW6RRFzM/pQBtwpovt2X4=; b=foBAcBmbCdqwSBYMvrfPJaf4PR4sa6LS1W7wwF3H4tj6jvNPmvAkM4SC7mSqoI6IbY kC3NVwlLz50g/sgTOGsnjAi18074yGIGadmngizNTVN4jqdW2ei+YP6U8UMmOZoSX0+k foVtJIq2w4LKCn4gpeXXgTyEUH6IR5OomYAr0Z5X/HSkJYrF3peM07LCvdnURkxV/hSi vEt5JixoiLkVMH6EZ7KUKSRK/VxFFACKr+57MT4b207tQq9EOM1Y8/iZBd8+Ukd0lKKD qGkoRop3Of4BDxI/Evqz4KG/MmmsUQuqiBFpuraZ1j5SZSX50Rlq2V7yOBbgEAjeWVfl Fbsg== X-Gm-Message-State: AA+aEWYVq/SnKAwXZxwre0TqKe9WouzSa/oByTpaaucEnOhXaX2R4DPz WziMWtCdOLp+gRuKPm4Rt6eEZA== X-Received: by 2002:a17:902:8a91:: with SMTP id p17mr17698810plo.316.1543877699012; Mon, 03 Dec 2018 14:54:59 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id v9sm20933057pfg.144.2018.12.03.14.54.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Dec 2018 14:54:58 -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: [PATCH v5 0/6] perf: Add ioctl for PMU driver configuration Date: Mon, 3 Dec 2018 15:54:50 -0700 Message-Id: <1543877696-17174-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 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