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 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/