From patchwork Tue Jun 8 14:52:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12307115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23BD6C47082 for ; Tue, 8 Jun 2021 14:55:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E04DE61183 for ; Tue, 8 Jun 2021 14:55:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E04DE61183 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=XcwL3pWKOyNfoQfIpXTAetHa3XuUD506z3c8gVveAkw=; b=h9o7dHXZaaCLWB mfg5aN6llcjC9VyBpCm6jRz36YSdZl+co+h5QHjRWByV1z2kfZbPHg3oy8NKAe1IRSnJI6ihHzTkI DPit96O5XmOA3ZkOoVnZ3HNWRHQDBResivt5to+J6EN+5E/omfcOtoXzSw5JRcVlAHLlWU9RzCoL1 mPtXt2yPW2SMg8dVzPyuOSTCjXg8OZG43ULFHeUDcMyweIGAdOr/2K98qs8tKJ2vaWoQ7o780DtPV JfVG8TM1fJPuK3i2bW+hRMqaBpuXPpx1gLtENfWWQcO+7+eimsfKMNFcs4Ay/zLlw2HwfxAkEH7F5 Lizbillz7iU8ibygHoYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqd6z-0091NZ-QH; Tue, 08 Jun 2021 14:53:49 +0000 Received: from mail-pg1-f176.google.com ([209.85.215.176]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqd6w-0091Lq-Nt for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 14:53:48 +0000 Received: by mail-pg1-f176.google.com with SMTP id y12so4866374pgk.6 for ; Tue, 08 Jun 2021 07:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NJBbIlN10zo6gxtXyHmx0RKdZoV8MV2Ra7I8+9IhS8c=; b=esGPVs/lq0L7m1V0gyMSaCe3KocNIKP+AgRVCaoZn/g31pb1FllDHp/xV9eryEpl1w 3M+jq2UQly6MVNA02fsXwPKLhu8kRqT823H1of10K9/lEI6+ebGMHDoeb6HUavi69tR2 3p2b0M91M+1z4Y2ihQKAXxjPPhYpxS2hiEi1syqKJvjZPrE1qUubHplBFkV7VRXmndPl rLnTc6LxNC7J0F5smIIIafKMeGMxVUTZMSiU2F+qzq5itlQNXl8BNz3JOBqwilP8YXyF 1bbG/jqgVc0IurvnjhV/EzE7h6JAE+qfEdDjPcvWkwSbhS5iVelwve3xMPZh3b/xYa93 iyOQ== 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:mime-version :content-transfer-encoding; bh=NJBbIlN10zo6gxtXyHmx0RKdZoV8MV2Ra7I8+9IhS8c=; b=YUdsT/sRewrrjto3sOV1SzQxgyhmXB0B1sYmgrkvqM370taJygsRtCSSse4MSQ16KZ P16L3EpD86J4ul6aFJDK0mWQKHkvqaewErGfZwSEWLP1bAJGv/9rCdYfGyP4VfPfjuCc kI5lBNXB/+m9X5NLJRY/UFGeN19wJbPt98Riq9Cx7wTvsXa9n56vhp4RHVcsVnF31RPo rh5C9cKK6m2N5z3NXIowUFhC8OPPOOLD4A2VNZryo3Drl8FXdUdXcuaktYeKgH5Q3c2U CdEl4ssO1BSzJWR6KLJ/KFSVniigWjrh1/MG+mF6N5mB1Wmp/KxbO0MFmSG2jHsKC3+6 MOKQ== X-Gm-Message-State: AOAM530FE8KR+ya1mkgT3RK9jAw51vpQS6F1Z9X9KVKsWLBB3K8bvys1 tA0TjpAThfbBELl7US16gokv3A== X-Google-Smtp-Source: ABdhPJx+15XdCLs2WnyMINrYpTVoNMyg3aXt4IuPoUQlZk8IIWVXFF1IbDyyudDqlztbcZyT1J9evA== X-Received: by 2002:aa7:8003:0:b029:2eb:2f8f:a320 with SMTP id j3-20020aa780030000b02902eb2f8fa320mr49724pfi.70.1623163962242; Tue, 08 Jun 2021 07:52:42 -0700 (PDT) Received: from localhost (ec2-18-167-84-74.ap-east-1.compute.amazonaws.com. [18.167.84.74]) by smtp.gmail.com with ESMTPSA id r11sm11995875pgl.34.2021.06.08.07.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 07:52:41 -0700 (PDT) From: Leo Yan To: Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 1/2] arm64: perf: Correct per-thread mode if the event is not supported Date: Tue, 8 Jun 2021 22:52:27 +0800 Message-Id: <20210608145228.36595-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_075346_815156_DFA3F27C X-CRM114-Status: GOOD ( 19.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the perf tool runs in per-thread mode, armpmu_event_init() defers to handle events in armpmu_add(), the main reason is the selected PMU in the init phase can mismatch with the CPUs when the profiled task is scheduled on. For example, on an Arm big.LTTILE platform with two clusters, every cluster has its dedicated PMU; the event initialization happens on the LITTLE cluster and its corresponding PMU is selected, but the profiled task is scheduled on big cluster, it's deferred to handle this case in armpmu_add(). Usually, we should report failure in the first place so this can allow users to easily locate the issue they are facing. For the per-thread mode, the profiled task can be migrated on any CPU, therefore the event can be enabled on any CPU. In other words, if a PMU detects it fails to support the process-following event, it can directly returns -EOPNOTSUPP so can stop profiling. This patch adds the checking for per-thread mode, if the event is not supported, return -EOPNOTSUPP. Signed-off-by: Leo Yan --- drivers/perf/arm_pmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index d4f7f1f9cc77..aedea060ca8b 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -502,9 +502,9 @@ static int armpmu_event_init(struct perf_event *event) /* * Reject CPU-affine events for CPUs that are of a different class to * that which this PMU handles. Process-following events (where - * event->cpu == -1) can be migrated between CPUs, and thus we have to - * reject them later (in armpmu_add) if they're scheduled on a - * different class of CPU. + * event->cpu == -1) can be migrated between CPUs, and thus we will + * reject them when map_event() detects absent entry at below or later + * (in armpmu_add) if they're scheduled on a different class of CPU. */ if (event->cpu != -1 && !cpumask_test_cpu(event->cpu, &armpmu->supported_cpus)) @@ -514,8 +514,16 @@ static int armpmu_event_init(struct perf_event *event) if (has_branch_stack(event)) return -EOPNOTSUPP; - if (armpmu->map_event(event) == -ENOENT) + if (armpmu->map_event(event) == -ENOENT) { + /* + * Process-following event is not supported on current PMU, + * returns -EOPNOTSUPP to stop perf at the initialization + * phase. + */ + if (event->cpu == -1) + return -EOPNOTSUPP; return -ENOENT; + } return __hw_perf_event_init(event); } From patchwork Tue Jun 8 14:52:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12307113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 374ACC4743E for ; Tue, 8 Jun 2021 14:54:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 02F6661059 for ; Tue, 8 Jun 2021 14:54:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02F6661059 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HgYtk/PQGnxOgo0n7KpTl6N0hxIvIy/CyAlkm954OYg=; b=r/YEkJglUT6DXQ pgnLl54lscdmuYQ1BRZag4QChN3vSvIZX+HFXLUaGoSTs2a3Luf64LTgoncxuCm+85jQ7vhaxePXI CMn0cGtNWM3/Hs4LFK0daEv9QjqPP+EVjso2cS/vrFf/zXgxi7kCp6WDEMQ60TKp+sPs3XyilVCXF IklTNRJU2Q/TUDHu1fkX/lZFx89udBYC90+UkNmfoIPwdjnw92UGrLgzT9navm/aIoGnrCkFaejdT rCAhFSxVgvllm1HiYn45o8B0ZuqqdOeJgVXYz7SWvRa4ZwD1uA0ywssbeALpGw9Z0/83CSAEXiEwi Krdnk1/SBY95XYESJmGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqd62-00918i-BS; Tue, 08 Jun 2021 14:52:50 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqd5y-00917x-KB for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 14:52:48 +0000 Received: by mail-pf1-x436.google.com with SMTP id m7so2950010pfa.10 for ; Tue, 08 Jun 2021 07:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GjjYvlo6o9qYmuvrmoD8jiP53R/+0wba+qif8TcHjrA=; b=u5mAwC3u3L5IH46vd4ciAayfeQ3nM5sy5exzt+TJQM2OAWL93U9IvLDtrUkohttu9F KvDPwUjzRKCry+ExqTn8qeDxr6nrRdvYoygi01TupNLKCuP7cnjpZzRZK8qiRMi2NRrc 5P4+FnoivbBeUQj8kXjARRI+/Ya6Ezudu/TnVq8xRHXPCLNIFXkNvgK+6WhVQl3qWsbO 3zu+SAOEyiE3b1NUiFn1sOBDKkdYJEcAwRpP0LuMevVh4GeakYKK6TjbGlNDRYoqKbNO GhEoGVdYM3WzA5k8o2hjzKy7CzQ/bVkpWw2hJ53GNm7J9RAywW6VFWshcRWYZ3q+n6ko yQxw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=GjjYvlo6o9qYmuvrmoD8jiP53R/+0wba+qif8TcHjrA=; b=XpNbQrde0VTOY3csLcumIe+zKqV8u3HuOwRsEhz7PX3vIC9KsCI9efY87YBfHQnCKQ At1ghZlj0euDFW8EiiJYnqGpJ9JQD25ZP7JDIerIfsf05XDBIXr9sj6YUEQd7dcINTjY eRM7fxJyPP/Ym1s7n+ebpdN94l55tguvX1snp/2zKbQ2gtRpGqpwm7KyZtSSnWYbSWAk vM4cnPnu7j1UXasdSPCJp2X4xC9OZcrNYjz3xt1aRQZdPRDfhXbqGzAHr0ITlOIZayi6 vLB8S2z9cUoiVfLt6eIwjUY/JpAnolG9sUK0zriRgk7+z61FW4lDN+KLP5/U3nK6DHqX PPzA== X-Gm-Message-State: AOAM530ri5EcKtOof6OT37nfoH3kHR34/+4YKHGx8ubk7ntTJ1RHrnhY AxXRjTSNN+VoTwDCUvF07Mrjhg== X-Google-Smtp-Source: ABdhPJys2rCAqYVEXhJeccvB2e2xd98ttYnH2gIKxpWEHJqhce3k27GEFOHEg/jAY1/ItRpj2TDPoA== X-Received: by 2002:a63:b30a:: with SMTP id i10mr22916323pgf.306.1623163965453; Tue, 08 Jun 2021 07:52:45 -0700 (PDT) Received: from localhost (ec2-18-167-84-74.ap-east-1.compute.amazonaws.com. [18.167.84.74]) by smtp.gmail.com with ESMTPSA id r5sm2793644pjd.2.2021.06.08.07.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 07:52:45 -0700 (PDT) From: Leo Yan To: Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 2/2] arm64: perf: Report error if PMU fails to support current CPU Date: Tue, 8 Jun 2021 22:52:28 +0800 Message-Id: <20210608145228.36595-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608145228.36595-1-leo.yan@linaro.org> References: <20210608145228.36595-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_075246_683465_0C0A59E1 X-CRM114-Status: GOOD ( 17.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When run perf command on the Arm big.LITTLE system (Juno-r2 board): perf record -e cycles --per-thread program The command executes normally without any errors; but when report the result with "perf report", it fails to parse the symbols. This is because the perf data file doesn't contain MMAP2 events, thus it cannot find the correct object file for parsing symbols. On the big.LITTLE system, if the initialized PMU doesn't match with the CPU the profiled task is scheduled on; for example, the initialized PMU is on CPU0 in the LITTLE cluster, when invoke the function perf_event_mmap_event() on CPU2 in the big cluster, the event is always filtered out due to the CPU2 is not supported by the initialized PMU. Finally, there have no any MMAP2 samples are generated for the profiling. This patch doesn't fix for this issue, alternatively, it simply reports an error when detect the current CPU is not supported by PMU, so can remind the user for the abnormal situation. Signed-off-by: Leo Yan --- drivers/perf/arm_pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index aedea060ca8b..99ddc8bf6466 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -565,6 +565,9 @@ static int armpmu_filter_match(struct perf_event *event) int ret; ret = cpumask_test_cpu(cpu, &armpmu->supported_cpus); + if (!ret) + pr_err("PMU doesn't support current CPU %d\n", cpu); + if (ret && armpmu->filter_match) return armpmu->filter_match(event);