linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Hoeun Ryu <hoeun.ryu@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Andreas Dilger <adilger@dilger.ca>,
	Vlastimil Babka <vbabka@suse.cz>, Michal Hocko <mhocko@suse.com>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Ingo Molnar <mingo@kernel.org>, zijun_hu <zijun_hu@htc.com>,
	Matthew Wilcox <mawilcox@microsoft.com>,
	Thomas Garnier <thgarnie@google.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: add VM_STATIC flag to vmalloc and prevent from removing the areas
Date: Thu, 13 Apr 2017 09:47:03 +0530	[thread overview]
Message-ID: <c900f2f4-8b0c-cc0e-afb7-a03cd1458e4c@linux.vnet.ibm.com> (raw)
In-Reply-To: <1491973350-26816-1-git-send-email-hoeun.ryu@gmail.com>

On 04/12/2017 10:31 AM, Hoeun Ryu wrote:
> vm_area_add_early/vm_area_register_early() are used to reserve vmalloc area
> during boot process and those virtually mapped areas are never unmapped.
> So `OR` VM_STATIC flag to the areas in vmalloc_init() when importing
> existing vmlist entries and prevent those areas from being removed from the
> rbtree by accident.

I am wondering whether protection against accidental deletion
of any vmap area should be done in remove_vm_area() function
or the callers should take care of it. But I guess either way
it works.

> 
> Signed-off-by: Hoeun Ryu <hoeun.ryu@gmail.com>
> ---
>  include/linux/vmalloc.h | 1 +
>  mm/vmalloc.c            | 9 ++++++---
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 46991ad..3df53fc 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -19,6 +19,7 @@ struct notifier_block;		/* in notifier.h */
>  #define VM_UNINITIALIZED	0x00000020	/* vm_struct is not fully initialized */
>  #define VM_NO_GUARD		0x00000040      /* don't add guard page */
>  #define VM_KASAN		0x00000080      /* has allocated kasan shadow memory */
> +#define VM_STATIC		0x00000200

You might want to add some description in the comment saying
its a sticky VM area which will never go away or something.

>  /* bits [20..32] reserved for arch specific ioremap internals */
>  
>  /*
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 8ef8ea1..fb5049a 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1262,7 +1262,7 @@ void __init vmalloc_init(void)
>  	/* Import existing vmlist entries. */
>  	for (tmp = vmlist; tmp; tmp = tmp->next) {
>  		va = kzalloc(sizeof(struct vmap_area), GFP_NOWAIT);
> -		va->flags = VM_VM_AREA;
> +		va->flags = VM_VM_AREA | VM_STATIC;
>  		va->va_start = (unsigned long)tmp->addr;
>  		va->va_end = va->va_start + tmp->size;
>  		va->vm = tmp;
> @@ -1480,7 +1480,7 @@ struct vm_struct *remove_vm_area(const void *addr)
>  	might_sleep();
>  
>  	va = find_vmap_area((unsigned long)addr);
> -	if (va && va->flags & VM_VM_AREA) {
> +	if (va && va->flags & VM_VM_AREA && likely(!(va->flags & VM_STATIC))) {


You might want to move the VM_STATIC check before the VM_VM_AREA
check so in cases where the former is set we can save one more
conditional check.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-04-13  4:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12  5:01 [PATCH] mm: add VM_STATIC flag to vmalloc and prevent from removing the areas Hoeun Ryu
2017-04-12  6:02 ` Christoph Hellwig
2017-04-12 11:42   ` Hoeun Ryu
2017-04-12 17:31     ` Christoph Hellwig
2017-04-13  1:03       ` Ho-Eun Ryu
2017-04-13  4:17 ` Anshuman Khandual [this message]
2017-04-14  0:25   ` Hoeun Ryu

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=c900f2f4-8b0c-cc0e-afb7-a03cd1458e4c@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=adilger@dilger.ca \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=hoeun.ryu@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=thgarnie@google.com \
    --cc=vbabka@suse.cz \
    --cc=zijun_hu@htc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).