From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756908AbcA2Uht (ORCPT ); Fri, 29 Jan 2016 15:37:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44970 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756876AbcA2Uhq (ORCPT ); Fri, 29 Jan 2016 15:37:46 -0500 Date: Fri, 29 Jan 2016 18:37:43 -0200 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: Alexei Starovoitov , Brendan Gregg , Daniel Borkmann , "David S. Miller" , He Kuang , Jiri Olsa , Li Zefan , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , pi3orama@163.com, Will Deacon , linux-kernel@vger.kernel.org Subject: Re: [PATCH 28/54] perf record: Extract synthesize code to record__synthesize() Message-ID: <20160129203743.GA4941@redhat.com> References: <1453715801-7732-1-git-send-email-wangnan0@huawei.com> <1453715801-7732-29-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453715801-7732-29-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Jan 25, 2016 at 09:56:15AM +0000, Wang Nan escreveu: > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > > +static int record__synthesize(struct record *rec) > +{ > + struct perf_session *session = rec->session; > + struct machine *machine = &session->machines.host; > + struct perf_data_file *file = &rec->file; > + struct record_opts *opts = &rec->opts; > + struct perf_tool *tool = &rec->tool; > + int fd = perf_data_file__fd(file); > + int err = 0; > + static bool warned_kmaps = false, warned_modules = false; snip > + err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, > + machine); > + if (err < 0 && !warned_kmaps) { Please use WARN_ONCE, there are lots of examples in tools/perf and in the kernel proper, from where this idiom was adopted, this way these static variables will be auto-created. - Arnaldo > + warned_kmaps = true; > + pr_err("Couldn't record kernel reference relocation symbol\n" > + "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" > + "Check /proc/kallsyms permission or run as root.\n"); > + } > + > + err = perf_event__synthesize_modules(tool, process_synthesized_event, > + machine); > + if (err < 0 && !warned_modules) { > + warned_modules = true; > + pr_err("Couldn't record kernel module information.\n" > + "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" > + "Check /proc/modules permission or run as root.\n");