From patchwork Wed Jul 15 02:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11664037 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 D1A93138C for ; Wed, 15 Jul 2020 02:07:26 +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 A818020663 for ; Wed, 15 Jul 2020 02:07:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G+dOVAwL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OKwq59of" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A818020663 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:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wtLBZ6FhIg49u4I3eTYz7vXLPAZOZorjyd/eRLsYadw=; b=G+dOVAwLBD/qvk3CKrrvFNfuZu UQ4yjXJlo+vJjYHlj3Mn6LsF4VsAh4aV82Hbgq8S5fSCGLBRfoChBucBpn1AQqvDfRKpyKa8eFBXZ 7TkHSghUly0UFpuQy/CN5qbTFdFqKmGux/Bw6v1DRotZmM3kiJAote/QoBKzfaOEZno0SbQcSdvLS gVJo8do0qEgrWpSdqRihgxPlJ5QqTOYf4hhqC1SU0x2Eb4w0kVbRGOVNs53oC8mUfWlJmW+BM+Znh T5JTQDOXFLEnTm8CYC74UsMrhpKHTBclY2/kydJsT2y35N0wdLef3D/hoXtSqUd1OlQURYZgvhpYQ vd9vXzMg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvWo6-0007S2-VV; Wed, 15 Jul 2020 02:06:03 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvWo4-0007Qh-4I for linux-arm-kernel@lists.infradead.org; Wed, 15 Jul 2020 02:06:01 +0000 Received: by mail-pl1-x643.google.com with SMTP id q17so969229pls.9 for ; Tue, 14 Jul 2020 19:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=ipEKOYUy0lWTBEiPnpX/QvgsPhGjR8M5oL+bv/+PVNY=; b=OKwq59ofEQvjl0rf8+qoNtlQqNXL5ng/x/i7+TUUKBCxrzu9o/bYZHlpHT2ipdlMH8 2sQ2Zz1lI65U364bGf66i119BtLUXETXBZk/dOs8LATJu5y3rkIygcwxAw5728KpNeKi jDhC46l3d64ZwdCPTL7pwDU2H6y7/6Q4RqzfTgl+qE/2UvbEK1wWZgHT5S2SMJjcbXnf IEHaGBzPFqfqpInLB5qWTvfhsZct2wRTcjuIsBxDVZ67SXUFSTkBXdnRCOciKV1mmySY BQgD+hC7EOxhuh6NeZiZvedcgjNwCXH6HxVTNRgf+6TWFDAuOrP/3JUKAqC5SHjbgwFL L0TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ipEKOYUy0lWTBEiPnpX/QvgsPhGjR8M5oL+bv/+PVNY=; b=CGADgozxqe7sjt3x2nZRjPPSGbpa15AN4DdVSRkjZXoxb89Y44F+XldQ5YVYne7YFW D1IPo5Fox6Tw2iYHIuzA5JZRrxRMSJRiKefDS7dEs0Aw/DL0rEEvgLb76XYpdlw3TDMc ogAH8xA1RYow0fVVghXuvwAvVl5uqeYpCOWa1lrrO3EbZd7mEEBYVYFffPfPwGazNO4T 96iWfD8BBbs0Vv/KhbqzpKm6eBiAZWbTqo8UGkBDWnx99TaYUvGWEdantZKQHwasqzGd iNtVQNwij27ar2Gs5+DxAopW6NgXcCiw6Jx4c1iyXvQQmxQd2oa2YXq59TPYqpqFwsft pEiQ== X-Gm-Message-State: AOAM532+2itcBI1r18V/bb5447AxMjw34ox+nJ7mYPY6rHeOYdUPkmOb YV+kQwdOAElHA+gDGEcmrpkguQ== X-Google-Smtp-Source: ABdhPJzCo/QzGIKdS2L42Rixd5oGY6ofdxrVlSJJ+PcSZI2ghr06QlESXk2/1dne8fRw0HHyOKflwA== X-Received: by 2002:a17:90a:db8a:: with SMTP id h10mr7811371pjv.197.1594778758276; Tue, 14 Jul 2020 19:05:58 -0700 (PDT) Received: from localhost ([2400:8904::f03c:91ff:fe8a:bbe4]) by smtp.gmail.com with ESMTPSA id q1sm376592pfk.132.2020.07.14.19.05.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jul 2020 19:05:57 -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 4/6] perf: Add perf_event_mmap_page::cap_user_time_short ABI Date: Wed, 15 Jul 2020 10:05:10 +0800 Message-Id: <20200715020512.20991-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715020512.20991-1-leo.yan@linaro.org> References: <20200715020512.20991-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200714_220600_204629_8AEC477D X-CRM114-Status: GOOD ( 16.12 ) 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:643 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: , 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) --- 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.