From: Jiri Olsa <jolsa@redhat.com> To: Florian Fainelli <f.fainelli@gmail.com> Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Namhyung Kim <namhyung@kernel.org>, Kim Phillips <kim.phillips@arm.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Thomas Gleixner <tglx@linutronix.de>, Ravi Bangoria <ravi.bangoria@linux.ibm.com>, Thomas Richter <tmricht@linux.ibm.com>, rmk+kernel@armlinux.org.uk, l.stach@pengutronix.de Subject: Re: [PATCH v2 1/2] perf tools: Make find_vdso_map() more modular Date: Tue, 27 Nov 2018 10:33:34 +0100 [thread overview] Message-ID: <20181127093334.GE8908@krava> (raw) In-Reply-To: <20181025175508.6967-2-f.fainelli@gmail.com> On Thu, Oct 25, 2018 at 10:55:07AM -0700, Florian Fainelli wrote: > In preparation for checking that the vectors page on the ARM > architecture, refactor the find_vdso_map() function to accept finding an > arbitrary string and create a dedicated helper function for that under > util/find-map.c and update find_vdso_map() to use it. > > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> > --- > tools/perf/util/find-map.c | 31 +++++++++++++++++++++++++++++++ > tools/perf/util/find-vdso-map.c | 30 +++--------------------------- > 2 files changed, 34 insertions(+), 27 deletions(-) > create mode 100644 tools/perf/util/find-map.c > > diff --git a/tools/perf/util/find-map.c b/tools/perf/util/find-map.c > new file mode 100644 > index 000000000000..19a3431a7b2a > --- /dev/null > +++ b/tools/perf/util/find-map.c > @@ -0,0 +1,31 @@ > +// SPDX-License-Identifier: GPL-2.0 > +static int find_map(void **start, void **end, const char *name) > +{ > + FILE *maps; > + char line[128]; > + int found = 0; > + > + maps = fopen("/proc/self/maps", "r"); > + if (!maps) { > + fprintf(stderr, "vdso: cannot open maps\n"); > + return -1; > + } > + > + while (!found && fgets(line, sizeof(line), maps)) { > + int m = -1; > + > + /* We care only about private r-x mappings. */ > + if (2 != sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n", > + start, end, &m)) > + continue; > + if (m < 0) > + continue; > + > + if (!strncmp(&line[m], name, strlen(name))) > + found = 1; > + } > + > + fclose(maps); > + return !found; > +} > + > diff --git a/tools/perf/util/find-vdso-map.c b/tools/perf/util/find-vdso-map.c > index d7823e3508fc..840d7d6e29e2 100644 > --- a/tools/perf/util/find-vdso-map.c > +++ b/tools/perf/util/find-vdso-map.c > @@ -1,31 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > +#include "find-map.c" aaah, I was wondering how this could build without 'Build' file record ;-) jirka > + > static int find_vdso_map(void **start, void **end) > { > - FILE *maps; > - char line[128]; > - int found = 0; > - > - maps = fopen("/proc/self/maps", "r"); > - if (!maps) { > - fprintf(stderr, "vdso: cannot open maps\n"); > - return -1; > - } > - > - while (!found && fgets(line, sizeof(line), maps)) { > - int m = -1; > - > - /* We care only about private r-x mappings. */ > - if (2 != sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n", > - start, end, &m)) > - continue; > - if (m < 0) > - continue; > - > - if (!strncmp(&line[m], VDSO__MAP_NAME, > - sizeof(VDSO__MAP_NAME) - 1)) > - found = 1; > - } > - > - fclose(maps); > - return !found; > + return find_map(start, end, VDSO__MAP_NAME); > } > -- > 2.17.1 >
next prev parent reply other threads:[~2018-11-27 9:33 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-25 17:55 [PATCH v2 0/2] perf tests: Check for ARM [vectors] page Florian Fainelli 2018-10-25 17:55 ` [PATCH v2 1/2] perf tools: Make find_vdso_map() more modular Florian Fainelli 2018-11-27 9:31 ` Jiri Olsa 2018-12-10 20:16 ` Florian Fainelli 2018-11-27 9:33 ` Jiri Olsa [this message] 2018-10-25 17:55 ` [PATCH v2 2/2] perf tests: Add a test for the ARM 32-bit [vectors] page Florian Fainelli 2018-11-13 22:44 ` [PATCH v2 0/2] perf tests: Check for ARM " Florian Fainelli 2018-11-27 0:27 ` Florian Fainelli 2018-11-27 9:32 ` Jiri Olsa
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20181127093334.GE8908@krava \ --to=jolsa@redhat.com \ --cc=acme@kernel.org \ --cc=alexander.shishkin@linux.intel.com \ --cc=f.fainelli@gmail.com \ --cc=gregkh@linuxfoundation.org \ --cc=kim.phillips@arm.com \ --cc=l.stach@pengutronix.de \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@redhat.com \ --cc=namhyung@kernel.org \ --cc=peterz@infradead.org \ --cc=ravi.bangoria@linux.ibm.com \ --cc=rmk+kernel@armlinux.org.uk \ --cc=tglx@linutronix.de \ --cc=tmricht@linux.ibm.com \ --subject='Re: [PATCH v2 1/2] perf tools: Make find_vdso_map() more modular' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).