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]
Date:	Fri, 24 Aug 2012 14:51:51 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Wanpeng Li <liwanp@...ux.vnet.ibm.com>
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	Michal Hocko <mhocko@...e.cz>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Minchan Kim <minchan@...nel.org>,
	Gavin Shan <shangw@...ux.vnet.ibm.com>
Subject: Re: [PATCH 1/2] mm/mmu_notifier: init notifier if necessary

On Fri, 24 Aug 2012 22:37:55 +0800
Wanpeng Li <liwanp@...ux.vnet.ibm.com> wrote:

> From: Gavin Shan <shangw@...ux.vnet.ibm.com>
> 
> While registering MMU notifier, new instance of MMU notifier_mm will
> be allocated and later free'd if currrent mm_struct's MMU notifier_mm
> has been initialized. That cause some overhead. The patch tries to
> eleminate that.
> 
> Signed-off-by: Gavin Shan <shangw@...ux.vnet.ibm.com>
> Signed-off-by: Wanpeng Li <liwanp@...ux.vnet.ibm.com>
> ---
>  mm/mmu_notifier.c |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
> index 862b608..fb4067f 100644
> --- a/mm/mmu_notifier.c
> +++ b/mm/mmu_notifier.c
> @@ -192,22 +192,23 @@ static int do_mmu_notifier_register(struct mmu_notifier *mn,
>  
>  	BUG_ON(atomic_read(&mm->mm_users) <= 0);
>  
> -	ret = -ENOMEM;
> -	mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm), GFP_KERNEL);
> -	if (unlikely(!mmu_notifier_mm))
> -		goto out;
> -
>  	if (take_mmap_sem)
>  		down_write(&mm->mmap_sem);
>  	ret = mm_take_all_locks(mm);
>  	if (unlikely(ret))
> -		goto out_cleanup;
> +		goto out;
>  
>  	if (!mm_has_notifiers(mm)) {
> +		mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm),
> +					GFP_ATOMIC);

Why was the code switched to the far weaker GFP_ATOMIC?  We can still
perform sleeping allocations inside mmap_sem.

> +		if (unlikely(!mmu_notifier_mm)) {
> +			ret = -ENOMEM;
> +			goto out_of_mem;
> +		}
>  		INIT_HLIST_HEAD(&mmu_notifier_mm->list);
>  		spin_lock_init(&mmu_notifier_mm->lock);
> +
>  		mm->mmu_notifier_mm = mmu_notifier_mm;
> -		mmu_notifier_mm = NULL;
>  	}
>  	atomic_inc(&mm->mm_count);
>  

--
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