From: Bjorn Helgaas <helgaas@kernel.org>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: andrew.murray@arm.com, maz@kernel.org,
linux-kernel@vger.kernel.org,
"Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Emilio López" <emilio@elopez.com.ar>,
"Maxime Ripard" <mripard@kernel.org>,
"Chen-Yu Tsai" <wens@csie.org>,
"Mike Marciniszyn" <mike.marciniszyn@intel.com>,
"Dennis Dalessandro" <dennis.dalessandro@intel.com>,
"Yishai Hadas" <yishaih@mellanox.com>,
"Moni Shoua" <monis@mellanox.com>,
"David Woodhouse" <dwmw2@infradead.org>,
"Lu Baolu" <baolu.lu@linux.intel.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Tom Lendacky" <thomas.lendacky@amd.com>,
"Mirko Lindner" <mlindner@marvell.com>,
"Stephen Hemminger" <stephen@networkplumber.org>,
"Jiri Pirko" <jiri@resnulli.us>,
"Solarflare linux maintainers" <linux-net-drivers@solarflare.com>,
"Edward Cree" <ecree@solarflare.com>,
"Martin Habets" <mhabets@solarflare.com>,
"Eric Biederman" <ebiederm@xmission.com>,
"Thomas Graf" <tgraf@suug.ch>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
james.quinlan@broadcom.com, mbrugger@suse.com,
f.fainelli@gmail.com, phil@raspberrypi.org, wahrenst@gmx.net,
jeremy.linton@arm.com, linux-pci@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org,
"Robin Murphy" <robin.murphy@arm.con>,
"Doug Ledford" <dledford@redhat.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"David S. Miller" <davem@davemloft.net>,
"Trond Myklebust" <trond.myklebust@hammerspace.com>,
"Anna Schumaker" <anna.schumaker@netapp.com>,
"J. Bruce Fields" <bfields@fieldses.org>,
"Chuck Lever" <chuck.lever@oracle.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rdma@vger.kernel.org, iommu@lists.linux-foundation.org,
netdev@vger.kernel.org, kexec@lists.infradead.org,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH v4 7/8] linux/log2.h: Fix 64bit calculations in roundup/down_pow_two()
Date: Thu, 5 Dec 2019 16:30:44 -0600 [thread overview]
Message-ID: <20191205223044.GA250573@google.com> (raw)
In-Reply-To: <20191203114743.1294-8-nsaenzjulienne@suse.de>
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
next prev parent reply other threads:[~2019-12-05 22:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 11:47 [PATCH v4 0/8] Raspberry Pi 4 PCIe support Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 1/8] dt-bindings: PCI: Add bindings for brcmstb's PCIe device Nicolas Saenz Julienne
2019-12-03 15:03 ` Andrew Murray
2019-12-03 11:47 ` [PATCH v4 2/8] ARM: dts: bcm2711: Enable PCIe controller Nicolas Saenz Julienne
2019-12-16 6:46 ` Jian-Hong Pan
2019-12-16 9:49 ` Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 3/8] PCI: brcmstb: Add Broadcom STB PCIe host controller driver Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 4/8] PCI: brcmstb: Add MSI support Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 5/8] MAINTAINERS: Add brcmstb PCIe controller Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 6/8] arm64: defconfig: Enable Broadcom's STB " Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 7/8] linux/log2.h: Fix 64bit calculations in roundup/down_pow_two() Nicolas Saenz Julienne
2019-12-03 16:39 ` Chuck Lever
2019-12-04 10:56 ` Martin Habets
2019-12-04 14:17 ` Leon Romanovsky
2019-12-05 0:39 ` Lu Baolu
2019-12-05 17:48 ` Robin Murphy
2019-12-12 12:31 ` Nicolas Saenz Julienne
2019-12-05 22:30 ` Bjorn Helgaas [this message]
2019-12-12 13:16 ` Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 8/8] linux/log2.h: Use roundup/dow_pow_two() on 64bit calculations Nicolas Saenz Julienne
2019-12-03 15:53 ` Rob Herring
2019-12-03 16:06 ` Nicolas Saenz Julienne
2019-12-05 20:38 ` Bjorn Helgaas
2019-12-12 13:21 ` Nicolas Saenz Julienne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191205223044.GA250573@google.com \
--to=helgaas@kernel.org \
--cc=andrew.murray@arm.com \
--cc=anna.schumaker@netapp.com \
--cc=baolu.lu@linux.intel.com \
--cc=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=dennis.dalessandro@intel.com \
--cc=dledford@redhat.com \
--cc=dwmw2@infradead.org \
--cc=ebiederm@xmission.com \
--cc=ecree@solarflare.com \
--cc=emilio@elopez.com.ar \
--cc=f.fainelli@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=iommu@lists.linux-foundation.org \
--cc=james.quinlan@broadcom.com \
--cc=jeremy.linton@arm.com \
--cc=jgg@ziepe.ca \
--cc=jiri@resnulli.us \
--cc=joro@8bytes.org \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net-drivers@solarflare.com \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=mbrugger@suse.com \
--cc=mhabets@solarflare.com \
--cc=mike.marciniszyn@intel.com \
--cc=mlindner@marvell.com \
--cc=monis@mellanox.com \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=netdev@vger.kernel.org \
--cc=nsaenzjulienne@suse.de \
--cc=phil@raspberrypi.org \
--cc=robin.murphy@arm.con \
--cc=sboyd@kernel.org \
--cc=stephen@networkplumber.org \
--cc=tgraf@suug.ch \
--cc=thomas.lendacky@amd.com \
--cc=trond.myklebust@hammerspace.com \
--cc=wahrenst@gmx.net \
--cc=wens@csie.org \
--cc=yishaih@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).