public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH] perf, tools: Support srccode output
Date: Sun, 7 May 2017 16:45:43 +0200	[thread overview]
Message-ID: <20170507144543.GB12933@krava> (raw)
In-Reply-To: <20170505230029.23826-1-andi@firstfloor.org>

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

  parent reply	other threads:[~2017-05-07 21:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-05 23:00 [PATCH] perf, tools: Support srccode output Andi Kleen
2017-05-07 14:45 ` Jiri Olsa
2017-05-07 15:29   ` Andi Kleen
2017-05-07 14:45 ` Jiri Olsa [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-05-08 20:22 Andi Kleen
2017-05-09  9:05 ` Jiri Olsa
2017-05-09  9:06 ` Jiri Olsa
2017-05-09 12:06 Andi Kleen
2017-05-09 12:36 ` Jiri Olsa
2018-12-04  0:18 Andi Kleen
2018-12-05 12:28 ` Jiri Olsa
2018-12-05 16:54   ` Arnaldo Carvalho de Melo
2018-12-05 17:05     ` Jiri Olsa
2018-12-05 17:33   ` Andi Kleen
2018-12-05 22:15   ` Arnaldo Carvalho de Melo

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=20170507144543.GB12933@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox