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] [day] [month] [year] [list]
Message-id: <4546BD4F.4050406@watson.ibm.com>
Date:	Mon, 30 Oct 2006 22:04:47 -0500
From:	Shailabh Nagar <nagar@...son.ibm.com>
To:	Oleg Nesterov <oleg@...sign.ru>
Cc:	Andrew Morton <akpm@...l.org>, Balbir Singh <balbir@...ibm.com>,
	Jay Lan <jlan@....com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] taskstats_exit_alloc: optimize/simplify

Oleg Nesterov wrote:
> If there are no listeners, every task does unneeded kmem_cache alloc/free on
> exit. We don't need listeners->sem for 'if (!list_empty())' check. Yes, we may
> have a false positive, but this doesn't differ from the case when the listener
> is unregistered after we drop the semaphore. So we don't need to do allocation
> beforehand.

Sounds reasonable.


> 
> Signed-off-by: Oleg Nesterov <oleg@...sign.ru>

Acked-by: Shailabh Nagar <nagar@...son.ibm.com>


> 
> --- STATS/kernel/taskstats.c~1_alloc	2006-10-29 18:35:40.000000000 +0300
> +++ STATS/kernel/taskstats.c	2006-10-30 23:45:20.000000000 +0300
> @@ -421,7 +421,6 @@ err:
>  void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu)
>  {
>  	struct listener_list *listeners;
> -	struct taskstats *tmp;
>  	/*
>  	 * This is the cpu on which the task is exiting currently and will
>  	 * be the one for which the exit event is sent, even if the cpu
> @@ -429,19 +428,11 @@ void taskstats_exit_alloc(struct tasksta
>  	 */
>  	*mycpu = raw_smp_processor_id();
>  
> -	*ptidstats = NULL;
> -	tmp = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
> -	if (!tmp)
> -		return;
> -
>  	listeners = &per_cpu(listener_array, *mycpu);
> -	down_read(&listeners->sem);
> -	if (!list_empty(&listeners->list)) {
> -		*ptidstats = tmp;
> -		tmp = NULL;
> -	}
> -	up_read(&listeners->sem);
> -	kfree(tmp);
> +
> +	*ptidstats = NULL;
> +	if (!list_empty(&listeners->list))
> +		*ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
>  }
>  
>  /* Send pid data out on exit */
> 

-
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