All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Chenggang Qin <chenggang.qin@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Chenggang Qin <chenggang.qcg@taobao.com>,
	David Ahern <dsahern@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Namhyung Kim <namhyung@gmail.com>,
	Yanmin Zhang <yanmin.zhang@intel.com>,
	Wu Fengguang <fengguang.wu@intel.com>,
	Mike Galbraith <efault@gmx.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/2] perf tools: avoid traverse dsos list while find vdso
Date: Mon, 14 Oct 2013 11:57:38 -0300	[thread overview]
Message-ID: <20131014145738.GC11175@ghostprotocols.net> (raw)
In-Reply-To: <1378732916-3537-1-git-send-email-chenggang.qin@gmail.com>

Em Mon, Sep 09, 2013 at 09:21:55PM +0800, Chenggang Qin escreveu:
> From: Chenggang Qin <chenggang.qcg@taobao.com>
> 
> Vdso is only one in a system. It is not necessory to traverse the
> macine->user_dsos list when looking for the dso of vdso.
> The flag vdso_found should be replaced by a pointor that point to the dso of
> vdso. If the pointer is NULL, dso of vdso have not been created. Else, the
> pointor can be returned directly in function vdso__dso_findnew().
> The list traversing can be avoided by this method.
> Thanks.
> 
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Cc: Arjan van de Ven <arjan@linux.intel.com>
> Cc: Namhyung Kim <namhyung@gmail.com>
> Cc: Yanmin Zhang <yanmin.zhang@intel.com>
> Cc: Wu Fengguang <fengguang.wu@intel.com>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Chenggang Qin <chenggang.qcg@taobao.com>
> 
> ---
>  tools/perf/util/vdso.c |   22 ++++++++--------------
>  1 files changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
> index 3915982..8022ef0 100644
> --- a/tools/perf/util/vdso.c
> +++ b/tools/perf/util/vdso.c
> @@ -13,7 +13,7 @@
>  #include "symbol.h"
>  #include "linux/string.h"
>  
> -static bool vdso_found;
> +static struct dso *vdso_dso = NULL;
>  static char vdso_file[] = "/tmp/perf-vdso.so-XXXXXX";
>  
>  static int find_vdso_map(void **start, void **end)
> @@ -55,9 +55,6 @@ static char *get_file(void)
>  	size_t size;
>  	int fd;
>  
> -	if (vdso_found)
> -		return vdso_file;
> -
>  	if (find_vdso_map(&start, &end))
>  		return NULL;
>  
> @@ -79,33 +76,30 @@ static char *get_file(void)
>   out:
>  	free(buf);
>  
> -	vdso_found = (vdso != NULL);
>  	return vdso;
>  }
>  
>  void vdso__exit(void)
>  {
> -	if (vdso_found)
> +	if (vdso_dso)
>  		unlink(vdso_file);

Don't we have to delete the vfso_dso and set it to NULL?

>  }
>  
>  struct dso *vdso__dso_findnew(struct list_head *head)
>  {
> -	struct dso *dso = dsos__find(head, VDSO__MAP_NAME, true);
> -
> -	if (!dso) {
> +	if (!vdso_dso) {
>  		char *file;
>  
>  		file = get_file();
>  		if (!file)
>  			return NULL;
>  
> -		dso = dso__new(VDSO__MAP_NAME);
> -		if (dso != NULL) {
> -			dsos__add(head, dso);
> -			dso__set_long_name(dso, file);
> +		vdso_dso = dso__new(VDSO__MAP_NAME);
> +		if (vdso_dso != NULL) {
> +			dsos__add(head, vdso_dso);
> +			dso__set_long_name(vdso_dso, file);
>  		}
>  	}
>  
> -	return dso;
> +	return vdso_dso;
>  }
> -- 
> 1.7.8.rc2.5.g815b

      parent reply	other threads:[~2013-10-14 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09 13:21 [PATCH 1/2] perf tools: avoid traverse dsos list while find vdso Chenggang Qin
2013-09-09 13:21 ` [PATCH 2/2] perf tools: remove short name compare in dsos__find() Chenggang Qin
2013-10-14 14:57 ` Arnaldo Carvalho de Melo [this message]

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=20131014145738.GC11175@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=chenggang.qcg@taobao.com \
    --cc=chenggang.qin@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=yanmin.zhang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.