Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2783738ybg; Thu, 24 Oct 2019 15:18:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqynGAgwLkyz3xsZaiZhiNvyS1eZefbtubLl3+Q7WAWBM7kKAtkPNMgfvr0fp4wY6kFmmWtD X-Received: by 2002:a50:ab01:: with SMTP id s1mr543156edc.192.1571955518157; Thu, 24 Oct 2019 15:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571955518; cv=none; d=google.com; s=arc-20160816; b=jMmuRuHA/eceJeeKmYl3JdxYrWqyHUgTWjn5Yh4f+j2xD9/winwkcT2NtD0Nx1oiP+ 7/YQzGAZeWOEIt/JZk7b5CRDRjdClcd7i1yy1KzAdMGIoiQ2oeL0+SM21LS6qg1rWQEi /Zisgd1IPkk+skYBcrgnUXpZKokhzGuBL6WEIn9IM617leRSqaNRSb21HTiVgmwU0WEN CyPq1jHbB6WK45p9K1yWU9aCoNw8Y+qJwN3S8OpTYIXYW2oncXkCKmEcUpSNxOlKvEfr 6AtaiJR9XlOSxi/XVexJ18s2QFt/+vSsYHdMolVITB1miSRczwqvZ8SwRgH43ePKufxL iU5A== 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; bh=pRqVhK77k7N7bPfZVJ9Nde/GnB+5c+0cKQv8vQBSWwA=; b=IUXH2zgU/HJLRqT95gSaJUhGH4omdvyECXtN1TDGhoCDD86dGpka+757CNKp1mRoww 9/uGr+poyXrl8/4DJzDLaAxGy3bKjH3TNegQOh4l6apTUAdOEJHZmI14rO/HFT+wA06A vs1pz6l8xeLh6Iosu+1LoGZIeYjoTGhG21dbxb0mrVERcMqvMr+ZMHD0sQE6ln72Wc2Y HDby6Nks3Y4h7J1wwx0gp9zkcLdXegF6dO/Ffo6n6pnF1xIP85WOvpTe5klJUMkqYC/K MlrqXp5wORmTMgDjVf/XGW/Ox7qki1edTjw7pO2YDdFyDE+NUudklcYzSRslqHJLkMo6 oAwA== 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 h21si2139853edb.20.2019.10.24.15.18.14; Thu, 24 Oct 2019 15:18:37 -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; 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 S2437674AbfJXGBX (ORCPT + 99 others); Thu, 24 Oct 2019 02:01:23 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:55705 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437466AbfJXGBW (ORCPT ); Thu, 24 Oct 2019 02:01:22 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07436418|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.199964-0.0374202-0.762616;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03289;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=3;RT=3;SR=0;TI=SMTPD_---.FpdA-Fy_1571896877; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.FpdA-Fy_1571896877) by smtp.aliyun-inc.com(10.147.42.16); Thu, 24 Oct 2019 14:01:17 +0800 Date: Thu, 24 Oct 2019 14:01:17 +0800 From: Mao Han To: Nick Kossifidis Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: Perf-related compilation issues Message-ID: <20191024060116.GA786@vmh-VirtualBox> References: <1bba622b-1f59-d21b-f396-d9c1a021dc3a@ics.forth.gr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1bba622b-1f59-d21b-f396-d9c1a021dc3a@ics.forth.gr> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 06:15:43PM +0300, Nick Kossifidis wrote: > Hello all, > > a) Compiling the current fixes branch with a minimal config I get the > following error: > > riscv64-unknown-linux-gnu-ld: arch/riscv/kernel/perf_callchain.o: in > function `.L0 ': > perf_callchain.c:(.text+0x16a): undefined reference to `walk_stackframe' > make: *** [Makefile:1074: vmlinux] Error 1 > > > I've removed the static delcaration of walk_stackframe on stackframe.c > and marked walk_stackframe as extern on perf_callchain.c to fix the > above issue. > Beside the compile problem caused by: [PATCH v3 5/8] riscv: mark some code and data as file-static similar issue may happen when CONFIG_FRAME_POINTER is not defined. I didn't see the CONFIG_FRAME_POINTER in stacktrace.c, and the conditional for !CONFIG_FRAME_POINTER looks quite strange, keep adding the sp and read pc from that? ksp = (unsigned long *)sp; while (!kstack_end(ksp)) { if (__kernel_text_address(pc) && unlikely(fn(pc, arg))) break; pc = (*ksp++) - 0x4; } A conditional for perf_callchain_kernel might be properly to fix that. --- a/arch/riscv/kernel/perf_callchain.c +++ b/arch/riscv/kernel/perf_callchain.c +#ifdef CONFIG_FRAME_POINTER void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg); void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, @@ -92,3 +93,4 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, walk_stackframe(NULL, regs, fill_callchain, entry); } +#endif > > b) Then If I compile the kernel without CONFIG_RISCV_BASE_PMU I get > > > ./arch/riscv/include/asm/perf_event.h:26:2: error: #error "Please > provide a valid RISCV_MAX_COUNTERS for the PMU." > #error "Please provide a valid RISCV_MAX_COUNTERS for the PMU." > > > I noticed that the only place where CONFIG_RISCV_BASE_PMU is checked is > on perf_event.h and only for this parameter that's not defined anywhere > else. So for now if one tries to compile the kernel without PMU the > kernel won't compile + I don't see how unsetting this saves code size as > the config description says. > The content inside perf_event.h mostly relate to HW PMU. Other architectures normally put them inside perf_event.c or pmu.h, they are not compiled when CONFIG_PERF_EVENTS is selected and HW PMU is not selected, user can use software event under this configuration. Base pmu shouldn't be registed when it is defined in dts. I think it can be fixed by put the content inside perf_event.h into a riscv_pmu.h, only compile perf_event.c when CONFIG_RISCV_BASE_PMU is selected or add conditional inside it: --- a/arch/riscv/kernel/perf_event.c +++ b/arch/riscv/kernel/perf_event.c @@ -474,12 +474,13 @@ int __init init_hw_perf_events(void) if (node) { of_id = of_match_node(riscv_pmu_of_ids, node); - if (of_id) + if (of_id) { riscv_pmu = of_id->data; + perf_pmu_register(riscv_pmu->pmu, "cpu", PERF_TYPE_RAW); + } of_node_put(node); } - perf_pmu_register(riscv_pmu->pmu, "cpu", PERF_TYPE_RAW); return 0; --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -38,7 +38,7 @@ obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o obj-$(CONFIG_DYNAMIC_FTRACE) += mcount-dyn.o -obj-$(CONFIG_PERF_EVENTS) += perf_event.o +obj-$(CONFIG_RISCV_BASE_PMU) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o Thanks, Mao Han