From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967008AbbLQPEi (ORCPT ); Thu, 17 Dec 2015 10:04:38 -0500 Received: from s3.sipsolutions.net ([5.9.151.49]:51407 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755687AbbLQPEg (ORCPT ); Thu, 17 Dec 2015 10:04:36 -0500 Message-ID: <1450364668.8247.34.camel@sipsolutions.net> Subject: Re: [PATCH 1/1] mac80211: improve the contiguous mask checking From: Johannes Berg To: Zeng Zhaoxiu , davem@davemloft.net Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 17 Dec 2015 16:04:28 +0100 In-Reply-To: <1450364392-76874-1-git-send-email-zhaoxiu.zeng@gmail.com> (sfid-20151217_160054_877867_44DDA348) References: <1450364392-76874-1-git-send-email-zhaoxiu.zeng@gmail.com> (sfid-20151217_160054_877867_44DDA348) Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-12-17 at 22:59 +0800, Zeng Zhaoxiu wrote: > If the result of adding the first set bit to the mask is power of 2, > the mask must be contiguous. "mask & -mask" can get the first set bit > of mask gracefully. > - if (__ffs64(mask) + hweight64(mask) != fls64(mask)) > { > + inc = (mask & -mask); > + val = mask + inc; > + if ((val & (val - 1)) != 0) { >   /* not a contiguous mask ... not handled now! */ Hm. Ok, I can see how that would work, but it doesn't really seem like much of an "improvement" to me? Surely I seem to need much more thinking to understand this. There's no reason to optimise it either, so why should we change it? johannes