Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1386538ybs; Mon, 25 May 2020 14:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2yuGayicxreKVH85zL1Aysg3vftayfwFdhsSysgFZ8/ThhwOXQPB+okboMMQMbfct/9GM X-Received: by 2002:a50:f391:: with SMTP id g17mr17987381edm.102.1590443714634; Mon, 25 May 2020 14:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590443714; cv=none; d=google.com; s=arc-20160816; b=xabDZYlKGtEh48zOm58xpafSbx+TxAkHnla0E0a0nacrjxojDXl66qk+JCHXrNS9m3 Cqr0fZvq/ewTuJxPX7XbMJ5rLEb/hMXOzu8P4C6n6Q6XyCQXzkz/6YEjJo3I+fnvYATo aGHUJF0j5HD+TRK/t+JCuRBKz/4aa25FSdwLLCtK3ya+SF/NBqg1xOC7c3Jj0pvdWaXX qEjjX1qVkCR7I1y018SqUZPqANYop8g/zAsVxDMEcAI+O5EQvsZZmIEbRHExKt/RFF4s bpd3gLlXrE71CszAb2iGF5AWcvIm3EFU15WxjCEddRteDMsggW/Un6RuoTDX8Aln4nQX qbCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=UBezJVkwIZGVpvPRCI9Waij1Jz5xzyQo+Ip6QqUmcAE=; b=ODk36j16VGYzq7IY/WC3zHT44h4JddjiirOMxlwKvXY8v8TEBs4WnQrGlRcph+5htZ /qx0Tt24qVWCy74ODHGKu9+VsFPPsFtqOCovFhocjvkd9IEQswt0UEJN4FQIQIJqBSnh j/cew6otTApJYy9Wr3E83FqKl6QN+k0LWHxYko6m6IRMGErjFNs3ZJSQJVY4/1nhOUks OWXk+vNp5k35t17Vk8lNeNjlYZVXNoXV5dUpo/1F8pk89UM21Fzvo4EplF1kHsts3z6k F+vn1vhQXofTtnrp9FJ4S8dsSZacx3rtOa19cqqDqiFhixra9PwOF+NjtpfgR+VVZk7r d3Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWrweGaV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si9537534edm.541.2020.05.25.14.54.51; Mon, 25 May 2020 14:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWrweGaV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390511AbgEYUlM (ORCPT + 99 others); Mon, 25 May 2020 16:41:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390493AbgEYUlM (ORCPT ); Mon, 25 May 2020 16:41:12 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AAA8920776; Mon, 25 May 2020 20:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590439270; bh=aeOe7fH/jd/H55PWevqur5gg9YXpxI/MI38Ji58NKFY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dWrweGaVmnKRDpQMrhm4JSVd88fwgaUoGxIOXfzM2izV+3xlisPmfpAFmt4tO1mnY ERok3+ImeXmMDUezzXnfUi8uajnZDmb3EOz2Q2EAjDatbZjF2CbAsZss948dg3XbBm kmwojQe0fCnOlHRUvcwfMis2E+415Ab70pNJZ1j4= Date: Mon, 25 May 2020 13:41:10 -0700 From: Andrew Morton To: Andy Shevchenko Cc: Wei Yang , Jesse Brandeburg , christian.brauner@ubuntu.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bitops: simplify get_count_order_long() Message-Id: <20200525134110.5737dd603d5fa1230e2f7ece@linux-foundation.org> In-Reply-To: <20200525153216.GD1634618@smile.fi.intel.com> References: <20200524123551.9469-1-richard.weiyang@gmail.com> <20200525091458.GK1634618@smile.fi.intel.com> <20200525144312.mbw2z3ydncyasvss@master> <20200525153216.GD1634618@smile.fi.intel.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 25 May 2020 18:32:16 +0300 Andy Shevchenko wrote: > On Mon, May 25, 2020 at 02:43:12PM +0000, Wei Yang wrote: > > On Mon, May 25, 2020 at 12:14:58PM +0300, Andy Shevchenko wrote: > > >On Sun, May 24, 2020 at 12:35:51PM +0000, Wei Yang wrote: > > >> These two cases could be unified into one. > > > > > >Care to provide a test case which supports your change? I hurt my brain convincing myself, so I got practical: int fls(unsigned int x) { return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; } static int get_count_order(unsigned l) { if (l == 0) return -1; else if (l & (l - 1UL)) return fls(l); else return fls(l) - 1; } static int get_count_order2(unsigned long l) { if (l == 0) return -1; return fls(--l); } main() { unsigned i; for (i = 1; i < 64; i++) { printf("%d %d\n", get_count_order(i), get_count_order2(i)); } } > > > > Hmm.. where should I put the test? tools/testing/selftests/ ? > > I guess into test_bitops.c [1]? I though it eventually should make kernel, but I don't see it. > > Andrew, can you apply that or do you need Jesse to resend? > Got it.