lkml.org 
[lkml]   [2015]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] percpu: add macro PCPU_CHUNK_AREA_IN_USE
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


\
 
 \ /
  Last update: 2015-07-22 03:01    [W:0.100 / U:1.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site