Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758821AbbBHSs0 (ORCPT ); Sun, 8 Feb 2015 13:48:26 -0500 Received: from ns.horizon.com ([71.41.210.147]:56864 "HELO ns.horizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1758285AbbBHSsZ (ORCPT ); Sun, 8 Feb 2015 13:48:25 -0500 Date: 8 Feb 2015 13:48:23 -0500 Message-ID: <20150208184823.31349.qmail@ns.horizon.com> From: "George Spelvin" To: akpm@linux-foundation.org, chris@chris-wilson.co.uk, davem@davemloft.net, dborkman@redhat.com, hannes@stressinduktion.org, klimov.linux@gmail.com, laijs@cn.fujitsu.com, linux@horizon.com, msalter@redhat.com, takahiro.akashi@linaro.org, tgraf@suug.ch, valentinrothberg@gmail.com, yury.norov@gmail.com Subject: Re: [PATCH v3 1/3] lib: find_*_bit reimplementation Cc: linux-kernel@vger.kernel.org In-Reply-To: <1423404619-10653-2-git-send-email-yury.norov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1858 Lines: 57 This basically has my Reviewed-by: (I'll send it in a few hours when I have time to do a real final copy-editing), but a few minor notes: >+ /* >+ * This is an equvalent for: >+ * >+ * tmp = find_set ? addr[start / BITS_PER_LONG] >+ * : ~addr[start / BITS_PER_LONG]; >+ * >+ * but saves a branch condition. >+ * >+ * Thanks George Spelvin for idea. >+ */ >+ tmp = addr[start / BITS_PER_LONG] ^ mask; 1. There's no need for detailed credit for such a trivial and obvious thing. If you want to comment it, describe the use of the parameter in the function header, e.g. +/* + * "mask" is either 0 or ~0UL and XORed into each fetched word, to select between + * searching for one bits and zero bits. If this function is inlined, GCC is + * smart enough to propagate the constant. + */ 2. The variable might be more meaningfully named "xor" or "invert"; "mask" suggests something that is &-ed with a value. > unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, > unsigned long offset) > { >+ return _find_next_bit(addr, size, offset, ~0UL); <--- > } > unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) > { >+ unsigned long idx; > >+ for (idx = 0; idx * BITS_PER_LONG < size; idx++) { >+ if (addr[idx] != ULONG_MAX) <--- >+ return min(idx * BITS_PER_LONG + ffz(addr[idx]), size); > } > >+ return size; > } 3. Using two names (ULONG_MAX and ~0UL) for the same thing is a bit odd; you might want to be consistent. I'll ack it either way; none of these are significant technical issues. -- 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/