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.