Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1637040

Re: [PATCH] perf, tools: Support srccode output

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] perf, tools: Support srccode output
Date 2017-05-08 00:00 +0200
Message-ID <tECnD-34t-19@gated-at.bofh.it> (permalink)
References <tDUwh-8nd-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, May 05, 2017 at 04:00:29PM -0700, Andi Kleen wrote:

SNIP

> +static struct srcfile *find_srcfile(char *fn)
> +{
> +	struct stat st;
> +	struct srcfile *h;
> +	int fd;
> +	unsigned long ps, sz;
> +	bool first = true;
> +
> +	list_for_each_entry (h, &srcfile_list, nd) {
> +		if (!strcmp(fn, h->fn)) {
> +			if (!first) {
> +				/* Move to front */
> +				list_del(&h->nd);
> +				list_add(&h->nd, &srcfile_list);
> +			}
> +			return h;
> +		}
> +		first = false;
> +	}
> +
> +	/* Only prune if there is more than one entry */
> +	while (map_total_sz > MAXSRCCACHE &&
> +	       srcfile_list.next != &srcfile_list) {
> +		assert(!list_empty(&srcfile_list));
> +		h = list_entry(srcfile_list.prev, struct srcfile, nd);
> +		free_srcfile(h);
> +	}
> +
> +	fd = open(fn, O_RDONLY);
> +	if (fd < 0 || fstat(fd, &st) < 0) {
> +		pr_debug("cannot open source file %s\n", fn);
> +		return NULL;
> +	}
> +
> +	h = malloc(sizeof(struct srcfile));
> +	if (!h)
> +		return NULL;
> +
> +	h->fn = strdup(fn);
> +	if (!h->fn)
> +		goto out_h;
> +
> +	h->maplen = st.st_size;
> +	ps = sysconf(_SC_PAGE_SIZE);

we have global page_size

jirka

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] perf, tools: Support srccode output Andi Kleen <andi@firstfloor.org> - 2017-05-06 01:10 +0200
  Re: [PATCH] perf, tools: Support srccode output Jiri Olsa <jolsa@redhat.com> - 2017-05-08 00:00 +0200
  Re: [PATCH] perf, tools: Support srccode output Jiri Olsa <jolsa@redhat.com> - 2017-05-08 00:00 +0200
    Re: [PATCH] perf, tools: Support srccode output Andi Kleen <ak@linux.intel.com> - 2017-05-08 00:10 +0200

csiph-web