From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755986AbdEGVxc (ORCPT ); Sun, 7 May 2017 17:53:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33018 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751731AbdEGVxa (ORCPT ); Sun, 7 May 2017 17:53:30 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A59AA3D975 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jolsa@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A59AA3D975 Date: Sun, 7 May 2017 16:45:43 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH] perf, tools: Support srccode output Message-ID: <20170507144543.GB12933@krava> References: <20170505230029.23826-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170505230029.23826-1-andi@firstfloor.org> User-Agent: Mutt/1.8.0 (2017-02-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 07 May 2017 14:45:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.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