From patchwork Wed Jul 15 02:05:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11664031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA1FC138C for ; Wed, 15 Jul 2020 02:07:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 7B6AC20663 for ; Wed, 15 Jul 2020 02:07:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zUZMrBdX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KSk5xf+9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B6AC20663 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=OmmziFGV08b9KLA4ILRtXOhsfBptlm5/r1XX5PXANCY=; b=zUZMrBdX0D/KpxSRPMKCTvL+9K 5IUhAjWmjfSjSdg3cYD6lsjuq9dlyvvEdlnca17uquNyuP8b6QAeOdDAx6/OuSpZEn0TBoRo70Q8s FkHIMlRP79U/4aZTNROckV35yD+mCsvmBSYJQPfq3yzEBrVFxHVfdaf8j0hUEVWQutBCcszwGBR0B rBruaAT4V2NK84i0iAz90Jcc+h2RzS7WqqyHjGaFjkH6LTZMUh+Ipc+khTYtAAU34S6mKeLncPnPf 1k4rj8sgcrOMQY6sG4MmcbWx1kbvHEE4Ry9nSNqtF/BdXSqe95B7UIZTcCG3tSG1Bpkn3fOs65QFi 1dAP3VZQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvWnc-0007LK-HV; Wed, 15 Jul 2020 02:05:32 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvWnY-0007KB-SJ for linux-arm-kernel@lists.infradead.org; Wed, 15 Jul 2020 02:05:30 +0000 Received: by mail-pg1-x543.google.com with SMTP id z5so1166340pgb.6 for ; Tue, 14 Jul 2020 19:05:25 -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; bh=IaDIKmrv4dx2/me1ziKFX3npWTh6u2+K8VHR4xtYEvI=; b=KSk5xf+9ttvbvG1cUFueIBgCZIa/2o3Ml/6KGETT23GM0EIHEb+kwexHi648eok0q+ b+rTfFxE6XjfnzX23D3MkRRo5oDlpI4h3Yg6JvtLWpYRR0MPrnWfCKvsk7a4OoFmZXWp 0a4wXfZbRtKWI7gtfU5yF51cqxGhVaUshB1jfsMmQ5VBkyJCSHsbSfBxZcFMcNkxtxrw YSiJ8zj1LJ1+HMafeOB/Sq75celLO4f7hb7lhBKux2CGbTKti/Oyc1VYBPdnsAi7unSN vO9JhCJN+kF0TxsPVQxU/v/XWDZgjKoNn8++ar7cpNVMUuwS3+jmRVvEEo75eGv8rrWz fMrQ== 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=IaDIKmrv4dx2/me1ziKFX3npWTh6u2+K8VHR4xtYEvI=; b=lrPWY9BAlGODO8RxNzX0MRWhe6p51yPVVXvkyzhHu0wbp5t3iylF8ev/ntwDkteIoL Q4GQFD6vRHsn4JZMkWvVM6ezDCJcwk3fyh1VjAJu9aK6m83aluiij6eRh7KJERVktvf5 RCHBOrZU98Gkm7/2lEteIdIaW6vIoRAVjVGSC/vd+qUnEHHrcep02pJxdgxzcY99SWwi UzszC4GuEioA1hw353RIhlGJxpnXmu1WmDeea8nmAia6hTaKKcj9skSAP63JC0uP2ptl iw364SpuzfNwXGffJqawzSxXDahQYA8fvCyDcWIyANL/tGxrrwGLk+A74KHwKN0EJY7Z J7Cg== X-Gm-Message-State: AOAM531rtK9I5XNM2tvZWSyaE6ShXhjK/GIiQ+t5NrMGMxnBYUIGsj/2 +bM2XL8QGrqcPXR6Ontrl5IQvg== X-Google-Smtp-Source: ABdhPJzcTSLzoTkwN0ZklOtgUfNh6CnWTfMrQCsIPnKPLy5Pumiyh3t7E4wIxKgRr9byBrCe1lgrHw== X-Received: by 2002:a62:1801:: with SMTP id 1mr6907081pfy.242.1594778723827; Tue, 14 Jul 2020 19:05:23 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id my9sm296320pjb.44.2020.07.14.19.05.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jul 2020 19:05:23 -0700 (PDT) From: Leo Yan To: Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , Paul Cercueil , "Ben Dooks (Codethink)" , "Ahmed S. Darwish" , Adrian Hunter , Kan Liang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/6] arm64: perf: Proper cap_user_time* support Date: Wed, 15 Jul 2020 10:05:06 +0800 Message-Id: <20200715020512.20991-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200714_220529_219374_13B41D4A X-CRM114-Status: GOOD ( 15.13 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2400:8904:0:0:f03c:91ff:fe8a:bbe4 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch set is rebased for Peter's patch set to support cap_user_time/cap_user_time_short ABI for Arm64, and export Arm arch timer counter related parameters from kernel to Perf tool. In this version, there have two changes comparing to Peter's original patch set [1]: The first change is for calculation 'time_zero', in the old patch it used the formula: userpg->time_zero -= (rd->epoch_cyc * rd->mult) >> rd->shift; From the testing, if 'rd->epoch_cyc' is a big counter value, then it's easily to cause overflow issue when multiply by the 'rd->mult'. So in this patch set, it changes to use quot/rem approach for the calculation and can avoid overflow: quot = rd->epoch_cyc >> rd->shift; rem = rd->epoch_cyc & (((u64)1 << rd->shift) - 1); ns = quot * rd->mult + ((rem * rd->mult) >> rd->shift); userpg->time_zero -= ns; The second change is to add new patch 'tools headers UAPI: Update tools's copy of linux/perf_event.h', it's used to update perf tool header so make sure the headers are consistent between kernel and user space. This patch set has been rebased on mainline kernel with the latest commit 11ba468877bb ("Linux 5.8-rc5"); it has been verified with Perf tool for Arm SPE timestamp enabling, the patch set for Arm SPE timestamp enabling will be sent out separately. [1] https://lkml.org/lkml/2020/5/12/481 Leo Yan (1): tools headers UAPI: Update tools's copy of linux/perf_event.h Peter Zijlstra (5): sched_clock: Expose struct clock_read_data arm64: perf: Implement correct cap_user_time arm64: perf: Only advertise cap_user_time for arch_timer perf: Add perf_event_mmap_page::cap_user_time_short ABI arm64: perf: Add cap_user_time_short arch/arm64/kernel/perf_event.c | 59 ++++++++++++++++++++------- include/linux/sched_clock.h | 28 +++++++++++++ include/uapi/linux/perf_event.h | 23 +++++++++-- kernel/time/sched_clock.c | 41 ++++++------------- tools/include/uapi/linux/perf_event.h | 23 +++++++++-- 5 files changed, 126 insertions(+), 48 deletions(-)