Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp37805imu; Tue, 27 Nov 2018 07:31:41 -0800 (PST) X-Google-Smtp-Source: AJdET5ciSRHPzi313yDdrGV3audctJeRxL4Z47CAV5Pb0Vf6IIBz6N24OOhBUd38JdCZsTROU+GO X-Received: by 2002:a62:f247:: with SMTP id y7mr33402911pfl.25.1543332701700; Tue, 27 Nov 2018 07:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543332701; cv=none; d=google.com; s=arc-20160816; b=v6T6JLZ39LUgGE4Yeqr9jGT+SBppdb1MVmIHKTX5j8UZ8vVBwv1Agg2VL+CtS45KLk MG9byRXSYstoL18c/tsIvU4fpHqeUzDiExXOKK/4l8hQz4VEZJVwHIOHc/d4FjjASl30 lr1fxlRYiuL8FcsD56C8rkn488WunTQkQWA5o+AHuj7apzY5ACHxqT1KDrqiKctuWS+Y F10Owsxqu7mnDKe69k7yTujDuXGJB75O9s772LZf0jSZS7vm9OcO7UgwEuJEMXhndorA ShU1l7LLniBIcGi3y3bh/dDViZcDBDBwGs6IjFVKhTxflT6/8xXNvK055zaBsrnTaiFX DCUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=S74wr0aRj+tOhoc5Fh8+2l4EqvMCvLQ23HTIxg0Txd0=; b=GTd3nm1SfVQzRsE7SPik3m3247+u6RquE/nJdvyJWMSEFVxZdTfjCQCMdQQvGMEqI3 91WM9Bf8KlCPj07lCjofHUSbJhzeQ2M6KfCY6e3t0yXN38RNYGZt5EXIjE9SJrgEaUwM BpRO9rdUPew3StcMrd+ja2qhq8we9GryfDb5NwqjPU9CgLoXBaC+vf5g+cuoD/qCWigO 6Zl70nsbbz/c8yaC9YSKUCH2QDWrVGqQUcu68SNA6tN3pesjVMcVaqMub9h12oKBhkCq 57pUN7Km3uv8rTRN2SgwU4KbcrrOXUN72ywKNkuaJbOpLbe5bxWTkIekKBiNycTLUABp 7/JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si4084445plb.253.2018.11.27.07.30.40; Tue, 27 Nov 2018 07:31:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729719AbeK1C0p (ORCPT + 99 others); Tue, 27 Nov 2018 21:26:45 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:40098 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726699AbeK1C0p (ORCPT ); Tue, 27 Nov 2018 21:26:45 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DA127364A; Tue, 27 Nov 2018 07:28:28 -0800 (PST) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A291A3F5A0; Tue, 27 Nov 2018 07:28:26 -0800 (PST) Subject: Re: 'branches' perf event mapping differs on ARC and ARM To: Eugeniy Paltsev , "linux-arm-kernel@lists.infradead.org" , "linux-snps-arc@lists.infradead.org" Cc: "mark.rutland@arm.com" , "peterz@infradead.org" , Vineet Gupta , Alexey Brodkin , "will.deacon@arm.com" , "linux-kernel@vger.kernel.org" , "acme@kernel.org" , "alexander.shishkin@linux.intel.com" , "mingo@redhat.com" , "namhyung@kernel.org" , "jolsa@redhat.com" References: <1543329386.13651.13.camel@synopsys.com> From: Robin Murphy Message-ID: <48cfcbf3-0084-7b17-f30d-371bbb5cbdde@arm.com> Date: Tue, 27 Nov 2018 15:28:25 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <1543329386.13651.13.camel@synopsys.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/11/2018 14:36, Eugeniy Paltsev wrote: > Hi, > > While playing with perf tool on ARMv7 and ARCv2 processors and profiling the > same application I got interesting results. Even if we got pretty > similar total > execution time and instructions number the number of branches on ARC is about > three times more then on ARM. > > I dug into architecture > specific perf sources and found that we map different > HW counters into generic 'branches' event on ARC and ARM. > - We use "ijmp" event on ARC which > counts all jump and branch instructions (regardless > of real execution flow - even if no real jump happens) > - We use "pc_write_retired" event on ARM > which counts only taken branches (Instruction > architecturally executed, condition check pass - software change of the PC) > > So I was wondering do you know > which approach is correct? > > > > I guess counting all jump and branch instructions is correct because we use > 'branches' event value to calculate relative value of 'branch-misses' using > > following formula: > ----------------------------8---------------------------- > branch-misses-ration = 'branch-misses' / 'branches' * 100.0 > ---------------- > ------------8---------------------------- > And using only taken branches here is incorrect IMHO. So I guess we should > map 'br_immed_retired' instead of > "pc_write_retired" into generic 'branches' > event on ARM. But register branches (including procedure returns) are also branches, so only counting immediate branches would be just as, if not more, misleading. Robin.