Re: [PATCH 3/3] percpu: add macro PCPU_CHUNK_AREA_IN_USE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]