From patchwork Thu Jul 16 05:11:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666659 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 EAF0B13A4 for ; Thu, 16 Jul 2020 05:13:36 +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 BD521207BB for ; Thu, 16 Jul 2020 05:13:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0y4uwsIq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Gt773ugE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD521207BB 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:References:In-Reply-To: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:List-Owner; bh=2nnOIfEApDKt3t2ahW4Kj/yG55dvDBr7SjFiYk6WzBI=; b=0y4uwsIqDAOLvUqsemOkQou882 Cwl6KKnKSWZrFHSyOuY127lLzx1rWXTxa49PXAcRMRH9buY6Kcvrvbc4XlppR2anp9xAp86tExVHS oPpP3XbBz/H/hy8tOYw7yV0cn9245HeTxDwIvIjNUW0dKqjTvNk8VjiKopBx8Dj8vhwhUmsY5uDTv D2C6jYLW2F/9vaNy4nLSw45iQ3U4YklGgu7XsIKvCFab8jG64+9GpQvQ92ytS95tRq1gxAvDEW6X1 hsTWMuPPkpooLaLnVx3k0qXm9bMoJaJhyxECv/V0ASh9oy5WvoVAKhibL2+a9tn8CQldTEjxEqKQv 7c/f8Hrg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwBf-0005TZ-Gv; Thu, 16 Jul 2020 05:12:03 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwBd-0005SL-Ae for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:02 +0000 Received: by mail-pj1-x1044.google.com with SMTP id f16so4084530pjt.0 for ; Wed, 15 Jul 2020 22:12:00 -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; bh=ZudUuOTNYLjrn927Wl/0yhsw+jXTcOSpfU/HEVcjSaU=; b=Gt773ugE0h5EgoccjmZl2Lzgz6qbZQF7ighWOfIN6A3dQJnKxXJTf185l8MbquwkH3 A3+XGKXQKfOqQSFhrCa1bopgyeKqM0oKMe2twwL7IkCP8d9+QlGYBdOryOLalN4+pQPz IwdoyQj455gQ21EVTpL8VZ9ZFKuk7aOM+muj+xJV3nA+tnIzKQ9Fxw3QmBcMDNKDnsW7 KCgGh2vQQF69RT8FkDYELw2fVMBW78CdrIZvnieOJ5pX66eEAKt0fdlk2PlTDi7TNEoc 4SrCSCkMBcJPbPI3ktSXHbeZ8MbcQa++cZT4ln3YNWt4nvwMfLtGsq6smxxCsh2MZG2F w0Jw== 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; bh=ZudUuOTNYLjrn927Wl/0yhsw+jXTcOSpfU/HEVcjSaU=; b=NABUG+/RZ5wkScfAWrZ/rvMwgL/7N/C8ZIRvL91tt3RCI/DPq66Q+K8MWu0k7P+1yp sr0V/xoi42gdqp/zUyj9fEVNPLU/c6cZ+FkyhbNnku6mgIUlaYQf5/hg3cLy1bGn/yTZ bCrjDnAIOWQqy//l5cbR1qutyAxVi/Ks5pMvZd3wmZkfM+tmqBJ4rCWTI4ids2U/eQ0n 12sl1q1dRBPbnv0kAvFjBbxUpX8mej6y+vsoNWGtOuQ3yVrd2n4XI+3Hig8nXyvcwf5X M+MSgnOnhh5aGcRJtge1mGHsKaIqsMTEvLr/uQiUh+ypOWvoSoe1b/BH2qs4okgWzy7V Lgxw== X-Gm-Message-State: AOAM530I5b+D2R8quhQPUq4RK/s+jW46t12SqTp5LHouaia9Cc4JaEqa Fk9SmvlpH90X7UprpCjJ3w55fg== X-Google-Smtp-Source: ABdhPJxLGTY7dEuWAlIYrXYOh6qTVtPq90fdCUjRoXKAII2jiuebeKM7/zHYlSqnZ/kmm1PEMSqrCg== X-Received: by 2002:a17:90a:7406:: with SMTP id a6mr2798818pjg.152.1594876319114; Wed, 15 Jul 2020 22:11:59 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id l17sm3701086pgn.48.2020.07.15.22.11.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:11:58 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/7] sched_clock: Expose struct clock_read_data Date: Thu, 16 Jul 2020 13:11:24 +0800 Message-Id: <20200716051130.4359-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011201_391322_A096BFC3 X-CRM114-Status: GOOD ( 15.75 ) 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:1044 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 From: Peter Zijlstra In order to support perf_event_mmap_page::cap_time features, an architecture needs, aside from a userspace readable counter register, to expose the exact clock data so that userspace can convert the counter register into a correct timestamp. Provide struct clock_read_data and two (seqcount) helpers so that architectures (arm64 in specific) can expose the numbers to userspace. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Leo Yan --- include/linux/sched_clock.h | 28 +++++++++++++++++++++++++ kernel/time/sched_clock.c | 41 ++++++++++++------------------------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/include/linux/sched_clock.h b/include/linux/sched_clock.h index 0bb04a96a6d4..528718e4ed52 100644 --- a/include/linux/sched_clock.h +++ b/include/linux/sched_clock.h @@ -6,6 +6,34 @@ #define LINUX_SCHED_CLOCK #ifdef CONFIG_GENERIC_SCHED_CLOCK +/** + * struct clock_read_data - data required to read from sched_clock() + * + * @epoch_ns: sched_clock() value at last update + * @epoch_cyc: Clock cycle value at last update. + * @sched_clock_mask: Bitmask for two's complement subtraction of non 64bit + * clocks. + * @read_sched_clock: Current clock source (or dummy source when suspended). + * @mult: Multipler for scaled math conversion. + * @shift: Shift value for scaled math conversion. + * + * Care must be taken when updating this structure; it is read by + * some very hot code paths. It occupies <=40 bytes and, when combined + * with the seqcount used to synchronize access, comfortably fits into + * a 64 byte cache line. + */ +struct clock_read_data { + u64 epoch_ns; + u64 epoch_cyc; + u64 sched_clock_mask; + u64 (*read_sched_clock)(void); + u32 mult; + u32 shift; +}; + +extern struct clock_read_data *sched_clock_read_begin(unsigned int *seq); +extern int sched_clock_read_retry(unsigned int seq); + extern void generic_sched_clock_init(void); extern void sched_clock_register(u64 (*read)(void), int bits, diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index fa3f800d7d76..0acaadc3156c 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -19,31 +19,6 @@ #include "timekeeping.h" -/** - * struct clock_read_data - data required to read from sched_clock() - * - * @epoch_ns: sched_clock() value at last update - * @epoch_cyc: Clock cycle value at last update. - * @sched_clock_mask: Bitmask for two's complement subtraction of non 64bit - * clocks. - * @read_sched_clock: Current clock source (or dummy source when suspended). - * @mult: Multipler for scaled math conversion. - * @shift: Shift value for scaled math conversion. - * - * Care must be taken when updating this structure; it is read by - * some very hot code paths. It occupies <=40 bytes and, when combined - * with the seqcount used to synchronize access, comfortably fits into - * a 64 byte cache line. - */ -struct clock_read_data { - u64 epoch_ns; - u64 epoch_cyc; - u64 sched_clock_mask; - u64 (*read_sched_clock)(void); - u32 mult; - u32 shift; -}; - /** * struct clock_data - all data needed for sched_clock() (including * registration of a new clock source) @@ -93,6 +68,17 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift) return (cyc * mult) >> shift; } +struct clock_read_data *sched_clock_read_begin(unsigned int *seq) +{ + *seq = raw_read_seqcount(&cd.seq); + return cd.read_data + (*seq & 1); +} + +int sched_clock_read_retry(unsigned int seq) +{ + return read_seqcount_retry(&cd.seq, seq); +} + unsigned long long notrace sched_clock(void) { u64 cyc, res; @@ -100,13 +86,12 @@ unsigned long long notrace sched_clock(void) struct clock_read_data *rd; do { - seq = raw_read_seqcount(&cd.seq); - rd = cd.read_data + (seq & 1); + rd = sched_clock_read_begin(&seq); cyc = (rd->read_sched_clock() - rd->epoch_cyc) & rd->sched_clock_mask; res = rd->epoch_ns + cyc_to_ns(cyc, rd->mult, rd->shift); - } while (read_seqcount_retry(&cd.seq, seq)); + } while (sched_clock_read_retry(seq)); return res; } From patchwork Thu Jul 16 05:11:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666661 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 17EAE13A4 for ; Thu, 16 Jul 2020 05:13:39 +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 E4C32207BB for ; Thu, 16 Jul 2020 05:13:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CzsOLMZT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hc4i2Nr6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4C32207BB 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:References:In-Reply-To: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:List-Owner; bh=KbkVdPpgBlGMYveqfIvafSHjnS/qhhBhuAeMSl0g8iI=; b=CzsOLMZTeJeeaC5pG1Y2fu6u9f vpmn6qijq9UfJZ98/pChI34MbUw+0ouPqMPgBdwfAR+UhYxnDWjn3NhO4Dfntxm1kEZ/6OMYibDGG Z1HAkn4wLJdRdU2qMDkWWAuYpet+OeghxSpL7C2+L56HSSrWZwftBHldODvd5x11m6HEo+/LB/XUZ nJAk9pznspBWvW3bOOfrrjzkgmPxuu+AGnyDM0/rpbJMzZubPoADrXOcrrlF7jwI0VKvThr9Zz5+J ZJDScfnqi/J5T96ogBoJwIR3fFL4tglr33BAwcBewZHYZa+QW7z97Zf6sIgmqyvePOdTwi9OQKbsR +XZp2UKA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwBp-0005VW-DR; Thu, 16 Jul 2020 05:12:13 +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 1jvwBm-0005UM-7s for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:11 +0000 Received: by mail-pg1-x543.google.com with SMTP id g67so4251314pgc.8 for ; Wed, 15 Jul 2020 22:12:09 -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; bh=o/BsIfvqtTzak5Mv7ZiI0+KdUGs6co1ng50/6qYskQE=; b=hc4i2Nr6oqKqPE2jXwZbSn/Rbqv8nFoXy79RI3Lk97cBQGfRExofkvamCUf5Oo9J3N yCVbSC24M4e2k7egLH4YemLumM88fh51oKP7zE1T2CXUyJgLVTt7zf5bS1cYwcC4edI3 OGbsrEH/Xs2i9s0VV4IZDrB9e8OdDk9HfV1N3c3VbJtQ2oyhg4/xn6JqKVC4r34xpeXU RQAJxud14c57X1UIFFQunjHv7cruYPst8np7S+LsS/NvbvI6kHk4MzxV8aLmCTglWn/n B7FEK/9bbc3vgOnpC4QiAUgC6nxpnuYTSjJN+xkPXFlz5XLXb4WqqjEFKbm7lrl/n4xh 5IPQ== 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; bh=o/BsIfvqtTzak5Mv7ZiI0+KdUGs6co1ng50/6qYskQE=; b=XF43FFQrYbjDGE+4+5HqgcyH1mfVIcpUW8/IaWD1h6Aso3ZREvrb8/Is+N0k+sIYS9 MrAJSkE/n+N4lAIpKhVdjdhtO2ilBIPShUDRexORcmdwir8L5ejyEYX0wUP2nQ9GhY+y W/eTQ2U+oIuUN3wCe2l66jIlMPVUN2ac9N2BONP6XYOUi73x4pFPeFoqkz0woWp8P8OV g40U89U09ftUY8FzLY9aoTAdbsjomZmM86NSb/WLsyKqyqiUaytji2I3L4Fo8xxuA/5J LolA3h5AoDZ1YB2JnRIs4/Ej2sHydb12Gc4dgzbUpms4iWz1S0CDfP/hoBiOt6wA9sA+ wlfw== X-Gm-Message-State: AOAM530VQooNFevsKjjGz/n1+HEU68nR5+yFKj4X2FjxKF1SxQD5i4KY X4C38MMLAM669lR8AnEmsyCcXQ== X-Google-Smtp-Source: ABdhPJwB25v0txIQiG1pHuN6YTqIfWIpOVf/k+duttLSriG0rbXE+fdtIvbK4/pYXJVfwXjm2oYlcA== X-Received: by 2002:a62:a217:: with SMTP id m23mr2175657pff.291.1594876328190; Wed, 15 Jul 2020 22:12:08 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id a26sm3499222pgm.20.2020.07.15.22.12.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:12:07 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/7] time/sched_clock: Use raw_read_seqcount_latch() Date: Thu, 16 Jul 2020 13:11:25 +0800 Message-Id: <20200716051130.4359-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011210_294198_751ED907 X-CRM114-Status: GOOD ( 14.25 ) 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 ---- ---------------------- -------------------------------------------------- -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] 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 From: "Ahmed S. Darwish" sched_clock uses seqcount_t latching to switch between two storage places protected by the sequence counter. This allows it to have interruptible, NMI-safe, seqcount_t write side critical sections. Since 7fc26327b756 ("seqlock: Introduce raw_read_seqcount_latch()"), raw_read_seqcount_latch() became the standardized way for seqcount_t latch read paths. Due to the dependent load, it also has one read memory barrier less than the currently used raw_read_seqcount() API. Use raw_read_seqcount_latch() for the seqcount_t latch read path. Link: https://lkml.kernel.org/r/20200625085745.GD117543@hirez.programming.kicks-ass.net Link: https://lkml.kernel.org/r/20200715092345.GA231464@debian-buster-darwi.lab.linutronix.de References: 1809bfa44e10 ("timers, sched/clock: Avoid deadlock during read from NMI") Signed-off-by: Ahmed S. Darwish Signed-off-by: Leo Yan --- kernel/time/sched_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 0acaadc3156c..0deaf4b79fb4 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -70,7 +70,7 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift) struct clock_read_data *sched_clock_read_begin(unsigned int *seq) { - *seq = raw_read_seqcount(&cd.seq); + *seq = raw_read_seqcount_latch(&cd.seq); return cd.read_data + (*seq & 1); } From patchwork Thu Jul 16 05:11:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666663 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 707F560D for ; Thu, 16 Jul 2020 05:13:55 +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 48DAE207BB for ; Thu, 16 Jul 2020 05:13:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nkg3vXaN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SpkZPn6H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48DAE207BB 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:References:In-Reply-To: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:List-Owner; bh=YUgmnipjFHSHFOurLBUV2MsAQmaRjF5Fch0xg9JK0/0=; b=Nkg3vXaN8sRQHEd2jemeanADp9 n1DWpkw2VuAXkJzK0Zm0mOp+u3J3AM21IOkd391Q3YAzjGwDC7y/8QUTJKnz81Y5GSBd+a204YWwl +4s/fozcNFMLt0YbDqz6/JUvRN3Y7JaPN9R/05iGg7ONxh/LBgtDf3w4i9PV5rpEH+utvTV45GrBQ 0t8OUsWJjdeVki7my/qJxy5vSLYSrATn1g9ENXQCvlVpbaKxZluatGfmglOkJpZVLs2If7c5C11kT vfgi7Rzo2rs+9bkyyNgdPPlHStUMb6HDKqeHX3zxotpHgOuIUyNsWMKW1Po8DJ1YGJFuuvZsrfqAq oow3l2FQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwBz-0005YT-AX; Thu, 16 Jul 2020 05:12:23 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwBv-0005Wf-3n for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:20 +0000 Received: by mail-pf1-x444.google.com with SMTP id a14so3133275pfi.2 for ; Wed, 15 Jul 2020 22:12:18 -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; bh=4VhxXYjKbZ91ifYY2On11u4TZO/XIuQkddY97dt/t3k=; b=SpkZPn6HFTAK/4VvQttjVC8fe0n8j7eP3CcwBrbTmeQNEaM1VHB0YNDXxoLRSa2ntj dyyFG1+mJs1hlXt/ZWy9Gdx4qaC6etSSnlpb73hg1rENA17exHfnZU2fhmNwu+7pcVNb b/6Sv0de10oKKOzuGbMuytdUyiuwCu3IILyWGcgdIV4z3u2DxwzoQ9YB1F4qAXAHO0EK VROPl76VXYNTGtUKr/RUyosdnYDAvU1iZZoLOI+Aj03OwGgAiZyM09cj4/pcUqa8dQW+ kIpd9K2tFxDl5F6y8h3WXK+92jVdFmATltLDUuKDs2hWmFA7tvr5uf6yXr+9XevQFb1m q68w== 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; bh=4VhxXYjKbZ91ifYY2On11u4TZO/XIuQkddY97dt/t3k=; b=PrH24dSvcLRAQ1ML4tpOMUG8s8pWv5p2KTXWYN8IBcJ4AtKFwN2Cpgjltyaj7NI2jk Y/Yo97NHc65TVtK1shacdnyyBbbD6SsKz8kGxMDx3/yDaRK1Wcg4uoA6Fx7+SLcEGQpi NAH1GMnqCh7d3oFlAMRk5M3l64c2N8aHPBQSjI0uYYHHeqVhtPoloTx04od8CxSru8cT HkZVc2QxYaytIDRlczdf/xRXOmIPWmE7Ha+2SuBF6ahD0GwaqZmH0CfXwvhVspo/Mp5d FH5Gi8MPWYRNds31NAdnblUd0gSMCL/YhPVFZfMGCCw9fL27a3/CDGehB+q+SKktWY5S MEYQ== X-Gm-Message-State: AOAM533zto3GtIYXT0SokTsDXYBaFoaWntqmdBVq0yvlQQpptL4L6exX oNpAQt/fAzCXa2fUvr4mZuhjbw== X-Google-Smtp-Source: ABdhPJxfoOZ704p055HZ4HNFWcZnXOf8IhfT34HDilk7G8UIS3GQF/sewD1QfL2KUuN1zRp+5HGrZQ== X-Received: by 2002:a63:8c4f:: with SMTP id q15mr2743964pgn.373.1594876336959; Wed, 15 Jul 2020 22:12:16 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id y22sm3396275pjp.41.2020.07.15.22.12.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:12:16 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 3/7] arm64: perf: Implement correct cap_user_time Date: Thu, 16 Jul 2020 13:11:26 +0800 Message-Id: <20200716051130.4359-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011219_196116_6FD5C983 X-CRM114-Status: GOOD ( 17.97 ) 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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:444 listed in] [list.dnswl.org] 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 From: Peter Zijlstra As reported by Leo; the existing implementation is broken when the clock and counter don't intersect at 0. Use the sched_clock's struct clock_read_data information to correctly implement cap_user_time and cap_user_time_zero. Note that the ARM64 counter is architecturally only guaranteed to be 56bit wide (implementations are allowed to be wider) and the existing perf ABI cannot deal with wrap-around. This implementation should also be faster than the old; seeing how we don't need to recompute mult and shift all the time. [leoyan: Use mul_u64_u32_shr() to convert cyc to ns to avoid overflow] Reported-by: Leo Yan Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Leo Yan --- arch/arm64/kernel/perf_event.c | 38 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 4d7879484cec..47db6c7cae6a 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -19,6 +19,7 @@ #include #include #include +#include #include /* ARMv8 Cortex-A53 specific event types. */ @@ -1165,28 +1166,47 @@ device_initcall(armv8_pmu_driver_init) void arch_perf_update_userpage(struct perf_event *event, struct perf_event_mmap_page *userpg, u64 now) { - u32 freq; - u32 shift; + struct clock_read_data *rd; + unsigned int seq; + u64 ns; /* * Internal timekeeping for enabled/running/stopped times * is always computed with the sched_clock. */ - freq = arch_timer_get_rate(); userpg->cap_user_time = 1; + userpg->cap_user_time_zero = 1; + + do { + rd = sched_clock_read_begin(&seq); + + userpg->time_mult = rd->mult; + userpg->time_shift = rd->shift; + userpg->time_zero = rd->epoch_ns; + + /* + * This isn't strictly correct, the ARM64 counter can be + * 'short' and then we get funnies when it wraps. The correct + * thing would be to extend the perf ABI with a cycle and mask + * value, but because wrapping on ARM64 is very rare in + * practise this 'works'. + */ + ns = mul_u64_u32_shr(rd->epoch_cyc, rd->mult, rd->shift); + userpg->time_zero -= ns; + + } while (sched_clock_read_retry(seq)); + + userpg->time_offset = userpg->time_zero - now; - clocks_calc_mult_shift(&userpg->time_mult, &shift, freq, - NSEC_PER_SEC, 0); /* * time_shift is not expected to be greater than 31 due to * the original published conversion algorithm shifting a * 32-bit value (now specifies a 64-bit value) - refer * perf_event_mmap_page documentation in perf_event.h. */ - if (shift == 32) { - shift = 31; + if (userpg->time_shift == 32) { + userpg->time_shift = 31; userpg->time_mult >>= 1; } - userpg->time_shift = (u16)shift; - userpg->time_offset = -now; + } From patchwork Thu Jul 16 05:11:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666665 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 A676760D for ; Thu, 16 Jul 2020 05:13:59 +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 7F163207BB for ; Thu, 16 Jul 2020 05:13:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ew2lkdoK"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TRdSIC6d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F163207BB 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:References:In-Reply-To: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:List-Owner; bh=Lj9EWN6c/IC10VLtEvYZY1PkMAh99VFO4PzNmLgnX2Q=; b=Ew2lkdoKnK+gyF2EnXpYAcjr98 3Q091tFKtTpQaf27QT39CkVBO8JLQ/E7KJ6yq4EWaAlrMPLEBZHryeR5v6VIIw+zFBU9qkAMF8Lwb kckUEXy3TR9GSDXlnmGJLajaw6pJ/Nnp6g5wnAH/yEOtQuYTbwAULCsimdIczPh1z/VaDvBATDTNC 3uB6+Jf8XrQcESqwucPsK0Oz9o84E02ODfuBQNV4jQ8QhNfOZII5tSfC7xcsqNxMu4AEkGvkfLvj5 kgbb7M4TEDamh6H6BnnEHpUVyVdYDYpMp06wkugTe6ipYsCsoGJoD4LmZ6wm8quWo0Gknk3q4zEMM Z/IBG5NQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwC7-0005br-W1; Thu, 16 Jul 2020 05:12:32 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwC4-0005Zk-1h for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:28 +0000 Received: by mail-pj1-x1043.google.com with SMTP id o22so4084140pjw.2 for ; Wed, 15 Jul 2020 22:12:27 -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; bh=glSQZFm7ys+cLEa0wg7dCBHtIduDXujsNwJL2d9Q+I0=; b=TRdSIC6dXy+lZ+6wWCp1mpGVWNjXOHu/5M1D3Bz65it9dKude5TzVDKZCRHyCxaYfw 0OMfKDU1jkAlpVUYkvK5m+dfi1yiL9qKqCsc4N4EOGNeWOD0E92tfrhffuTS1let1yPt Q2ADkOJBYoYvE3hZCQ3vzRe1bd4KsszHP+64SVDJtiOqirz8nttLy6d5e9xWl2YTkOQV XKAJjmPcvRTsIWmZORHiX4P5O7KL/6NEh32sEiZg4IYNQEfjCNPKysexb61QKpe2P2AP uBF90PHf0Z6DfEvb3899CmoRDDzupLKhSVfElgrK93tZFFH3QVsWgibDAZ80uJPQNdex 5+nA== 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; bh=glSQZFm7ys+cLEa0wg7dCBHtIduDXujsNwJL2d9Q+I0=; b=CFEdolmSoVT+PooABhjWgwBnUrGrlRrBOuwzvSQ6eZgogr59pI2sX0vZMnYF1REagp 1o8zx3wkmLLGjcTWt8GKYKylTczRYe//TOvzmgCPFt5e5XyBGr7FUbeC3xZr9jlXWzBe 36DphP+nsfi0CM3S+aJbuwvxT5riQkQxFqus3KCdsTcq7kd1jV8xphiD4i1wfdjKGFtH 6psaj2qNBrAHohv7ttwBkQxmaSae+Byu/cDjXbf/NuvfzRpFBmjeFF+9ypPwLn0ZTnrK Y9Fv6wMwNRx9HLuFTxbH13bARlcr6Ow4uV9S1j0VYk7NabInw7gNq8fsNq5WpVLXbjmu 2bXQ== X-Gm-Message-State: AOAM5301j1mc/UaN1hyCk6XulPoWVSnjDkzHrU3H5tZvoACDbdGyGlVE 2NX5pBXd3xp9oD4gQaGYVxrHlQ== X-Google-Smtp-Source: ABdhPJwnZMN7wItnqdmCQNXmc8Fzi/hRItUqa329drQ/ARnFk3gh9eNckgGM9hg+UWfxBYZjxbciLQ== X-Received: by 2002:a17:90a:3002:: with SMTP id g2mr3156915pjb.68.1594876345975; Wed, 15 Jul 2020 22:12:25 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id y7sm3247268pfq.69.2020.07.15.22.12.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:12:25 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 4/7] arm64: perf: Only advertise cap_user_time for arch_timer Date: Thu, 16 Jul 2020 13:11:27 +0800 Message-Id: <20200716051130.4359-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011228_122272_54A99280 X-CRM114-Status: GOOD ( 13.78 ) 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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1043 listed in] [list.dnswl.org] 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 From: Peter Zijlstra When sched_clock is running on anything other than arch_timer, don't advertise cap_user_time*. Requested-by: Will Deacon Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Leo Yan --- arch/arm64/kernel/perf_event.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 47db6c7cae6a..c016b116ae33 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -1170,16 +1172,15 @@ void arch_perf_update_userpage(struct perf_event *event, unsigned int seq; u64 ns; - /* - * Internal timekeeping for enabled/running/stopped times - * is always computed with the sched_clock. - */ - userpg->cap_user_time = 1; - userpg->cap_user_time_zero = 1; + userpg->cap_user_time = 0; + userpg->cap_user_time_zero = 0; do { rd = sched_clock_read_begin(&seq); + if (rd->read_sched_clock != arch_timer_read_counter) + return; + userpg->time_mult = rd->mult; userpg->time_shift = rd->shift; userpg->time_zero = rd->epoch_ns; @@ -1209,4 +1210,10 @@ void arch_perf_update_userpage(struct perf_event *event, userpg->time_mult >>= 1; } + /* + * Internal timekeeping for enabled/running/stopped times + * is always computed with the sched_clock. + */ + userpg->cap_user_time = 1; + userpg->cap_user_time_zero = 1; } From patchwork Thu Jul 16 05:11:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666667 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 32CB413A4 for ; Thu, 16 Jul 2020 05:14:02 +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 0A65B207BB for ; Thu, 16 Jul 2020 05:14:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G4SUId67"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bh5ySB4x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A65B207BB 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:References:In-Reply-To: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:List-Owner; bh=zOE8UIrzNJa+MWzWk8y/RmYJ2dNUE/0P1Ikh82B+Zvg=; b=G4SUId67LvfLUIkDahz25qgFfV QpdhO6RFn3XMbdNeWb2WF4i1ZFA5E/0rzTYsAXGlPk/hKPIXxn+5cy0TkjvLNbliOTNINScPMyNI9 b1r9THKP3tOwfl/74Ld/679Vw0AgeDQNDJoonLOULh84GW22G15ZjUCLx8poULKmHra8dmQCsGQF2 BGLyEVw82Sryke7tXzqRL5dKsdazATqadgL35c0g03GCgMGbKC1FEuvwo2pvZu8dt+5sEHqiEYQw8 9/v6QfV/KEnjxrm075NHfKNeMOwdqt4hjAvHRQFGwH0eG+LWo89p+AcIdYjv5OSY8OT32PE2si5kk sYyzq/Pw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwCH-0005fL-Bm; Thu, 16 Jul 2020 05:12:41 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwCD-0005dO-Mq for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:38 +0000 Received: by mail-pg1-x544.google.com with SMTP id k27so4260104pgm.2 for ; Wed, 15 Jul 2020 22:12:37 -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; bh=1eiDx750W5TLv9xcl+J4+klU55EJ+/NLxR5IMbapo/w=; b=Bh5ySB4xAmR52HC1OH0iXNGC70GZFINorsNKoAexjqz5/RQbvbOhLzF+zVjwhiKXud Wv6mI91XeQrXw2gOMKprlLbs2qPcKNK9jdA3dLOQ7J3U35/A0VYpYFzyaSFWcNSAHslK c2xnAjYkSJEpOvFxYOtpWX6w1ufOvI0eXWxVoHOoHe4QPtr0KfYhJqYW9iIBjVYbmv1c J/3jTzOH1qvz8YyVffpocpLlGapdbR6m54sPIjPe0Uyk1lvcuOwnlM/89YPz3jmH8q58 aEeb9zGlQmmPy2p7ey12hb8lpepPgEShlkr9hQAJRZg7NmwB4mRL7xMgajtKp++9eCl/ Cq1A== 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; bh=1eiDx750W5TLv9xcl+J4+klU55EJ+/NLxR5IMbapo/w=; b=VhR30CBt2Pp289V/3iVmsPVcorHCIaVMD/R/4jQpHGzylKjzbTgTFDpvDL6wGNYXDE nzuW8qWb2D4fsZCMwgJz7+8aLVuMkMtSU83r+IKP2keycGHExcfvTfScSff0iqfz7hoI c0FG1+VGS8W1Q+j85fYHBsM0x+vHi+zMX7YGnK2U1plpropEOeUrbEW9PrWv10vBQwyO KNiIXEV8FEiHQcZ76jlKaHtY8qkxCitMHJXOkx5vvJUWJ8HDiVTfDR6u2KDBg1mcHp8d /BVQ+GGMev23JX76iVmJKtke/a6e/JQPMN1o46U40p3Yhz94tVDA6U5e72hTNf6kBpH/ jbtg== X-Gm-Message-State: AOAM531NFnKk6xsbHIPW/AhxJJWyiR/2Pg6tu6BDns0uxXWWLfILlfxA giuYhWQDO0Dwu4YZyqw0WBppxA== X-Google-Smtp-Source: ABdhPJxWZ4yrWVleVc9uo+BhXQllLqdxl67XUscUvWSXbZ8qaPwQyIVvxGNtPCOShlN2uq6b716gjA== X-Received: by 2002:a65:64c5:: with SMTP id t5mr2833586pgv.28.1594876355312; Wed, 15 Jul 2020 22:12:35 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id m16sm3602382pfd.101.2020.07.15.22.12.33 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:12:34 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 5/7] perf: Add perf_event_mmap_page::cap_user_time_short ABI Date: Thu, 16 Jul 2020 13:11:28 +0800 Message-Id: <20200716051130.4359-6-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011237_775389_80A9B273 X-CRM114-Status: GOOD ( 16.65 ) 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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 From: Peter Zijlstra In order to support short clock counters, provide an ABI extension. As a whole: u64 time, delta, cyc = read_cycle_counter(); + if (cap_user_time_short) + cyc = time_cycle + ((cyc - time_cycle) & time_mask); delta = mul_u64_u32_shr(cyc, time_mult, time_shift); if (cap_user_time_zero) time = time_zero + delta; delta += time_offset; Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Leo Yan --- include/uapi/linux/perf_event.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index 7b2d6fc9e6ed..21a1edd08cbe 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -532,9 +532,10 @@ struct perf_event_mmap_page { cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */ cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */ - cap_user_time : 1, /* The time_* fields are used */ + cap_user_time : 1, /* The time_{shift,mult,offset} fields are used */ cap_user_time_zero : 1, /* The time_zero field is used */ - cap_____res : 59; + cap_user_time_short : 1, /* the time_{cycle,mask} fields are used */ + cap_____res : 58; }; }; @@ -593,13 +594,29 @@ struct perf_event_mmap_page { * ((rem * time_mult) >> time_shift); */ __u64 time_zero; + __u32 size; /* Header size up to __reserved[] fields. */ + __u32 __reserved_1; + + /* + * If cap_usr_time_short, the hardware clock is less than 64bit wide + * and we must compute the 'cyc' value, as used by cap_usr_time, as: + * + * cyc = time_cycles + ((cyc - time_cycles) & time_mask) + * + * NOTE: this form is explicitly chosen such that cap_usr_time_short + * is a correction on top of cap_usr_time, and code that doesn't + * know about cap_usr_time_short still works under the assumption + * the counter doesn't wrap. + */ + __u64 time_cycles; + __u64 time_mask; /* * Hole for extension of the self monitor capabilities */ - __u8 __reserved[118*8+4]; /* align to 1k. */ + __u8 __reserved[116*8]; /* align to 1k. */ /* * Control data for the mmap() data buffer. From patchwork Thu Jul 16 05:11:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666669 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 CEB2D13A4 for ; Thu, 16 Jul 2020 05:14:13 +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 A69A5207BB for ; Thu, 16 Jul 2020 05:14:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R4fLnWSU"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="krIWOXFg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A69A5207BB 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:References:In-Reply-To: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:List-Owner; bh=JLVAHmV7sIXWynu7GAKbPDHjPlwXFJvXzIqNBGq8/yY=; b=R4fLnWSU3fLDLhHEidGnuxmSvR K1Fy8krnyOI2SWoSiu96MzJfiKms8KZ3aItOEYBDezDiYnSuAkEEMgdabJbBftm1BCCa9NMB9OesU ADZ4svZ3O9oSUizc8Qj4lF/IRDk8MjxvHUdH1P6k8gGEMrsntwE7yvR7e+jSGFalQLQyuGLGv6hC4 MHxKE/AGuOwUKWwj1JyrYmSszSGSrapNZSG6gUS/cFKWh3bWCm5cZddEH9fcEm8zu1qlrSQuXJUZl kZEyGFa2FC19eV/MmG97ZrO5EdiRbBxQseqp3srlsJptWutr1Ukc2+3dKdZDHbvUUPTB62uVAH8IE Fo/rqblQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwCR-0005ju-AV; Thu, 16 Jul 2020 05:12:51 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwCM-0005hC-RP for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:47 +0000 Received: by mail-pl1-x641.google.com with SMTP id m16so3358059pls.5 for ; Wed, 15 Jul 2020 22:12:46 -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; bh=9SuwXG5wYWJjKAU5flve9nJ1dK7+MJYoWmtIlrptV4I=; b=krIWOXFgIeM3ecJz/r74xx6HpdmDjHKKU8d9VmYrCjaWOM76YlH8WKFVtDlhMXxJCV N1kshlioH70saQvzgIiD65BamQnO4wxV8dDroEHJx9BpV+u3dPt5Gx3L6SX3Zb9r80Ab b3GJ3j7tjwTDQm7q7A1ZYBHDKzhZwJSCyIiegcXYthgzta8sT+dPfBYyVprpkKjzm4GS nPO1b6tGOKS+ihfG4Sc58vMmdbRyqxsjsIouW60F8Fn1zkuEeqVBkVLqIB5Dw0jMBmeh nmz3G6ZdO12uxRk1zXHRxurZueMzMS5BkuJ3HkkwYGk3dtWmbExR1yxyOccsZSUwptA/ ckDg== 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; bh=9SuwXG5wYWJjKAU5flve9nJ1dK7+MJYoWmtIlrptV4I=; b=qnUfEl84dNk4Nw7AMHWijcjTMYjIinZY9UdUbr8sLvXr3lmiVyFmfCKKUTa4GzljUG ACutQUj3wyM7NXZnuwnVYA2k6NRy5/s9cWuPqqiO9um8YewmhvnNV4TXt40LNnf/MEJM 0IVe0yfeB9sTuckTOQBOyYeu22vYp/wUXKbF46koonn1uKwuIZwmImYpnILAfX8rSwKL UGl5HNVqG5ceY3dpKnqvslNxVR74iEjsnKPJ6zogYL1/V/4OaKK3DGsc7MEWP5kFONyb 1BD+Wh9uIJqW9sVHD7sNXN8SRcnG4QqH5+O+793ET5JUlWJ8FG0ws5rOx0MYfaBCGi4v urKg== X-Gm-Message-State: AOAM5337YuaWL3/wtcAQm+/zANJDkvhbjNwqOIoyPIilo0Ueg239sL1d yIlVD4OoHNROYjfTn1sDi8FGGQ== X-Google-Smtp-Source: ABdhPJzOQxiFHywkTQOU5cdSK+Q4FRgeK3RFG1TxHSXZ1LJrkJiq2mpEHfQHBWxgWjUYdMVODsOS/g== X-Received: by 2002:a17:90b:4b12:: with SMTP id lx18mr3346143pjb.156.1594876364801; Wed, 15 Jul 2020 22:12:44 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id n25sm3525709pff.51.2020.07.15.22.12.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:12:44 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 6/7] arm64: perf: Add cap_user_time_short Date: Thu, 16 Jul 2020 13:11:29 +0800 Message-Id: <20200716051130.4359-7-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011246_973900_ECE276B9 X-CRM114-Status: GOOD ( 12.70 ) 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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 From: Peter Zijlstra This completes the ARM64 cap_user_time support. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Leo Yan --- arch/arm64/kernel/perf_event.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index c016b116ae33..888bcb5d1388 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -1174,6 +1174,7 @@ void arch_perf_update_userpage(struct perf_event *event, userpg->cap_user_time = 0; userpg->cap_user_time_zero = 0; + userpg->cap_user_time_short = 0; do { rd = sched_clock_read_begin(&seq); @@ -1184,13 +1185,13 @@ void arch_perf_update_userpage(struct perf_event *event, userpg->time_mult = rd->mult; userpg->time_shift = rd->shift; userpg->time_zero = rd->epoch_ns; + userpg->time_cycles = rd->epoch_cyc; + userpg->time_mask = rd->sched_clock_mask; /* - * This isn't strictly correct, the ARM64 counter can be - * 'short' and then we get funnies when it wraps. The correct - * thing would be to extend the perf ABI with a cycle and mask - * value, but because wrapping on ARM64 is very rare in - * practise this 'works'. + * Subtract the cycle base, such that software that + * doesn't know about cap_user_time_short still 'works' + * assuming no wraps. */ ns = mul_u64_u32_shr(rd->epoch_cyc, rd->mult, rd->shift); userpg->time_zero -= ns; @@ -1216,4 +1217,5 @@ void arch_perf_update_userpage(struct perf_event *event, */ userpg->cap_user_time = 1; userpg->cap_user_time_zero = 1; + userpg->cap_user_time_short = 1; } From patchwork Thu Jul 16 05:11:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11666671 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 88F0A60D for ; Thu, 16 Jul 2020 05:14:35 +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 5FB35207BB for ; Thu, 16 Jul 2020 05:14:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="McEDuWGK"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CyRfgRhB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FB35207BB 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:References:In-Reply-To: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:List-Owner; bh=Bt0Pi+7pIrIRcWMKMDyKxi9EJSQlzwo8kFtij0Zct4Q=; b=McEDuWGK8SWMpgShx30FIqF+tW Q/A7ILqApVTYe3zRpC7FJSGOXk+Hx56F4OQJB72TiI6zTgwXjj3X4ahcaOCJcraIDFkvHGGWb1aB5 zSBwMTcopz9FKWtBLCpP7hLIJwTp6/n2f00jpgG/2y1FPOzPW4epInx18lqCXyyBzPmUbKK7DWMuO F5nEuck9sXChbCrTeELH+qWexxscVZPEXVGS3JLYffQjC/Mgjo9dfa37HYSZwMOPwlYCvODyiXEKv PDgSvA/SXcUxGegXscDt9cZfiuACPhKlgWc4CTRBuQwxiXb0AfnoksVGa6L4LzOvkZUFI0sC1tg9S qcr2Tybg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwCf-0005pT-8v; Thu, 16 Jul 2020 05:13:05 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvwCX-0005mt-Mb for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 05:12:58 +0000 Received: by mail-pg1-x544.google.com with SMTP id j19so4229892pgm.11 for ; Wed, 15 Jul 2020 22:12:57 -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; bh=5uEgZcOvxySkXqr8EUPn06IShVdK3dXiQkAlG2OoJgw=; b=CyRfgRhBPlbJusvWZ2r6TphLSUqOHZjwFjCUPFk4b0NBT22sQeUDaJ717mzoDj3zAz MVUZsXUGOplDpyd9M+8GVQGshB2Mo8Lc0MKq7+iTRog7lrQJNWLmqK9tVvRtwlkEEUxt N6HKAb0924maFPbitUjI2O06iGLFFngf/67TSSZD+rtoVfQEvq+U6xUWIVZPgPziTcLY c03WrC2tRZeuCnvFXyccZWdySAfelGuPrVPtzSQFremFGc8NJWz6OROOUgjlpLvpZ6uF 0l88G612fXl0BSRTEIYHmPqU46PxFQ+xAh6chUdesCpDENSxsp97o6sL0yq0hFUMKw7i EB2Q== 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; bh=5uEgZcOvxySkXqr8EUPn06IShVdK3dXiQkAlG2OoJgw=; b=gyAVcYf8i/ZJWygPnzRwDc85cchuWgvyOg4iBC1KVhlyUXAfO1UrCC5Azbk4BH09nr O5JTPcku4ccloobJvhwkYQ91m2ZEVgvJPqFIehBz6X/slCYwvde6GGxn/kv8wfSD4ula 3Ybl1CrPmZGHXdwtuu7UbWY0Gx74UdkINYPFNs9iJUJwsVsKAy1HL2Gz3pPw22n0Pi77 PfmGkGiybXDwDGCdCrNPop0DoV4Hnn+lxvLYOlSfUEQk8WA0sVWAYmBqlmugY1ho+YXq eqNKBiU1VxPMtV2uHfKyd5gSlK5Sz2464dWUI0MqJgdtwAV0+nyTAKpCa2tB7pBvTkA2 g7UQ== X-Gm-Message-State: AOAM532wLdNtgN1onIb8D9RxVeG6xE1XDQCNYfsiwL2L2ePNbLC/Fj69 JPUBCiUJ1aluKkIBfDOtPgU+5cOVD51Kqg== X-Google-Smtp-Source: ABdhPJyMvmCqRalWIJW5f9/g7nrURfOw7B8xkuE0x7liIs+vZhTKT7UKjFTL2WrzuJNWEe8iDMSN3A== X-Received: by 2002:aa7:988f:: with SMTP id r15mr2227739pfl.2.1594876375762; Wed, 15 Jul 2020 22:12:55 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id az13sm3449882pjb.34.2020.07.15.22.12.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jul 2020 22:12:55 -0700 (PDT) From: Leo Yan To: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , "Ahmed S. Darwish" , "Ben Dooks (Codethink)" , Paul Cercueil , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 7/7] tools headers UAPI: Update tools's copy of linux/perf_event.h Date: Thu, 16 Jul 2020 13:11:30 +0800 Message-Id: <20200716051130.4359-8-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200716051130.4359-1-leo.yan@linaro.org> References: <20200716051130.4359-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_011257_856009_C66DC299 X-CRM114-Status: GOOD ( 16.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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 To get the changes in the commit: "perf: Add perf_event_mmap_page::cap_user_time_short ABI" This update is a prerequisite to add support for short clock counters related ABI extension. Signed-off-by: Leo Yan --- tools/include/uapi/linux/perf_event.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 7b2d6fc9e6ed..21a1edd08cbe 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -532,9 +532,10 @@ struct perf_event_mmap_page { cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */ cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */ - cap_user_time : 1, /* The time_* fields are used */ + cap_user_time : 1, /* The time_{shift,mult,offset} fields are used */ cap_user_time_zero : 1, /* The time_zero field is used */ - cap_____res : 59; + cap_user_time_short : 1, /* the time_{cycle,mask} fields are used */ + cap_____res : 58; }; }; @@ -593,13 +594,29 @@ struct perf_event_mmap_page { * ((rem * time_mult) >> time_shift); */ __u64 time_zero; + __u32 size; /* Header size up to __reserved[] fields. */ + __u32 __reserved_1; + + /* + * If cap_usr_time_short, the hardware clock is less than 64bit wide + * and we must compute the 'cyc' value, as used by cap_usr_time, as: + * + * cyc = time_cycles + ((cyc - time_cycles) & time_mask) + * + * NOTE: this form is explicitly chosen such that cap_usr_time_short + * is a correction on top of cap_usr_time, and code that doesn't + * know about cap_usr_time_short still works under the assumption + * the counter doesn't wrap. + */ + __u64 time_cycles; + __u64 time_mask; /* * Hole for extension of the self monitor capabilities */ - __u8 __reserved[118*8+4]; /* align to 1k. */ + __u8 __reserved[116*8]; /* align to 1k. */ /* * Control data for the mmap() data buffer.