From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Alasdair Kergon <agk@redhat.com>,
dm-devel@redhat.com
Subject: [PATCH v2 04/10] dm: use memweight()
Date: Sat, 2 Jun 2012 22:40:10 +0900 [thread overview]
Message-ID: <1338644416-11417-4-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1338644416-11417-1-git-send-email-akinobu.mita@gmail.com>
Use memweight() to count the total number of bits set in memory area.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: dm-devel@redhat.com
---
v2: change patch title s/dm-log:/dm:/
drivers/md/dm-log.c | 13 ++-----------
1 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index 65ebaeb..627d191 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -571,16 +571,6 @@ static void disk_dtr(struct dm_dirty_log *log)
destroy_log_context(lc);
}
-static int count_bits32(uint32_t *addr, unsigned size)
-{
- int count = 0, i;
-
- for (i = 0; i < size; i++) {
- count += hweight32(*(addr+i));
- }
- return count;
-}
-
static void fail_log_device(struct log_c *lc)
{
if (lc->log_dev_failed)
@@ -629,7 +619,8 @@ static int disk_resume(struct dm_dirty_log *log)
/* copy clean across to sync */
memcpy(lc->sync_bits, lc->clean_bits, size);
- lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
+ lc->sync_count = memweight(lc->clean_bits,
+ lc->bitset_uint32_count * sizeof(uint32_t));
lc->sync_search = 0;
/* set the correct number of regions in the header */
--
1.7.7.6
next prev parent reply other threads:[~2012-06-02 13:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-02 13:40 [PATCH v2 01/10] string: introduce memweight Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 02/10] minixfs: use memweight() Akinobu Mita
2012-06-04 10:26 ` Jan Kara
2012-06-02 13:40 ` [PATCH v2 03/10] qnx4fs: " Akinobu Mita
2012-06-02 13:40 ` Akinobu Mita [this message]
2012-06-02 13:40 ` [PATCH v2 05/10] affs: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 06/10] video/uvc: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 07/10] ocfs2: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 08/10] ext2: " Akinobu Mita
2012-06-04 10:10 ` Jan Kara
2012-06-02 13:40 ` [PATCH v2 09/10] ext3: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 10/10] ext4: " Akinobu Mita
2012-06-02 14:35 ` Andreas Dilger
2012-06-03 12:57 ` Akinobu Mita
2012-06-04 10:12 ` [PATCH v2 01/10] string: introduce memweight Jan Kara
2012-06-04 11:46 ` Akinobu Mita
2012-06-04 13:35 ` Jan Kara
2012-06-05 9:03 ` Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338644416-11417-4-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).