From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753403Ab2BPQhk (ORCPT ); Thu, 16 Feb 2012 11:37:40 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:53707 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751589Ab2BPQhj convert rfc822-to-8bit (ORCPT ); Thu, 16 Feb 2012 11:37:39 -0500 MIME-Version: 1.0 In-Reply-To: <1329409183.2293.245.camel@twins> References: <1329323900.2293.150.camel@twins> <20120216150004.GE2641@mudshark.cambridge.arm.com> <1329409183.2293.245.camel@twins> Date: Fri, 17 Feb 2012 00:37:35 +0800 Message-ID: Subject: Re: oprofile and ARM A9 hardware counter From: Ming Lei To: Peter Zijlstra Cc: Will Deacon , "eranian@gmail.com" , "Shilimkar, Santosh" , David Long , "b-cousson@ti.com" , "mans@mansr.com" , linux-arm , Ingo Molnar , Linux Kernel Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 17, 2012 at 12:19 AM, Peter Zijlstra wrote: > On Fri, 2012-02-17 at 00:12 +0800, Ming Lei wrote: >> is triggered: u64 delta = 100 -  1000000 = 18446744073708551716. > > on x86 we do: > >  int shift = 64 - x86_pmu.cntval_bits; >  s64 delta; > >  delta = (new_raw_count << shift) - (prev_raw_count << shift); >  delta >>= shift; > > This deals with short overflows (on x86 the registers are typically 40 > or 48 bits wide). If the arm register is 32 you can of course also get > there with some u32 casts. Good idea, but it may not work if new_raw_count is bigger than prev_raw_count. thanks -- Ming Lei