From mboxrd@z Thu Jan 1 00:00:00 1970 From: Minchan Kim Date: Thu, 12 Jun 2014 07:40:29 +0000 Subject: Re: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex Message-Id: <20140612074029.GB12663@bbox> List-Id: References: <1402543307-29800-1-git-send-email-iamjoonsoo.kim@lge.com> <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> In-Reply-To: <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Joonsoo Kim Cc: Andrew Morton , "Aneesh Kumar K.V" , Marek Szyprowski , Michal Nazarewicz , Russell King - ARM Linux , Greg Kroah-Hartman , Paolo Bonzini , Gleb Natapov , Alexander Graf , Benjamin Herrenschmidt , Paul Mackerras , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > Currently, we should take the mutex for manipulating bitmap. > This job may be really simple and short so we don't need to sleep > if contended. So I change it to spinlock. I'm not sure it would be good always. Maybe you remember we discussed about similar stuff about bitmap searching in vmap friend internally, which was really painful when it was fragmented. So, at least we need number if you really want and I hope the number from ARM machine most popular platform for CMA at the moment. > > Signed-off-by: Joonsoo Kim > > diff --git a/mm/cma.c b/mm/cma.c > index 22a5b23..3085e8c 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -36,7 +37,7 @@ struct cma { > unsigned long count; > unsigned long *bitmap; > int order_per_bit; /* Order of pages represented by one bit */ > - struct mutex lock; > + spinlock_t lock; > }; > > /* > @@ -72,9 +73,9 @@ static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count) > bitmapno = (pfn - cma->base_pfn) >> cma->order_per_bit; > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmap_clear(cma->bitmap, bitmapno, nr_bits); > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > } > > static int __init cma_activate_area(struct cma *cma) > @@ -112,7 +113,7 @@ static int __init cma_activate_area(struct cma *cma) > init_cma_reserved_pageblock(pfn_to_page(base_pfn)); > } while (--i); > > - mutex_init(&cma->lock); > + spin_lock_init(&cma->lock); > return 0; > > err: > @@ -261,11 +262,11 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > for (;;) { > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmapno = bitmap_find_next_zero_area(cma->bitmap, > bitmap_maxno, start, nr_bits, mask); > if (bitmapno >= bitmap_maxno) { > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > break; > } > bitmap_set(cma->bitmap, bitmapno, nr_bits); > @@ -274,7 +275,7 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > * our exclusive use. If the migration fails we will take the > * lock again and unmark it. > */ > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > > pfn = cma->base_pfn + (bitmapno << cma->order_per_bit); > mutex_lock(&cma_mutex); > -- > 1.7.9.5 > > -- > 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 -- Kind regards, Minchan Kim From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lgemrelse7q.lge.com (LGEMRELSE7Q.lge.com [156.147.1.151]) by lists.ozlabs.org (Postfix) with ESMTP id B4D831A032D for ; Thu, 12 Jun 2014 17:40:19 +1000 (EST) Date: Thu, 12 Jun 2014 16:40:29 +0900 From: Minchan Kim To: Joonsoo Kim Subject: Re: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex Message-ID: <20140612074029.GB12663@bbox> References: <1402543307-29800-1-git-send-email-iamjoonsoo.kim@lge.com> <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> Cc: kvm-ppc@vger.kernel.org, Russell King - ARM Linux , kvm@vger.kernel.org, Gleb Natapov , Greg Kroah-Hartman , Alexander Graf , Michal Nazarewicz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Paul Mackerras , "Aneesh Kumar K.V" , Paolo Bonzini , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, Marek Szyprowski List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > Currently, we should take the mutex for manipulating bitmap. > This job may be really simple and short so we don't need to sleep > if contended. So I change it to spinlock. I'm not sure it would be good always. Maybe you remember we discussed about similar stuff about bitmap searching in vmap friend internally, which was really painful when it was fragmented. So, at least we need number if you really want and I hope the number from ARM machine most popular platform for CMA at the moment. > > Signed-off-by: Joonsoo Kim > > diff --git a/mm/cma.c b/mm/cma.c > index 22a5b23..3085e8c 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -36,7 +37,7 @@ struct cma { > unsigned long count; > unsigned long *bitmap; > int order_per_bit; /* Order of pages represented by one bit */ > - struct mutex lock; > + spinlock_t lock; > }; > > /* > @@ -72,9 +73,9 @@ static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count) > bitmapno = (pfn - cma->base_pfn) >> cma->order_per_bit; > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmap_clear(cma->bitmap, bitmapno, nr_bits); > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > } > > static int __init cma_activate_area(struct cma *cma) > @@ -112,7 +113,7 @@ static int __init cma_activate_area(struct cma *cma) > init_cma_reserved_pageblock(pfn_to_page(base_pfn)); > } while (--i); > > - mutex_init(&cma->lock); > + spin_lock_init(&cma->lock); > return 0; > > err: > @@ -261,11 +262,11 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > for (;;) { > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmapno = bitmap_find_next_zero_area(cma->bitmap, > bitmap_maxno, start, nr_bits, mask); > if (bitmapno >= bitmap_maxno) { > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > break; > } > bitmap_set(cma->bitmap, bitmapno, nr_bits); > @@ -274,7 +275,7 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > * our exclusive use. If the migration fails we will take the > * lock again and unmark it. > */ > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > > pfn = cma->base_pfn + (bitmapno << cma->order_per_bit); > mutex_lock(&cma_mutex); > -- > 1.7.9.5 > > -- > 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 -- Kind regards, Minchan Kim From mboxrd@z Thu Jan 1 00:00:00 1970 From: minchan@kernel.org (Minchan Kim) Date: Thu, 12 Jun 2014 16:40:29 +0900 Subject: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex In-Reply-To: <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> References: <1402543307-29800-1-git-send-email-iamjoonsoo.kim@lge.com> <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> Message-ID: <20140612074029.GB12663@bbox> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > Currently, we should take the mutex for manipulating bitmap. > This job may be really simple and short so we don't need to sleep > if contended. So I change it to spinlock. I'm not sure it would be good always. Maybe you remember we discussed about similar stuff about bitmap searching in vmap friend internally, which was really painful when it was fragmented. So, at least we need number if you really want and I hope the number from ARM machine most popular platform for CMA at the moment. > > Signed-off-by: Joonsoo Kim > > diff --git a/mm/cma.c b/mm/cma.c > index 22a5b23..3085e8c 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -36,7 +37,7 @@ struct cma { > unsigned long count; > unsigned long *bitmap; > int order_per_bit; /* Order of pages represented by one bit */ > - struct mutex lock; > + spinlock_t lock; > }; > > /* > @@ -72,9 +73,9 @@ static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count) > bitmapno = (pfn - cma->base_pfn) >> cma->order_per_bit; > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmap_clear(cma->bitmap, bitmapno, nr_bits); > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > } > > static int __init cma_activate_area(struct cma *cma) > @@ -112,7 +113,7 @@ static int __init cma_activate_area(struct cma *cma) > init_cma_reserved_pageblock(pfn_to_page(base_pfn)); > } while (--i); > > - mutex_init(&cma->lock); > + spin_lock_init(&cma->lock); > return 0; > > err: > @@ -261,11 +262,11 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > for (;;) { > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmapno = bitmap_find_next_zero_area(cma->bitmap, > bitmap_maxno, start, nr_bits, mask); > if (bitmapno >= bitmap_maxno) { > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > break; > } > bitmap_set(cma->bitmap, bitmapno, nr_bits); > @@ -274,7 +275,7 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > * our exclusive use. If the migration fails we will take the > * lock again and unmark it. > */ > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > > pfn = cma->base_pfn + (bitmapno << cma->order_per_bit); > mutex_lock(&cma_mutex); > -- > 1.7.9.5 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo at kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email at kvack.org -- Kind regards, Minchan Kim From mboxrd@z Thu Jan 1 00:00:00 1970 From: Minchan Kim Subject: Re: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex Date: Thu, 12 Jun 2014 16:40:29 +0900 Message-ID: <20140612074029.GB12663@bbox> References: <1402543307-29800-1-git-send-email-iamjoonsoo.kim@lge.com> <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Morton , "Aneesh Kumar K.V" , Marek Szyprowski , Michal Nazarewicz , Russell King - ARM Linux , Greg Kroah-Hartman , Paolo Bonzini , Gleb Natapov , Alexander Graf , Benjamin Herrenschmidt , Paul Mackerras , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org To: Joonsoo Kim Return-path: Content-Disposition: inline In-Reply-To: <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > Currently, we should take the mutex for manipulating bitmap. > This job may be really simple and short so we don't need to sleep > if contended. So I change it to spinlock. I'm not sure it would be good always. Maybe you remember we discussed about similar stuff about bitmap searching in vmap friend internally, which was really painful when it was fragmented. So, at least we need number if you really want and I hope the number from ARM machine most popular platform for CMA at the moment. > > Signed-off-by: Joonsoo Kim > > diff --git a/mm/cma.c b/mm/cma.c > index 22a5b23..3085e8c 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -36,7 +37,7 @@ struct cma { > unsigned long count; > unsigned long *bitmap; > int order_per_bit; /* Order of pages represented by one bit */ > - struct mutex lock; > + spinlock_t lock; > }; > > /* > @@ -72,9 +73,9 @@ static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count) > bitmapno = (pfn - cma->base_pfn) >> cma->order_per_bit; > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmap_clear(cma->bitmap, bitmapno, nr_bits); > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > } > > static int __init cma_activate_area(struct cma *cma) > @@ -112,7 +113,7 @@ static int __init cma_activate_area(struct cma *cma) > init_cma_reserved_pageblock(pfn_to_page(base_pfn)); > } while (--i); > > - mutex_init(&cma->lock); > + spin_lock_init(&cma->lock); > return 0; > > err: > @@ -261,11 +262,11 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > for (;;) { > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmapno = bitmap_find_next_zero_area(cma->bitmap, > bitmap_maxno, start, nr_bits, mask); > if (bitmapno >= bitmap_maxno) { > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > break; > } > bitmap_set(cma->bitmap, bitmapno, nr_bits); > @@ -274,7 +275,7 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > * our exclusive use. If the migration fails we will take the > * lock again and unmark it. > */ > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > > pfn = cma->base_pfn + (bitmapno << cma->order_per_bit); > mutex_lock(&cma_mutex); > -- > 1.7.9.5 > > -- > 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 -- Kind regards, Minchan Kim From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by kanga.kvack.org (Postfix) with ESMTP id 1E883900002 for ; Thu, 12 Jun 2014 03:40:21 -0400 (EDT) Received: by mail-pa0-f45.google.com with SMTP id rd3so131009pab.18 for ; Thu, 12 Jun 2014 00:40:20 -0700 (PDT) Received: from lgemrelse7q.lge.com (LGEMRELSE7Q.lge.com. [156.147.1.151]) by mx.google.com with ESMTP id xp2si40740615pbc.57.2014.06.12.00.40.19 for ; Thu, 12 Jun 2014 00:40:20 -0700 (PDT) Date: Thu, 12 Jun 2014 16:40:29 +0900 From: Minchan Kim Subject: Re: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex Message-ID: <20140612074029.GB12663@bbox> References: <1402543307-29800-1-git-send-email-iamjoonsoo.kim@lge.com> <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1402543307-29800-11-git-send-email-iamjoonsoo.kim@lge.com> Sender: owner-linux-mm@kvack.org List-ID: To: Joonsoo Kim Cc: Andrew Morton , "Aneesh Kumar K.V" , Marek Szyprowski , Michal Nazarewicz , Russell King - ARM Linux , Greg Kroah-Hartman , Paolo Bonzini , Gleb Natapov , Alexander Graf , Benjamin Herrenschmidt , Paul Mackerras , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > Currently, we should take the mutex for manipulating bitmap. > This job may be really simple and short so we don't need to sleep > if contended. So I change it to spinlock. I'm not sure it would be good always. Maybe you remember we discussed about similar stuff about bitmap searching in vmap friend internally, which was really painful when it was fragmented. So, at least we need number if you really want and I hope the number from ARM machine most popular platform for CMA at the moment. > > Signed-off-by: Joonsoo Kim > > diff --git a/mm/cma.c b/mm/cma.c > index 22a5b23..3085e8c 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -36,7 +37,7 @@ struct cma { > unsigned long count; > unsigned long *bitmap; > int order_per_bit; /* Order of pages represented by one bit */ > - struct mutex lock; > + spinlock_t lock; > }; > > /* > @@ -72,9 +73,9 @@ static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count) > bitmapno = (pfn - cma->base_pfn) >> cma->order_per_bit; > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmap_clear(cma->bitmap, bitmapno, nr_bits); > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > } > > static int __init cma_activate_area(struct cma *cma) > @@ -112,7 +113,7 @@ static int __init cma_activate_area(struct cma *cma) > init_cma_reserved_pageblock(pfn_to_page(base_pfn)); > } while (--i); > > - mutex_init(&cma->lock); > + spin_lock_init(&cma->lock); > return 0; > > err: > @@ -261,11 +262,11 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > nr_bits = cma_bitmap_pages_to_bits(cma, count); > > for (;;) { > - mutex_lock(&cma->lock); > + spin_lock(&cma->lock); > bitmapno = bitmap_find_next_zero_area(cma->bitmap, > bitmap_maxno, start, nr_bits, mask); > if (bitmapno >= bitmap_maxno) { > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > break; > } > bitmap_set(cma->bitmap, bitmapno, nr_bits); > @@ -274,7 +275,7 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align) > * our exclusive use. If the migration fails we will take the > * lock again and unmark it. > */ > - mutex_unlock(&cma->lock); > + spin_unlock(&cma->lock); > > pfn = cma->base_pfn + (bitmapno << cma->order_per_bit); > mutex_lock(&cma_mutex); > -- > 1.7.9.5 > > -- > 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 -- Kind regards, Minchan Kim -- 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