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]
Date:   Tue, 4 Apr 2017 11:40:50 +0200
From:   Michal Hocko <mhocko@...nel.org>
To:     Andrey Ryabinin <aryabinin@...tuozzo.com>
Cc:     akpm@...ux-foundation.org, penguin-kernel@...ove.SAKURA.ne.jp,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org, hpa@...or.com,
        chris@...is-wilson.co.uk, hch@....de, mingo@...e.hu,
        jszhang@...vell.com, joelaf@...gle.com, joaodias@...gle.com,
        willy@...radead.org, tglx@...utronix.de
Subject: Re: [PATCH 4/4] mm/vmalloc: remove vfree_atomic()

On Thu 30-03-17 13:27:19, Andrey Ryabinin wrote:
> vfree() can be used in any atomic context and there is no
> vfree_atomic() callers left, so let's remove it.
> 
> This reverts commit bf22e37a6413 ("mm: add vfree_atomic()")
> 
> Signed-off-by: Andrey Ryabinin <aryabinin@...tuozzo.com>

the idea was nice but reality hits the fan and we learn that this just
doesn't work...
Acked-by: Michal Hocko <mhocko@...e.com>

> ---
>  include/linux/vmalloc.h |  1 -
>  mm/vmalloc.c            | 40 +++++-----------------------------------
>  2 files changed, 5 insertions(+), 36 deletions(-)
> 
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 46991ad..b4f044f 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -83,7 +83,6 @@ extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
>  extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags);
>  
>  extern void vfree(const void *addr);
> -extern void vfree_atomic(const void *addr);
>  
>  extern void *vmap(struct page **pages, unsigned int count,
>  			unsigned long flags, pgprot_t prot);
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index ea1b4ab..b77337a 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1534,38 +1534,6 @@ static void __vunmap(const void *addr, int deallocate_pages)
>  	return;
>  }
>  
> -static inline void __vfree_deferred(const void *addr)
> -{
> -	/*
> -	 * Use raw_cpu_ptr() because this can be called from preemptible
> -	 * context. Preemption is absolutely fine here, because the llist_add()
> -	 * implementation is lockless, so it works even if we are adding to
> -	 * nother cpu's list.  schedule_work() should be fine with this too.
> -	 */
> -	struct vfree_deferred *p = raw_cpu_ptr(&vfree_deferred);
> -
> -	if (llist_add((struct llist_node *)addr, &p->list))
> -		schedule_work(&p->wq);
> -}
> -
> -/**
> - *	vfree_atomic  -  release memory allocated by vmalloc()
> - *	@addr:		memory base address
> - *
> - *	This one is just like vfree() but can be called in any atomic context
> - *	except NMIs.
> - */
> -void vfree_atomic(const void *addr)
> -{
> -	BUG_ON(in_nmi());
> -
> -	kmemleak_free(addr);
> -
> -	if (!addr)
> -		return;
> -	__vfree_deferred(addr);
> -}
> -
>  /**
>   *	vfree  -  release memory allocated by vmalloc()
>   *	@addr:		memory base address
> @@ -1588,9 +1556,11 @@ void vfree(const void *addr)
>  
>  	if (!addr)
>  		return;
> -	if (unlikely(in_interrupt()))
> -		__vfree_deferred(addr);
> -	else
> +	if (unlikely(in_interrupt())) {
> +		struct vfree_deferred *p = this_cpu_ptr(&vfree_deferred);
> +		if (llist_add((struct llist_node *)addr, &p->list))
> +			schedule_work(&p->wq);
> +	} else
>  		__vunmap(addr, 1);
>  }
>  EXPORT_SYMBOL(vfree);
> -- 
> 2.10.2
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@...ck.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@...ck.org"> email@...ck.org </a>

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ