Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3422663ybi; Fri, 19 Jul 2019 03:03:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNOKyz3FSlmPxeap36MAQooVNkjyprzn/VAZmw21yS5vXfHkt3z2csco36x34XoG5DxFJa X-Received: by 2002:a63:d950:: with SMTP id e16mr55395126pgj.271.1563530597034; Fri, 19 Jul 2019 03:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563530597; cv=none; d=google.com; s=arc-20160816; b=Cn8dHSlQZmsh5XQwcZCVMiT+TTc07LdIpMYGtfZIzujNowkuipsXlZxYPhzRHIeKLT W/CfiQDQccjNULzs6+kEINSxEUAkKH6CzGHGowLkZh9NvfAk12gHDYLe+GoLcjU7WKIq vfCrQMH1QnQCPOBBk+FEkXdPopF8zpR+h+HYDjAPxmtQ3LyikT7DVeOknzhoQ1OaCxfP LvskS0MdBb80w6Bh0qegAwLqHccY5CNetUZ7V2YpaBc3oQ6hOzY1Po+1E+8ULI7uw3fX 1EtKZ+B+pM+kYxSt9CTPk/23Q+sfdedCdhl0URnI3gVdzu8zI+WUrUNMkm5NZANpGYBR h5/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1cUmeMwfdJCuMla5v8g+z3khJrUovvnxetIOZ9jROUA=; b=ZvOVrV1nw6qmZSj6i49j4Z+nseOS0qnVwofQRYYEWsQftqXM5eQlaeF/y8Q96/AWEK h1l7+ST6JyR9VvXVdxuau+zCHGoLb7d8LiyfJGitfxCocjp14HrhYkkMv1gtrnL4v0xt er03ABRKzJN1vupZzoOhgiMIcCBotKx1NTLIJi8A1dG3DGtf+DK5LtF5BeAXlBFcZYq+ e5WJWW4zyuR79JngH9PUoer5mEvveF+dWqefNHrv+APv8hEtEDmyPG25aneAZ0ZqBDKy z91G/e7eADdOfvTMAEa/Rvi5sfrcdtsnw47X1VpOD0n9odM0dWl+Sk0FFtmljlO4SAcm O0qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ngDBnyyv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b38si992735pla.137.2019.07.19.03.03.00; Fri, 19 Jul 2019 03:03:17 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=ngDBnyyv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbfGSKC0 (ORCPT + 99 others); Fri, 19 Jul 2019 06:02:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:36390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbfGSKC0 (ORCPT ); Fri, 19 Jul 2019 06:02:26 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3DF302173B; Fri, 19 Jul 2019 10:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563530545; bh=KvPLM1GNe5tFVjsJpLtAS+Cc5JSEL3ozQZTgGhM2Zj0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ngDBnyyvbzeDdeqaWe1yYZ14j969anbfifz4sULg2Y/9mfJfcN2ruBIKYgfHGrwXv RK6jQPeP2tF0RC6ZW5ZWHe7piD8IkfoGr1N8FVpUiEllxkKqG6jvPfz5Eo+0qxU4FW pwk+O2cge3NeLPhjy9rKqiqtFbFtbFxsxPikY1Nw= Date: Fri, 19 Jul 2019 11:02:20 +0100 From: Will Deacon To: Joakim Zhang Cc: "peterz@infradead.org" , "mingo@redhat.com" , "acme@kernel.org" , "jolsa@redhat.com" , "namhyung@kernel.org" , Frank Li , dl-linux-imx , "linux-kernel@vger.kernel.org" , "mark.rutland@arm.com" Subject: Re: [PATCH] perf tool: arch: arm64: change the way for get_cpuid_str() function Message-ID: <20190719100219.b3bbrv4t4qcv2gid@willie-the-truck> References: <20190718061853.10403-1-qiangqing.zhang@nxp.com> <20190719075450.xcm4i4a5sfaxlfap@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 19, 2019 at 08:29:12AM +0000, Joakim Zhang wrote: > > On Thu, Jul 18, 2019 at 06:21:30AM +0000, Joakim Zhang wrote: > > > Now the get_cpuid__str function returns the MIDR string of the first > > > online cpu from the range of cpus asscociated with the PMU CORE device. > > > > > > It can work when pass a perf_pmu entity to get_cpuid_str. However, it > > > will pass NULL via perf_pmu__find_map from metricgroup.c if we want to > > > add metric group for arm64. When pass NULL to get_cpuid_str, it can't > > > return the MIDR string. > > > > Why is this code passing a NULL PMU? What information does it actually need? > > Other functions, such as print_pmu_events(), iterate over all PMUs. > > tools/perf/utils/metricgroup.c: > metricgroup__add_metric()/metricgroup__has_metric()/metricgroup__print()---->perf_pmu__find_map(NULL)------>perf_pmu__getcpuid(NULL)----->get_cpuid_str(NULL) > So, it will eventually pass NULL to get_cpuid_str() function for arm64, and now get_cpuid_str() for arm64 need *struct perf_pmu* entity to return MIDR string. > > And the declaration for get_cpuid_str() is char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused) in tools/perf/utils/header.h file. > So, it can return MIDR string without passing *struct perf_pmu* entity. Arch PowerPC/x86/s390 which implement metricgroup all add __maybe_unused. > > > > There are three methods from userspace getting MIDR string for arm64: > > > 1. parse > > > sysfs(/sys/devices/system/cpu/cpu?/regs/identification/midr_el1) > > > 2. parse procfs(/proc/cpuinfo) > > > 3. read the hwcaps(MIDR register) with getauxval(AT_HWCAP) > > > > > > Perfer to select #3 as it is more simple and direct. > > > > That's probably terminally broken for heterogeneous systems, so I'm not at all > > happy with this patch. > > The implement of get_cpuid_str() for arm64 now only can return the MIDR > string of the first online cpu. I think it is also broken for > heterogeneous systems. I disagree: the current code returns the MIDR string for the first online CPU *corresponding to the PMU* (e.g. pmu->cpus) and therefore handles heterogeneous systems like that. > Will, do you know how to fix this issue more reasonable? I still don't know what the metricgroup coce is trying to achieve, but my previous suggestion about looking at print_pmu_events() is probably still a good place to start. Will