linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: tj@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] percpu: add macro PCPU_CHUNK_AREA_IN_USE
Date: Wed, 22 Jul 2015 08:25:22 +0800	[thread overview]
Message-ID: <20150722002522.GB1834@dhcp-17-102.nay.redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1507201034210.14535@east.gentwo.org>

Hi Christoph,

On 07/20/15 at 10:35am, Christoph Lameter wrote:
> On Mon, 20 Jul 2015, Baoquan He wrote:
> 
> > chunk->map[] contains <offset|in-use flag> of each area. Now add a
> > new macro PCPU_CHUNK_AREA_IN_USE and use it as the in-use flag to
> > replace all magic number '1'.
> 
> Hmmm... This is a bitflag and the code now looks like there is some sort
> of bitmask that were are using. Use bitops or something else that clearly
> implies that a bit is flipped instead?

Thanks for your reviewing and suggesting.

I tried your suggestion and changed to use set_bit/clear_bit to do
instead. It's like this:

@@ -328,8 +329,10 @@ static void pcpu_mem_free(void *ptr, size_t size)
  */
 static int pcpu_count_occupied_pages(struct pcpu_chunk *chunk, int i)
 {
-       int off = chunk->map[i] & ~1;
-       int end = chunk->map[i + 1] & ~1;
+       int off = chunk->map[i];
+       int end = chunk->map[i + 1];
+       clear_bit(PCPU_CHUNK_AREA_IN_USE_BIT, &chunk->map[i]);
+       clear_bit(PCPU_CHUNK_AREA_IN_USE_BIT, &chunk->map[i + 1]);

Looks like code becomes a little redundent. If several different bits in
chunk->map[] have different usage and need several different flags,
bitops maybe better. While now only the lowest bit need be handle, use
bitops kindof too much and can make code a little messy.

You and Tejun may be a little struggled on this change since it make
code longer. Tejun has suggested that at least use a shorter name, like
PCPU_MAP_BUSY. I am going to post v2 to see if it's better.

Thanks
Baoquan

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-07-22  0:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 14:55 [PATCH 1/3] percpu: clean up of schunk->map[] assignment in pcpu_setup_first_chunk Baoquan He
2015-07-20 14:55 ` [PATCH 2/3] perpuc: check pcpu_first_chunk and pcpu_reserved_chunk to avoid handling them twice Baoquan He
2015-07-21 15:28   ` Tejun Heo
2015-07-22  0:03     ` Baoquan He
2015-07-22 13:52       ` Tejun Heo
2015-07-22 14:29         ` Baoquan He
2015-07-22 14:37           ` Tejun Heo
2015-07-23  1:56             ` Baoquan He
2015-07-23  1:53   ` [PATCH v3 2/3] percpu: Add WARN_ON into percpu_init_late Baoquan He
2015-07-20 14:55 ` [PATCH 3/3] percpu: add macro PCPU_CHUNK_AREA_IN_USE Baoquan He
2015-07-20 15:35   ` Christoph Lameter
2015-07-22  0:25     ` Baoquan He [this message]
2015-07-21 15:30   ` Tejun Heo
2015-07-22  0:28     ` Baoquan He
2015-07-22 13:53       ` Tejun Heo
2015-07-23  1:55         ` Baoquan He
2015-07-23  1:50   ` [PATCH v2 3/3] percpu: add macro PCPU_MAP_BUSY Baoquan He
2015-07-20 15:32 ` [PATCH 1/3] percpu: clean up of schunk->map[] assignment in pcpu_setup_first_chunk Christoph Lameter
2015-07-21 15:33 ` Tejun Heo
2015-07-22  0:56   ` Baoquan He

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=20150722002522.GB1834@dhcp-17-102.nay.redhat.com \
    --to=bhe@redhat.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@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