Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp208460ybi; Fri, 14 Jun 2019 22:53:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXe+NUHig+YDWZopvpFnp8Rt+s7CYw+phOM7m+fBC8z+wpsIsQzNp0KOc4MlkeRi84hQBL X-Received: by 2002:a17:902:7e0e:: with SMTP id b14mr72351286plm.257.1560578005728; Fri, 14 Jun 2019 22:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560578005; cv=none; d=google.com; s=arc-20160816; b=PRLPov4RmQ39GJxF3njSnw5f+nl/MtWa24tWy4Fa+kTk+3f3ktWjcKGVhnV/gViaYb alOW28JWT7gN60k0x77/r1MF5ZqCOJSu7R1ezZ9kiP/LL2CgUtf8iVqPUtr/gJEOdz5Q a8tSZFASYCDP/rXT8HU9Jl+j6MtP/ucM34TVKiBoGwk7CfD0lKDMfdKaNBiC5qz+RM1y I2YjZhN7lcIFL2et07VPVykXF8W3gQskP9owIZNW7kPnfgCkGOcYfdN7Ysd7wFBdxe+P uAt3qRgN8hwDl4abdWIMUAOT3tgy+jIpD6hgCgHZ20AhjTGooTpUfRhvUFPwvAjySTAo xQkQ== 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=Kz+tawjj+TKGLusbM0dZKp0s2fiz0LpOWBpuEGiIXoo=; b=H42NiLCvmp2e+ZWNh5T9WWtVkcbo1mad580x5Tp7wo/Unbnuf0fCXqfNYtBFDja1Zj +8K/atSFVoTWYSX3hcbb7oSup9+wsYYQu7u6MOoljFiLZdukNEsOPEvab6Tm3b8u22qc qHvaGc6Vji2O3t3cccPrx8nVtbJ9EOS6XAgMfsi4O7BOS8V9JlNzIe9Os5AZrpLZUaNe 9eAoMkfId5wFaaGOsvrGeIvB3s0aSRdx9yaC7UKRcCzUH/sDwaeam81xtcnXcssqKjk3 rmTMAkqkHi99hYH4IGuMxfuHZQrmrPsNpgaGyhETJpPbqgjMwj8zZMovvOypXoUbwt4x WExw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c4dwLIgG; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si4012912pjq.101.2019.06.14.22.53.10; Fri, 14 Jun 2019 22:53:25 -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=@linaro.org header.s=google header.b=c4dwLIgG; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726279AbfFOFxC (ORCPT + 99 others); Sat, 15 Jun 2019 01:53:02 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:40895 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbfFOFxC (ORCPT ); Sat, 15 Jun 2019 01:53:02 -0400 Received: by mail-qk1-f195.google.com with SMTP id c70so3100911qkg.7 for ; Fri, 14 Jun 2019 22:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Kz+tawjj+TKGLusbM0dZKp0s2fiz0LpOWBpuEGiIXoo=; b=c4dwLIgGIFZILjgl4mh8YLfuK7rL81nwXA/1iHCW5MEKfrs9x4sPI2/59Aao2vYRK2 JRupca19/9klmYhMoXAQRHQ524wIx8ItlLVH7TwwkzFrnbuPs+b+SL6MAw0etINOfGi1 tCsAM1QcalwmxnHVmpsNlbCx2ryeQ5qltSyoWo2HuyhrQr4lI7s9VA97Y1tY8Xh1rTGW hoFH3XD2+VA6LJCqz5a3XMoCnW2Ge75kQgEAPtZ99qRZiN3MyPVYb4eM+8qjYalAeCEk fzbiw7rNGVCwUwVs92X2Jly94WDadpVcYijCGrJrNP7QrA3rTPQlnnII9aQ6e8UHacpS /QTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Kz+tawjj+TKGLusbM0dZKp0s2fiz0LpOWBpuEGiIXoo=; b=c+a0AJKcgDixx89NUhI8P7BsZGi7Q17TgMmkg4ER30hnoiZHrj4TNHH1Y2agjngDji Ddgw+MC5c2w9N3vG2P659hqe1b7hCtmgxlNi5Xnrajx4+FCFeo9KysfKBnDLEpet92/d Z3B/yWFb+veE2XVePxaTFzBU9tEowKlxNSpGX+OAlMZeyXem+1utWDpeyhdk+re6A0Fn WokmDE0hLo13P9QGSrYKHPjLxwSJ9mmzsqHDIp0wrRgzBnMS7y7dvHrvUs1m3GpvMGBZ b428xUIqN7nUhY9IPJtyKgdHWdpArcFlIQ15Fqou8DsxQxmD58sz1Rm3uWTUuDeIVmW2 DUiQ== X-Gm-Message-State: APjAAAXUOnZj2D99yxwDRgwMMaN0LsEU9pP//lc+uxQzkcL+VxQpDsTn vfwvNwvolDOE56uDYJbONuUJZQ== X-Received: by 2002:a05:620a:1661:: with SMTP id d1mr4643851qko.192.1560577981016; Fri, 14 Jun 2019 22:53:01 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li1322-146.members.linode.com. [45.79.223.146]) by smtp.gmail.com with ESMTPSA id t67sm2494822qkf.34.2019.06.14.22.52.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 22:53:00 -0700 (PDT) Date: Sat, 15 Jun 2019 13:52:49 +0800 From: Leo Yan To: Arnaldo Carvalho de Melo Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Adrian Hunter , Mathieu Poirier , Mike Leach , Suzuki K Poulose , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v2 3/4] perf augmented_raw_syscalls: Support arm64 raw syscalls Message-ID: <20190615055249.GA3742@leoy-ThinkPad-X240s> References: <20190606094845.4800-4-leo.yan@linaro.org> <20190606133838.GC30166@kernel.org> <20190606141231.GC5970@leoy-ThinkPad-X240s> <20190606144412.GC21245@kernel.org> <20190607095831.GG5970@leoy-ThinkPad-X240s> <20190609131849.GB6357@leoy-ThinkPad-X240s> <20190610184754.GU21245@kernel.org> <20190611041831.GA3959@leoy-ThinkPad-X240s> <20190612024917.GG28689@kernel.org> <20190613181514.GC1402@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190613181514.GC1402@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 13, 2019 at 03:15:14PM -0300, Arnaldo Carvalho de Melo wrote: [...] > > > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c > > > > index 1a2a605cf068..eb70a4b71755 100644 > > > > --- a/tools/perf/builtin-trace.c > > > > +++ b/tools/perf/builtin-trace.c > > > > @@ -1529,6 +1529,7 @@ static int trace__read_syscall_info(struct trace *trace, int id) > > > > static int trace__validate_ev_qualifier(struct trace *trace) > > > > { > > > > int err = 0, i; > > > > + bool printed_invalid_prefix = false; > > > > size_t nr_allocated; > > > > struct str_node *pos; > > > > > > > > @@ -1555,14 +1556,15 @@ static int trace__validate_ev_qualifier(struct trace *trace) > > > > if (id >= 0) > > > > goto matches; > > > > > > > > - if (err == 0) { > > > > - fputs("Error:\tInvalid syscall ", trace->output); > > > > - err = -EINVAL; > > > > + if (!printed_invalid_prefix) { > > > > + pr_debug("Skipping unknown syscalls: "); > > > > + printed_invalid_prefix = true; > > > > } else { > > > > - fputs(", ", trace->output); > > > > + pr_debug(", "); > > > > } > > > > > > > > - fputs(sc, trace->output); > > > > + pr_debug("%s", sc); > > > > + continue; > > > > > > Here adds 'continue' so that we want to let ev_qualifier_ids.entries > > > to only store valid system call ids. But this is not sufficient, > > > because we have initialized ev_qualifier_ids.nr at the beginning of > > > the function: > > > > > > trace->ev_qualifier_ids.nr = strlist__nr_entries(trace->ev_qualifier); > > > This sentence will set ids number to the string table's length; but > > > actually some strings are not really supported; this leads to some > > > items in trace->ev_qualifier_ids.entries[] will be not initialized > > > properly. > > > > > > If we want to get neat entries and entry number, I suggest at the > > > beginning of the function we use variable 'nr_allocated' to store > > > string table length and use it to allocate entries: > > > > > > nr_allocated = strlist__nr_entries(trace->ev_qualifier); > > > trace->ev_qualifier_ids.entries = malloc(nr_allocated * > > > sizeof(trace->ev_qualifier_ids.entries[0])); > > > > > > If we find any matched string, then increment the nr field under > > > 'matches' tag: > > > > > > matches: > > > trace->ev_qualifier_ids.nr++; > > > trace->ev_qualifier_ids.entries[i++] = id; > > > > > > This can ensure the entries[0..nr-1] has valid id and we can use > > > ev_qualifier_ids.nr to maintain the valid system call numbers. > > > > yeah, you're right, I'll address these issues in a followup patch, > > tomorrow. > > This is equivalent and I think the smallest patch, I'll add one on top > doing what you suggested about nr_allocated getting the > strlist__nr_entries() and also will rename i to nr_used to contrast with > nr_allocated, and then at the end set ev_qualifier_ids.nr to nr_used. Thanks for this patch, I tested below changes and 'perf trace' works well. You could add my test tag: Tested-by: Leo Yan > - Arnaldo > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c > index eb70a4b71755..bd1f00e7a2eb 100644 > --- a/tools/perf/builtin-trace.c > +++ b/tools/perf/builtin-trace.c > @@ -1528,9 +1528,9 @@ static int trace__read_syscall_info(struct trace *trace, int id) > > static int trace__validate_ev_qualifier(struct trace *trace) > { > - int err = 0, i; > + int err = 0; > bool printed_invalid_prefix = false; > - size_t nr_allocated; > + size_t nr_allocated, i; > struct str_node *pos; > > trace->ev_qualifier_ids.nr = strlist__nr_entries(trace->ev_qualifier); > @@ -1575,7 +1575,7 @@ static int trace__validate_ev_qualifier(struct trace *trace) > id = syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next); > if (id < 0) > break; > - if (nr_allocated == trace->ev_qualifier_ids.nr) { > + if (nr_allocated == i) { > void *entries; > > nr_allocated += 8; > @@ -1588,11 +1588,11 @@ static int trace__validate_ev_qualifier(struct trace *trace) > } > trace->ev_qualifier_ids.entries = entries; > } > - trace->ev_qualifier_ids.nr++; > trace->ev_qualifier_ids.entries[i++] = id; > } > } > > + trace->ev_qualifier_ids.nr = i; > out: > if (printed_invalid_prefix) > pr_debug("\n");