From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 6108AC433E6 for ; Thu, 16 Jul 2020 05:12:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35DB6207BB for ; Thu, 16 Jul 2020 05:12:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bh5ySB4x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727910AbgGPFMg (ORCPT ); Thu, 16 Jul 2020 01:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgGPFMg (ORCPT ); Thu, 16 Jul 2020 01:12:36 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDAFC061755 for ; Wed, 15 Jul 2020 22:12:36 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o13so4268777pgf.0 for ; Wed, 15 Jul 2020 22:12:36 -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=FNT+mgvXhD5XY3C9jdkcH653EH9RqHNwSduSZYQ/JwSKx0lvo7gnzMjL9qtEy+G5b8 uFyc5yniRkfbi21kWfrjVYVNKCBdyiI7DsgFFnQxKGdvsvUJvji8nNODe+XasuU3ABaa XyNgKXEZF5yXmvldYrD7O2wQMu4b+He3FUBqwtJggC8EwYYcMbR1kwu3uztzmxoSMpLl BHBMSF8hPleSwXEuImCu3XsYGSEt6xTSsUeMubRRkX3jxhP6oCneu9M1UMCh+BpOMGF7 wX7O96oUZ/0aJvuQNInHSZrdA0i+m+m91+GpmUjv1CwkFsKuhTbiCV3LlhOycwtFKGmW X0YQ== X-Gm-Message-State: AOAM531l2b7h3tT3iUbs69ZUaYeg2GO4vE7xMa3YTurfd7lGLKDY/t9O /ybALWelujealV5hoobDGu6m1A== 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 Cc: Leo Yan 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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. -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 3A9E9C433E5 for ; Thu, 16 Jul 2020 05:13:57 +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 05074207BB for ; Thu, 16 Jul 2020 05:13:57 +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 05074207BB 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=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-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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.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. -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel