From: Hoeun Ryu Subject: Re: [PATCH] mm: add VM_STATIC flag to vmalloc and prevent from removing the areas Date: Fri, 14 Apr 2017 09:25:54 +0900 Message-ID: References: <1491973350-26816-1-git-send-email-hoeun.ryu@gmail.com> Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Sender: owner-linux-mm@kvack.org To: Anshuman Khandual Cc: Andrew Morton , Andrey Ryabinin , Andreas Dilger , Vlastimil Babka , Michal Hocko , Chris Wilson , Ingo Molnar , zijun_hu , Matthew Wilcox , Thomas Garnier , "Kirill A. Shutemov" , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org List-Id: linux-arch.vger.kernel.org > On Apr 13, 2017, at 1:17 PM, Anshuman Khandual wrote: >=20 >> On 04/12/2017 10:31 AM, Hoeun Ryu wrote: >> vm_area_add_early/vm_area_register_early() are used to reserve vmalloc ar= ea >> 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 t= he >> rbtree by accident. >=20 > 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. >=20 >>=20 >> Signed-off-by: Hoeun Ryu >> --- >> include/linux/vmalloc.h | 1 + >> mm/vmalloc.c | 9 ++++++--- >> 2 files changed, 7 insertions(+), 3 deletions(-) >>=20 >> 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 initi= alized */ >> #define VM_NO_GUARD 0x00000040 /* don't add guard page */ >> #define VM_KASAN 0x00000080 /* has allocated kasan shadow mem= ory */ >> +#define VM_STATIC 0x00000200 >=20 > You might want to add some description in the comment saying > its a sticky VM area which will never go away or something. >=20 OK. I will add some description. >> /* bits [20..32] reserved for arch specific ioremap internals */ >>=20 >> /* >> 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 =3D vmlist; tmp; tmp =3D tmp->next) { >> va =3D kzalloc(sizeof(struct vmap_area), GFP_NOWAIT); >> - va->flags =3D VM_VM_AREA; >> + va->flags =3D VM_VM_AREA | VM_STATIC; >> va->va_start =3D (unsigned long)tmp->addr; >> va->va_end =3D va->va_start + tmp->size; >> va->vm =3D tmp; >> @@ -1480,7 +1480,7 @@ struct vm_struct *remove_vm_area(const void *addr) >> might_sleep(); >>=20 >> va =3D 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))= ) { >=20 >=20 > 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. >=20 OK, I'll fix this in the next version Thank you for the review.= -- 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: email@kvack.org