lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <528E782A.9010509@gmail.com>
Date:	Thu, 21 Nov 2013 14:16:26 -0700
From:	David Ahern <dsahern@...il.com>
To:	Dongsheng Yang <yangds.fnst@...fujitsu.com>, mingo@...nel.org
CC:	linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Subject: Re: [PATCH] perf util: optimize util/machine.c:machines__find().

On 11/21/13, 2:31 PM, Dongsheng Yang wrote:
> * Remove an unnecessary variable default_machine.
> * Return earlier to avoid unnecessary searching in children.
>
> Signed-off-by: Dongsheng Yang <yangds.fnst@...fujitsu.com>
> ---
>   tools/perf/util/machine.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 84cdb07..f0dd5f6 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -175,8 +175,7 @@ struct machine *machines__find(struct machines *machines, pid_t pid)
>   {
>   	struct rb_node **p = &machines->guests.rb_node;
>   	struct rb_node *parent = NULL;
> -	struct machine *machine;
> -	struct machine *default_machine = NULL;
> +	struct machine *machine = NULL;
>
>   	if (pid == HOST_KERNEL_ID)
>   		return &machines->host;
> @@ -184,17 +183,17 @@ struct machine *machines__find(struct machines *machines, pid_t pid)
>   	while (*p != NULL) {
>   		parent = *p;
>   		machine = rb_entry(parent, struct machine, rb_node);
> +		if (!machine->pid)
> +			break;
>   		if (pid < machine->pid)
>   			p = &(*p)->rb_left;
>   		else if (pid > machine->pid)
>   			p = &(*p)->rb_right;
>   		else
> -			return machine;
> -		if (!machine->pid)
> -			default_machine = machine;
> +			break;
>   	}
>
> -	return default_machine;
> +	return machine;
>   }

This changes machines__find to always return the machine for the host 
(pid == 0). This function is also used for VM lookups.

David

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ