percpu: use bitmap_clear
Subsystems (10)
PATCH 1/1 percpu: use bitmap_clear
Use bitmap_clear rather than clearing individual bits in a memory region.
--- mm/percpu-vm.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
mm/percpu-vm.c +1 -2
@@ -184,8 +184,7 @@ static void pcpu_unmap_pages(struct pcpu_chunk *chunk, page_end - page_start); } -for (i = page_start; i < page_end; i++) -__clear_bit (i, populated); +bitmap_clear (populated, page_start, page_end - page_start); }/**
Signature · 1 line
1.7.4.4
PATCH 1/1 ocfs2: use find_last_bit
We already have find_last_bit. So just use it as described in the comment.
--- fs/ocfs2/cluster/heartbeat.c | 18 ++---------------- 1 files changed, 2 insertions(+), 16 deletions(-)
fs/ocfs2/cluster/heartbeat.c +2 -16
@@ -956,23 +956,9 @@ out:return changed; } -/* This could be faster if we just implmented a find_last_bit, but I -* don't think the circumstances warrant it. */ -static int o2hb_highest_node (unsigned long *nodes, -int numbits) +static int o2hb_highest_node (unsigned long *nodes,int numbits) { -int highest, node; - - highest = numbits; - node =-1 ; -while ((node =find_next_bit (nodes, numbits, node +1 )) !=-1 ) { -if (node >= numbits) -break ; - - highest = node; - } - -return highest; +return find_last_bit (nodes, numbits); }static int o2hb_do_disk_heartbeat (struct o2hb_region *reg)
Signature · 1 line
1.7.4.4
PATCH 1/1 ocfs2: use bitmap_weight()
In reply to Akinobu MitaUse bitmap_weight instead of reinventing the wheel.
--- fs/ocfs2/cluster/heartbeat.c | 22 +++++++--------------- 1 files changed, 7 insertions(+), 15 deletions(-)
fs/ocfs2/cluster/heartbeat.c +7 -15
@@ -35,6 +35,7 @@#include <linux/time.h> #include <linux/debugfs.h> #include <linux/slab.h> +#include <linux/bitmap.h> #include "heartbeat.h" #include "tcp.h"
@@ -282,15 +283,6 @@ struct o2hb_bio_wait_ctxt {int wc_error; }; -static int o2hb_pop_count (void *map,int count) -{ -int i =-1 , pop =0 ; - -while ((i =find_next_bit (map, count, i +1 )) < count) - pop++; -return pop; -} -static void o2hb_write_timeout (struct work_struct *work) {int failed, quorum;
@@ -307,9 +299,9 @@ static void o2hb_write_timeout(struct work_struct *work)spin_lock_irqsave (&o2hb_live_lock, flags);if (test_bit (reg->hr_region_num, o2hb_quorum_region_bitmap))set_bit (reg->hr_region_num, o2hb_failed_region_bitmap); - failed =o2hb_pop_count (&o2hb_failed_region_bitmap, + failed =bitmap_weight (o2hb_failed_region_bitmap,O2NM_MAX_REGIONS ); - quorum =o2hb_pop_count (&o2hb_quorum_region_bitmap, + quorum =bitmap_weight (o2hb_quorum_region_bitmap,O2NM_MAX_REGIONS );spin_unlock_irqrestore (&o2hb_live_lock, flags);
@@ -771,7 +763,7 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg)* If global heartbeat active, unpin all regions if the * region count > CUT_OFF */ -if (o2hb_pop_count (&o2hb_quorum_region_bitmap, +if (bitmap_weight (o2hb_quorum_region_bitmap,O2NM_MAX_REGIONS ) >O2HB_PIN_CUT_OFF )o2hb_region_unpin (NULL ); unlock:
@@ -1813,7 +1805,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, live_threshold =O2HB_LIVE_THRESHOLD ;if (o2hb_global_heartbeat_active ()) {spin_lock (&o2hb_live_lock); -if (o2hb_pop_count (&o2hb_region_bitmap,O2NM_MAX_REGIONS ) ==1 ) +if (bitmap_weight (o2hb_region_bitmap,O2NM_MAX_REGIONS ) ==1 ) live_threshold <<=1 ;spin_unlock (&o2hb_live_lock); }
@@ -2164,7 +2156,7 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group,if (!o2hb_dependent_users) goto unlock; -if (o2hb_pop_count (&o2hb_quorum_region_bitmap, +if (bitmap_weight (o2hb_quorum_region_bitmap,O2NM_MAX_REGIONS ) <=O2HB_PIN_CUT_OFF )o2hb_region_pin (NULL );
@@ -2458,7 +2450,7 @@ static int o2hb_region_inc_user(const char *region_uuid)if (o2hb_dependent_users >1 ) goto unlock; -if (o2hb_pop_count (&o2hb_quorum_region_bitmap, +if (bitmap_weight (o2hb_quorum_region_bitmap,O2NM_MAX_REGIONS ) <=O2HB_PIN_CUT_OFF ) ret =o2hb_region_pin (NULL );
Signature · 1 line
1.7.4.4
PATCH 1/1 xen-blkfront: use bitmap_set() and bitmap_clear()
In reply to Akinobu MitaUse bitmap_set and bitmap_clear rather than modifying individual bits in a memory region.
--- drivers/block/xen-blkfront.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/block/xen-blkfront.c +3 -4
@@ -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); }
Signature · 1 line
1.7.4.4
PATCH 1/1 hpsa: use find_first_zero_bit
In reply to Akinobu MitaUse find_first_zero_bit to find the first cleared bit in a memory region.
This also includes the following minor changes.
- Use bitmap_zero
- Reduce unnecessary atomic bitops usage
--- drivers/scsi/hpsa.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-)
drivers/scsi/hpsa.c +8 -10
@@ -577,21 +577,19 @@ static int hpsa_find_target_lun(struct ctlr_info *h,int i, found =0 ;DECLARE_BITMAP (lun_taken,HPSA_MAX_DEVICES ); -memset (&lun_taken[0 ],0 ,HPSA_MAX_DEVICES >>3 ); +bitmap_zero (lun_taken,HPSA_MAX_DEVICES );for (i =0 ; i < h->ndevices; i++) {if (h->dev[i]->bus == bus && h->dev[i]->target !=-1 ) -set_bit (h->dev[i]->target, lun_taken); +__set_bit (h->dev[i]->target, lun_taken); } -for (i =0 ; i <HPSA_MAX_DEVICES ; i++) { -if (!test_bit (i, lun_taken)) { -/* *bus = 1; */ - *target = i; - *lun =0 ; - found =1 ; -break ; - } + i =find_first_zero_bit (lun_taken,HPSA_MAX_DEVICES ); +if (i <HPSA_MAX_DEVICES ) { +/* *bus = 1; */ + *target = i; + *lun =0 ; + found =1 ; }return !found; }
Signature · 1 line
1.7.4.4
PATCH 1/1 sysctl: use bitmap library functions
In reply to Akinobu MitaUse bitmap_set() instead of using set_bit() for each bit. This conversion is valid because the bitmap is private in the function call and atomic bitops was unnecessary.
This also includes minor change.
- Use bitmap_copy() for shorter typing
--- kernel/sysctl.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
kernel/sysctl.c +3 -5
@@ -58,6 +58,7 @@#include <linux/oom.h> #include <linux/kmod.h> #include <linux/capability.h> +#include <linux/bitmap.h> #include <asm/uaccess.h> #include <asm/processor.h>
@@ -2884,9 +2885,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, } } -while (val_a <= val_b) -set_bit (val_a++, tmp_bitmap); - +bitmap_set (tmp_bitmap, val_a, val_b - val_a +1 ); first =0 ;proc_skip_char (&kbuf, &left,'\n' ); }
@@ -2929,8 +2928,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,if (*ppos)bitmap_or (bitmap, bitmap, tmp_bitmap, bitmap_len);else -memcpy (bitmap, tmp_bitmap, -BITS_TO_LONGS (bitmap_len) *sizeof (unsigned long )); +bitmap_copy (bitmap, tmp_bitmap, bitmap_len); }kfree (tmp_bitmap); *lenp -= left;
Signature · 1 line
1.7.4.4
Quoted 1 line · Akinobu Mita
Use
bitmap_clearrather than clearing individual bits in a memory region.
Re: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
In reply to Akinobu MitaI used Jeremy Fitzhardinge's old email address...
2012/1/21 Akinobu Mita <[email protected]>:
Quoted 5 lines
Use
bitmap_setandbitmap_clearrather than modifying individual bits in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>
Quoted 42 lines
---
drivers/block/xen-blkfront.c | 7 +++----1 files changed, 3 insertions(+), 4 deletions(-)drivers/block/xen-blkfront.c +3
-5@@ -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
Re: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
In reply to Akinobu MitaQuoted 25 lines · Akinobu Mita
Use
bitmap_setandbitmap_clearrather than modifying individual bits in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- drivers/block/xen-blkfront.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)drivers/block/xen-blkfront.c +1
-0@@ -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>
drivers/block/xen-blkfront.c static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) · line 181
Quoted 6 lines
drivers/block/xen-blkfront.c +1
-2@@ -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?
drivers/block/xen-blkfront.c static void xlbd_release_minors(unsigned int minor, unsigned int nr) · line 196
Quoted 10 lines
drivers/block/xen-blkfront.c +1
-2rc =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.
Quoted 11 lines
drivers/block/xen-blkfront.c +0
-0spin_unlock (&minor_lock); }Signature · 7 lines
1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] hpsa: use find_first_zero_bit
In reply to Akinobu MitaQuoted 5 lines · Akinobu Mita
Use
find_first_zero_bitto find the first cleared bit in a memory region.This also includes the following minor changes.
- Usebitmap_zero
- Reduce unnecessary atomic bitops usage
Ack.
This isn't performance sensitive code though, hpsa_find_target_lun() only gets called during device discovery when a multi-lun device like a tape drive with an auto changer is encountered.
I tried it out and it doesn't conflict with any of the patches I sent up yesterday, and it works with a tape drive/autochanger.
-- steve
Quoted 46 lines
Signed-off-by Akinobu Mita <[email protected]>Cc "Stephen M. Cameron" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>--- drivers/scsi/hpsa.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-)drivers/scsi/hpsa.c +8
-10@@ -577,21 +577,19 @@ static int hpsa_find_target_lun(struct ctlr_info *h,int i, found =0 ;DECLARE_BITMAP (lun_taken,HPSA_MAX_DEVICES ); -memset (&lun_taken[0 ],0 ,HPSA_MAX_DEVICES >>3 ); +bitmap_zero (lun_taken,HPSA_MAX_DEVICES );for (i =0 ; i < h->ndevices; i++) {if (h->dev[i]->bus == bus && h->dev[i]->target !=-1 ) -set_bit (h->dev[i]->target, lun_taken); +__set_bit (h->dev[i]->target, lun_taken); } -for (i =0 ; i <HPSA_MAX_DEVICES ; i++) { -if (!test_bit (i, lun_taken)) { -/* *bus = 1; */ - *target = i; - *lun =0 ; - found =1 ; -break ; - } + i =find_first_zero_bit (lun_taken,HPSA_MAX_DEVICES ); +if (i <HPSA_MAX_DEVICES ) { +/* *bus = 1; */ + *target = i; + *lun =0 ; + found =1 ; }return !found; }Signature · 1 line
1.7.4.4
Re: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
In reply to Konrad Rzeszutek Wilk2012/1/21 Konrad Rzeszutek Wilk <[email protected]>:
Quoted 27 lines · Akinobu Mita
Quoted 26 lines
Use
bitmap_setandbitmap_clearrather than modifying individual bits in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>---
drivers/block/xen-blkfront.c | 7 +++----1 files changed, 3 insertions(+), 4 deletions(-)drivers/block/xen-blkfront.c +1
-0@@ -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)
Quoted 7 lines
drivers/block/xen-blkfront.c static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) · line 181
Quoted 5 lines
drivers/block/xen-blkfront.c +1
-2spin_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'?
'end' is the index of the last bit to clear. But the last argument of bitmap_clear() is the number of bits to clear. So I think 'nr' is correct.
Quoted 1 line
Did you test this patch with a large amount of minors?
Sorry I didn't do runtime test.
Quoted 23 lines
drivers/block/xen-blkfront.c static void xlbd_release_minors(unsigned int minor, unsigned int nr) · line 196
Quoted 10 lines
drivers/block/xen-blkfront.c +1
-2rc = 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.
Quoted 11 lines
drivers/block/xen-blkfront.c +0
-1spin_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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
Quoted 36 lines · Akinobu Mita
2012/1/21 Konrad Rzeszutek Wilk <[email protected]>:
Quoted 27 lines · Akinobu Mita
Quoted 26 lines
Use
bitmap_setandbitmap_clearrather than modifying individual bits in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>---
drivers/block/xen-blkfront.c | 7 +++----1 files changed, 3 insertions(+), 4 deletions(-)drivers/block/xen-blkfront.c +1
-0@@ -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)Quoted 7 lines
drivers/block/xen-blkfront.c static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) · line 181
Quoted 5 lines
drivers/block/xen-blkfront.c +1
-2spin_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'?
Quoted 2 lines
'end' is the index of the last bit to clear. But the last argument of
bitmap_clear()is the number of bits to clear. So I think 'nr' is correct.
Ah, I see it.
Quoted 4 lines
Quoted 2 lines
Did you test this patch with a large amount of minors?
Sorry I didn't do runtime test.
Please do.
Quoted 5 lines · Akinobu Mita
Use
bitmap_clearrather than clearing individual bits in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Tejun Heo <[email protected]>Cc Christoph Lameter <[email protected]>
Applied to percpu/for-3.4 w/ cl's ack added.
Thanks.
Signature · 1 line
tejun
Andrew Morton
maintainerRe: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
In reply to Konrad Rzeszutek WilkQuoted 6 lines · On Fri, 20 Jan 2012 11:09:38 -0500 Konrad Rzeszutek Wilk…
Quoted 4 lines
Quoted 2 lines
Did you test this patch with a large amount of minors?
Sorry I didn't do runtime test.
Please do.
The poor guy probably doesn't know how to test it and surely it would be quite a lot of work for him to do so.
Overall, it would be much more efficient if the tester of this code is someone who is set up to easily apply the patch and test it. ie: the code maintainer(s).
Re: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Fri, 20 Jan 2012 11:09:38 -0500 Konrad Rzeszutek Wilk…
Quoted 4 lines
Quoted 2 lines
Did you test this patch with a large amount of minors?
Sorry I didn't do runtime test.
Quoted 8 lines
Quoted 1 line
Please do.
The poor guy probably doesn't know how to test it and surely it would be quite a lot of work for him to do so.
Overall, it would be much more efficient if the tester of this code is someone who is set up to easily apply the patch and test it. ie: the code maintainer(s).
<grins>
This patch aside - Andrew how do you deal with a large amount of patches and make sure they are tested? Is there a weekly Test Tuesday where you kick off your automated tests and dilligently look for any variations?
Or is it more of compile the kernel with X features and run it for a week doing normal (and abnormal!) things to see if it falls over?
Thanks!
Andrew Morton
maintainerRe: [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
Quoted 14 lines · On Fri, 20 Jan 2012 18:55:08 -0500 Konrad Rzeszutek Wilk…
Quoted 13 lines · Andrew Morton
Quoted 6 lines · On Fri, 20 Jan 2012 11:09:38 -0500 Konrad Rzeszutek Wilk…
Quoted 4 lines
Quoted 2 lines
Did you test this patch with a large amount of minors?
Sorry I didn't do runtime test.
Please do.
The poor guy probably doesn't know how to test it and surely it would be quite a lot of work for him to do so.
Quoted 8 lines
Quoted 3 lines
Overall, it would be much more efficient if the tester of this code is someone who is set up to easily apply the patch and test it. ie: the code maintainer(s).
<grins>
This patch aside - Andrew how do you deal with a large amount of patches and make sure they are tested?
Not very well :(
Quoted 4 lines
Is there a weekly Test Tuesday where you
kick off your automated tests and dilligently look for any variations? Or is it more of compile the kernel with X features and run it for a week doing normal (and abnormal!) things to see if it falls over?
I build all the patches I have along with all of linux-next and boot the thing, then use the resulting kernel for a few hours compilation testing, then shove it all into linux-next where I naively hope that someone else is testing things.
The coverage which is obtained this way is pretty poor.