Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753007AbcD1CMn (ORCPT ); Wed, 27 Apr 2016 22:12:43 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:58599 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752757AbcD1CMm (ORCPT ); Wed, 27 Apr 2016 22:12:42 -0400 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.204 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Thu, 28 Apr 2016 11:12:19 +0900 From: Namhyung Kim To: Masami Hiramatsu CC: Arnaldo Carvalho de Melo , , Peter Zijlstra , Ingo Molnar , Hemant Kumar , Ananth N Mavinakayanahalli Subject: Re: [PATCH perf/core v5 04/15] perf probe: Add --cache option to cache the probe definitions Message-ID: <20160428021219.GB15055@sejong.aot.lge.com> References: <20160427183701.23446.15293.stgit@devbox> <20160427183741.23446.1938.stgit@devbox> MIME-Version: 1.0 In-Reply-To: <20160427183741.23446.1938.stgit@devbox> User-Agent: Mutt/1.6.0 (2016-04-01) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/04/28 11:12:19, Serialize by Router on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/04/28 11:12:19, Serialize complete at 2016/04/28 11:12:19 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1482 Lines: 59 On Thu, Apr 28, 2016 at 03:37:42AM +0900, Masami Hiramatsu wrote: > From: Masami Hiramatsu > > Add --cache option to cache the probe definitions. This > just saves the result of the dwarf analysis to probe cache. > > Signed-off-by: Masami Hiramatsu > Signed-off-by: Masami Hiramatsu > --- > Changes in v5: > - Move probe_cache* definitions. (code cleanup) > > Changes in v4: > - Remove cache saving failure message. > --- [snip] > +static int probe_cache__load(struct probe_cache *pcache) > +{ > + struct probe_cache_entry *entry = NULL; > + char buf[MAX_CMDLEN], *p; > + int ret = 0; > + FILE *fp; > + > + fp = fdopen(dup(pcache->fd), "r"); > + while (!feof(fp)) { > + if (!fgets(buf, MAX_CMDLEN, fp)) > + break; > + p = strchr(buf, '\n'); > + if (p) > + *p = '\0'; > + if (buf[0] == '#') { /* #perf_probe_event */ > + entry = probe_cache_entry__new(NULL); The probe_cache_entry__new() can fail. Thanks, Namhyung > + entry->spev = strdup(buf + 1); > + ret = parse_perf_probe_command(buf + 1, &entry->pev); > + if (!entry->spev || ret < 0) { > + probe_cache_entry__delete(entry); > + goto out; > + } > + list_add_tail(&entry->list, &pcache->list); > + } else { /* trace_probe_event */ > + if (!entry) { > + ret = -EINVAL; > + goto out; > + } > + strlist__add(entry->tevlist, buf); > + } > + } > +out: > + fclose(fp); > + return ret; > +}