Akinobu Mita
2012-Jan-20 15:15 UTC
[PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
Use bitmap_set and bitmap_clear rather than modifying individual bits in a memory region. Signed-off-by: Akinobu Mita <akinobu.mita at gmail.com> Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge at citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com> Cc: xen-devel at lists.xensource.com Cc: virtualization at lists.linux-foundation.org --- drivers/block/xen-blkfront.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2f22874..619868d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -43,6 +43,7 @@ #include <linux/slab.h> #include <linux/mutex.h> #include <linux/scatterlist.h> +#include <linux/bitmap.h> #include <xen/xen.h> #include <xen/xenbus.h> @@ -177,8 +178,7 @@ static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) spin_lock(&minor_lock); if (find_next_bit(minors, end, minor) >= end) { - for (; minor < end; ++minor) - __set_bit(minor, minors); + bitmap_set(minors, minor, nr); rc = 0; } else rc = -EBUSY; @@ -193,8 +193,7 @@ static void xlbd_release_minors(unsigned int minor, unsigned int nr) BUG_ON(end > nr_minors); spin_lock(&minor_lock); - for (; minor < end; ++minor) - __clear_bit(minor, minors); + bitmap_clear(minors, minor, nr); spin_unlock(&minor_lock); } -- 1.7.4.4
Akinobu Mita
2012-Jan-20 15:27 UTC
[PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
I used Jeremy Fitzhardinge's old email address... 2012/1/21 Akinobu Mita <akinobu.mita at gmail.com>:> Use bitmap_set and bitmap_clear rather than modifying individual bits > in a memory region. > > Signed-off-by: Akinobu Mita <akinobu.mita at gmail.com> > Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge at citrix.com>Cc: Jeremy Fitzhardinge <jeremy at goop.org>> Cc: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com> > Cc: xen-devel at lists.xensource.com > Cc: virtualization at lists.linux-foundation.org > --- > ?drivers/block/xen-blkfront.c | ? ?7 +++---- > ?1 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c > index 2f22874..619868d 100644 > --- a/drivers/block/xen-blkfront.c > +++ b/drivers/block/xen-blkfront.c > @@ -43,6 +43,7 @@ > ?#include <linux/slab.h> > ?#include <linux/mutex.h> > ?#include <linux/scatterlist.h> > +#include <linux/bitmap.h> > > ?#include <xen/xen.h> > ?#include <xen/xenbus.h> > @@ -177,8 +178,7 @@ static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) > > ? ? ? ?spin_lock(&minor_lock); > ? ? ? ?if (find_next_bit(minors, end, minor) >= end) { > - ? ? ? ? ? ? ? for (; minor < end; ++minor) > - ? ? ? ? ? ? ? ? ? ? ? __set_bit(minor, minors); > + ? ? ? ? ? ? ? bitmap_set(minors, minor, nr); > ? ? ? ? ? ? ? ?rc = 0; > ? ? ? ?} else > ? ? ? ? ? ? ? ?rc = -EBUSY; > @@ -193,8 +193,7 @@ static void xlbd_release_minors(unsigned int minor, unsigned int nr) > > ? ? ? ?BUG_ON(end > nr_minors); > ? ? ? ?spin_lock(&minor_lock); > - ? ? ? for (; minor < end; ++minor) > - ? ? ? ? ? ? ? __clear_bit(minor, minors); > + ? ? ? bitmap_clear(minors, ?minor, nr); > ? ? ? ?spin_unlock(&minor_lock); > ?} > > -- > 1.7.4.4 >
Konrad Rzeszutek Wilk
2012-Jan-20 15:28 UTC
[PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
On Sat, Jan 21, 2012 at 12:15:26AM +0900, Akinobu Mita wrote:> Use bitmap_set and bitmap_clear rather than modifying individual bits > in a memory region. > > Signed-off-by: Akinobu Mita <akinobu.mita at gmail.com> > Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge at citrix.com> > Cc: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com> > Cc: xen-devel at lists.xensource.com > Cc: virtualization at lists.linux-foundation.org > --- > drivers/block/xen-blkfront.c | 7 +++---- > 1 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c > index 2f22874..619868d 100644 > --- a/drivers/block/xen-blkfront.c > +++ b/drivers/block/xen-blkfront.c > @@ -43,6 +43,7 @@ > #include <linux/slab.h> > #include <linux/mutex.h> > #include <linux/scatterlist.h> > +#include <linux/bitmap.h> > > #include <xen/xen.h> > #include <xen/xenbus.h> > @@ -177,8 +178,7 @@ static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) > > spin_lock(&minor_lock); > if (find_next_bit(minors, end, minor) >= end) { > - for (; minor < end; ++minor) > - __set_bit(minor, minors); > + bitmap_set(minors, minor, nr);Hm, I would have thought the last argument should have been 'end'? Did you test this patch with a large amount of minors?> rc = 0; > } else > rc = -EBUSY; > @@ -193,8 +193,7 @@ static void xlbd_release_minors(unsigned int minor, unsigned int nr) > > BUG_ON(end > nr_minors); > spin_lock(&minor_lock); > - for (; minor < end; ++minor) > - __clear_bit(minor, minors); > + bitmap_clear(minors, minor, nr);Ditto.> spin_unlock(&minor_lock); > } > > -- > 1.7.4.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/