From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932563AbcFOMoM (ORCPT ); Wed, 15 Jun 2016 08:44:12 -0400 Received: from ns.sciencehorizons.net ([71.41.210.147]:28102 "HELO ns.sciencehorizons.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932130AbcFOMoK (ORCPT ); Wed, 15 Jun 2016 08:44:10 -0400 Date: 15 Jun 2016 08:44:09 -0400 Message-ID: <20160615124409.6985.qmail@ns.sciencehorizons.net> From: "George Spelvin" To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, maddy@linux.vnet.ibm.com Subject: Re: [PATCH] tools/perf: fix the word selected in find_*_bit Cc: acme@kernel.org, adrian.hunter@intel.com, bp@suse.de, dsahern@gmail.com, jolsa@redhat.com, linux@horizon.com, linux@rasmusvillemoes.dk, mpe@ellerman.id.au, namhyung@kernel.org, wangnan0@huawei.com, yury.norov@gmail.com In-Reply-To: <1465990973-31483-1-git-send-email-maddy@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Madhavan Srinivasan wrote: > +#if (__BYTE_ORDER == __BIG_ENDIAN) && (BITS_PER_LONG != 64) > + tmp = addr[(((nbits - 1)/BITS_PER_LONG) - (start / BITS_PER_LONG))] > + ^ invert; > +#else > tmp = addr[start / BITS_PER_LONG] ^ invert; > +#endif Than you for diagnosing this problem, but I don't think the fix is correct. 1) It's not clear that all users of _find_next_bit and for_each_set_bit() want this change. 2) Is your code even correct? I'd think you'd want addr[x ^ 1]. Are you sure you shpuld be reversing the whole array, and not just the halves of each 64-bit word? 3) You've now broken the case of 32-bit big-endian kernel. I think the proper solution is uglier than this. :-(