From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,FAKE_REPLY_C,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB145C2D0C1 for ; Thu, 5 Dec 2019 22:30:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD81822525 for ; Thu, 5 Dec 2019 22:30:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PjazjCP3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="cliOZcUx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD81822525 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=1pC2AnGLp0MTykW2eBGpEyb/dRUgeKzws9xCb9w+e1Y=; b=PjazjCP37U9iQt //v1LhZBhcRByRWdY6DjnSmorkO8NnC2AD6WaLApVo5AR7CEFZyMM5tpLJPzpzdc27nNlBhq6jGGf /8m33BGyXrI5w4EZTs/VFM7c3nWNR9XkmciKfyCsmgtjSz7/2FQlfNtdQe9VqspAbax+HSSmG1nrt RXJnFPZy6hp84upfHS+a5MwIGMXh1B1E7q+pLFyXi9xc/upPzWFa8O6ZmFpksYIfjFH/xd3FNoEyW xLgFRjlbvRupGgmGe5t/F4yHhS9ef0pSgMXNK7lhzdbG4539rB0+JdAgBfd+HauA7PmMXlNCB7hN4 f5C86t4BW2kSYAgBrr6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iczeC-0007gf-2e; Thu, 05 Dec 2019 22:30:56 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1icze4-0007Z9-TL; Thu, 05 Dec 2019 22:30:50 +0000 Received: from localhost (mobile-166-170-221-197.mycingular.net [166.170.221.197]) (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 84F6520707; Thu, 5 Dec 2019 22:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575585047; bh=rwc2W/J/V58JZoKOWg2doRruK6KWPbQgM5Sb2F/Ai60=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=cliOZcUxDWzGZ1UQTKJkPsD++s/EPrjyE7H/snJuA3uqE7NURH520sOnVje6nd0Ts Td38CmfeZyMBlRyr+Rypsepv/EG8hoAOa7B7sJiJzOVgMDkiBquX3yxdZnHzKOkS/c BBv+wew7DxEj2QDNBsIebdp/nYnu0CS5l8OPwMaM= Date: Thu, 5 Dec 2019 16:30:44 -0600 From: Bjorn Helgaas To: Nicolas Saenz Julienne Subject: Re: [PATCH v4 7/8] linux/log2.h: Fix 64bit calculations in roundup/down_pow_two() Message-ID: <20191205223044.GA250573@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191203114743.1294-8-nsaenzjulienne@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191205_143049_068772_69E30AAE X-CRM114-Status: GOOD ( 10.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, Michael Turquette , "J. Bruce Fields" , linux-nfs@vger.kernel.org, Edward Cree , linux-clk@vger.kernel.org, f.fainelli@gmail.com, Herbert Xu , Emilio =?iso-8859-1?Q?L=F3pez?= , maz@kernel.org, Joerg Roedel , phil@raspberrypi.org, Doug Ledford , Jason Gunthorpe , Chen-Yu Tsai , Chuck Lever , Martin Habets , wahrenst@gmx.net, Tom Lendacky , Jiri Pirko , Solarflare linux maintainers , Maxime Ripard , linux-rpi-kernel@lists.infradead.org, Anna Schumaker , Trond Myklebust , linux-arm-kernel@lists.infradead.org, Mirko Lindner , Mike Marciniszyn , mbrugger@suse.com, Stephen Boyd , netdev@vger.kernel.org, Yishai Hadas , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com, "David S. Miller" , Stephen Hemminger , linux-rdma@vger.kernel.org, iommu@lists.linux-foundation.org, Moni Shoua , Eric Biederman , james.quinlan@broadcom.com, Thomas Graf , andrew.murray@arm.com, Robin Murphy , David Woodhouse , Dennis Dalessandro , Lu Baolu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org You got the "n" on "down" in the subject, but still missing "of" ;) On Tue, Dec 03, 2019 at 12:47:40PM +0100, Nicolas Saenz Julienne wrote: > Some users need to make sure their rounding function accepts and returns > 64bit long variables regardless of the architecture. Sadly > roundup/rounddown_pow_two() takes and returns unsigned longs. It turns > out ilog2() already handles 32/64bit calculations properly, and being > the building block to the round functions we can rework them as a > wrapper around it. Missing "of" in the function names here. s/a wrapper/wrappers/ IIUC the point of this is that roundup_pow_of_two() returned "unsigned long", which can be either 32 or 64 bits (worth pointing out, I think), and many callers need something that returns "unsigned long long" (always 64 bits). It's a nice simplification to remove the "__" variants. Just as a casual reader of this commit message, I'd like to know why we had both the roundup and the __roundup versions in the first place, and why we no longer need both. > -#define roundup_pow_of_two(n) \ > -( \ > - __builtin_constant_p(n) ? ( \ > - (n == 1) ? 1 : \ > - (1UL << (ilog2((n) - 1) + 1)) \ > - ) : \ > - __roundup_pow_of_two(n) \ > - ) > +#define roundup_pow_of_two(n) \ > +( \ > + (__builtin_constant_p(n) && ((n) == 1)) ? \ > + 1 : (1ULL << (ilog2((n) - 1) + 1)) \ > +) Should the resulting type of this expression always be a ULL, even when n==1, i.e., should it be this? 1ULL : (1ULL << (ilog2((n) - 1) + 1)) \ Or maybe there's no case where that makes a difference? Bjorn _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel