Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934184AbbGVAZ3 (ORCPT ); Tue, 21 Jul 2015 20:25:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41454 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690AbbGVAZ1 (ORCPT ); Tue, 21 Jul 2015 20:25:27 -0400 Date: Wed, 22 Jul 2015 08:25:22 +0800 From: Baoquan He To: Christoph Lameter 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 Message-ID: <20150722002522.GB1834@dhcp-17-102.nay.redhat.com> References: <1437404130-5188-1-git-send-email-bhe@redhat.com> <1437404130-5188-3-git-send-email-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1778 Lines: 45 Hi Christoph, On 07/20/15 at 10:35am, Christoph Lameter wrote: > On Mon, 20 Jul 2015, Baoquan He wrote: > > > chunk->map[] contains 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/