From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941424AbdEYDFe (ORCPT ); Wed, 24 May 2017 23:05:34 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:6377 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937754AbdEYDFd (ORCPT ); Wed, 24 May 2017 23:05:33 -0400 Message-ID: <592649CC.8090702@huawei.com> Date: Thu, 25 May 2017 11:04:44 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Wei Yang CC: , , , Subject: Re: [PATCH] mm/vmalloc: a slight change of compare target in __insert_vmap_area() References: <20170524100347.8131-1-richard.weiyang@gmail.com> In-Reply-To: <20170524100347.8131-1-richard.weiyang@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.592649F6.0088,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ff74ded1aa2d5cfaadea1d94d6ce596c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I hit the overlap issue, but it is hard to reproduced. if you think it is safe. and the situation is not happen. AFAIC, it is no need to add the code. if you insist on the point. Maybe VM_WARN_ON is a choice. Regards zhongjiang On 2017/5/24 18:03, Wei Yang wrote: > The vmap RB tree store the elements in order and no overlap between any of > them. The comparison in __insert_vmap_area() is to decide which direction > the search should follow and make sure the new vmap_area is not overlap > with any other. > > Current implementation fails to do the overlap check. > > When first "if" is not true, it means > > va->va_start >= tmp_va->va_end > > And with the truth > > xxx->va_end > xxx->va_start > > The deduction is > > va->va_end > tmp_va->va_start > > which is the condition in second "if". > > This patch changes a little of the comparison in __insert_vmap_area() to > make sure it forbids the overlapped vmap_area. > > Signed-off-by: Wei Yang > --- > mm/vmalloc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 0b057628a7ba..8087451cb332 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -360,9 +360,9 @@ static void __insert_vmap_area(struct vmap_area *va) > > parent = *p; > tmp_va = rb_entry(parent, struct vmap_area, rb_node); > - if (va->va_start < tmp_va->va_end) > + if (va->va_end <= tmp_va->va_start) > p = &(*p)->rb_left; > - else if (va->va_end > tmp_va->va_start) > + else if (va->va_start >= tmp_va->va_end) > p = &(*p)->rb_right; > else > BUG(); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id C79416B0279 for ; Wed, 24 May 2017 23:06:40 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id p86so214270131pfl.12 for ; Wed, 24 May 2017 20:06:40 -0700 (PDT) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com. [45.249.212.188]) by mx.google.com with ESMTPS id j1si26130545pld.54.2017.05.24.20.06.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 May 2017 20:06:39 -0700 (PDT) Message-ID: <592649CC.8090702@huawei.com> Date: Thu, 25 May 2017 11:04:44 +0800 From: zhong jiang MIME-Version: 1.0 Subject: Re: [PATCH] mm/vmalloc: a slight change of compare target in __insert_vmap_area() References: <20170524100347.8131-1-richard.weiyang@gmail.com> In-Reply-To: <20170524100347.8131-1-richard.weiyang@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Wei Yang Cc: akpm@linux-foundation.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org I hit the overlap issue, but it is hard to reproduced. if you think it is safe. and the situation is not happen. AFAIC, it is no need to add the code. if you insist on the point. Maybe VM_WARN_ON is a choice. Regards zhongjiang On 2017/5/24 18:03, Wei Yang wrote: > The vmap RB tree store the elements in order and no overlap between any of > them. The comparison in __insert_vmap_area() is to decide which direction > the search should follow and make sure the new vmap_area is not overlap > with any other. > > Current implementation fails to do the overlap check. > > When first "if" is not true, it means > > va->va_start >= tmp_va->va_end > > And with the truth > > xxx->va_end > xxx->va_start > > The deduction is > > va->va_end > tmp_va->va_start > > which is the condition in second "if". > > This patch changes a little of the comparison in __insert_vmap_area() to > make sure it forbids the overlapped vmap_area. > > Signed-off-by: Wei Yang > --- > mm/vmalloc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 0b057628a7ba..8087451cb332 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -360,9 +360,9 @@ static void __insert_vmap_area(struct vmap_area *va) > > parent = *p; > tmp_va = rb_entry(parent, struct vmap_area, rb_node); > - if (va->va_start < tmp_va->va_end) > + if (va->va_end <= tmp_va->va_start) > p = &(*p)->rb_left; > - else if (va->va_end > tmp_va->va_start) > + else if (va->va_start >= tmp_va->va_end) > p = &(*p)->rb_right; > else > BUG(); -- 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