From: Bjorn Helgaas <helgaas@kernel•org>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse•de>
Cc: linux-pci@vger•kernel.org,
"Michael Turquette" <mturquette@baylibre•com>,
"J. Bruce Fields" <bfields@fieldses•org>,
linux-nfs@vger•kernel.org, "Edward Cree" <ecree@solarflare•com>,
linux-clk@vger•kernel.org, f.fainelli@gmail•com,
"Herbert Xu" <herbert@gondor•apana.org.au>,
"Emilio López" <emilio@elopez•com.ar>,
maz@kernel•org, "Joerg Roedel" <joro@8bytes•org>,
phil@raspberrypi•org, "Doug Ledford" <dledford@redhat•com>,
"Jason Gunthorpe" <jgg@ziepe•ca>, "Chen-Yu Tsai" <wens@csie•org>,
"Chuck Lever" <chuck.lever@oracle•com>,
"Martin Habets" <mhabets@solarflare•com>,
wahrenst@gmx•net, "Tom Lendacky" <thomas.lendacky@amd•com>,
"Jiri Pirko" <jiri@resnulli•us>,
"Solarflare linux maintainers" <linux-net-drivers@solarflare•com>,
"Maxime Ripard" <mripard@kernel•org>,
linux-rpi-kernel@lists•infradead.org,
"Anna Schumaker" <anna.schumaker@netapp•com>,
"Trond Myklebust" <trond.myklebust@hammerspace•com>,
linux-arm-kernel@lists•infradead.org,
"Mirko Lindner" <mlindner@marvell•com>,
"Mike Marciniszyn" <mike.marciniszyn@intel•com>,
mbrugger@suse•com, "Stephen Boyd" <sboyd@kernel•org>,
netdev@vger•kernel.org, "Yishai Hadas" <yishaih@mellanox•com>,
kexec@lists•infradead.org, linux-kernel@vger•kernel.org,
jeremy.linton@arm•com, "David S. Miller" <davem@davemloft•net>,
"Stephen Hemminger" <stephen@networkplumber•org>,
linux-rdma@vger•kernel.org, iommu@lists•linux-foundation.org,
"Moni Shoua" <monis@mellanox•com>,
"Eric Biederman" <ebiederm@xmission•com>,
james.quinlan@broadcom•com, "Thomas Graf" <tgraf@suug•ch>,
andrew.murray@arm•com, "Robin Murphy" <robin.murphy@arm•con>,
"David Woodhouse" <dwmw2@infradead•org>,
"Dennis Dalessandro" <dennis.dalessandro@intel•com>,
"Lu Baolu" <baolu.lu@linux•intel.com>
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-12-05 22:30 UTC|newest]
Thread overview: 18+ 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 6/8] arm64: defconfig: Enable Broadcom's STB PCIe controller 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
[not found] ` <20191203114743.1294-8-nsaenzjulienne@suse.de>
2019-12-03 16:39 ` [PATCH v4 7/8] linux/log2.h: Fix 64bit calculations in roundup/down_pow_two() Chuck Lever
2019-12-04 10:56 ` Martin Habets
2019-12-05 22:30 ` Bjorn Helgaas [this message]
2019-12-12 13:16 ` 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$(echo .)org \
--cc=andrew.murray@arm$(echo .)com \
--cc=anna.schumaker@netapp$(echo .)com \
--cc=baolu.lu@linux$(echo .)intel.com \
--cc=bfields@fieldses$(echo .)org \
--cc=chuck.lever@oracle$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=dennis.dalessandro@intel$(echo .)com \
--cc=dledford@redhat$(echo .)com \
--cc=dwmw2@infradead$(echo .)org \
--cc=ebiederm@xmission$(echo .)com \
--cc=ecree@solarflare$(echo .)com \
--cc=emilio@elopez$(echo .)com.ar \
--cc=f.fainelli@gmail$(echo .)com \
--cc=herbert@gondor$(echo .)apana.org.au \
--cc=iommu@lists$(echo .)linux-foundation.org \
--cc=james.quinlan@broadcom$(echo .)com \
--cc=jeremy.linton@arm$(echo .)com \
--cc=jgg@ziepe$(echo .)ca \
--cc=jiri@resnulli$(echo .)us \
--cc=joro@8bytes$(echo .)org \
--cc=kexec@lists$(echo .)infradead.org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-clk@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-net-drivers@solarflare$(echo .)com \
--cc=linux-nfs@vger$(echo .)kernel.org \
--cc=linux-pci@vger$(echo .)kernel.org \
--cc=linux-rdma@vger$(echo .)kernel.org \
--cc=linux-rpi-kernel@lists$(echo .)infradead.org \
--cc=maz@kernel$(echo .)org \
--cc=mbrugger@suse$(echo .)com \
--cc=mhabets@solarflare$(echo .)com \
--cc=mike.marciniszyn@intel$(echo .)com \
--cc=mlindner@marvell$(echo .)com \
--cc=monis@mellanox$(echo .)com \
--cc=mripard@kernel$(echo .)org \
--cc=mturquette@baylibre$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nsaenzjulienne@suse$(echo .)de \
--cc=phil@raspberrypi$(echo .)org \
--cc=robin.murphy@arm$(echo .)con \
--cc=sboyd@kernel$(echo .)org \
--cc=stephen@networkplumber$(echo .)org \
--cc=tgraf@suug$(echo .)ch \
--cc=thomas.lendacky@amd$(echo .)com \
--cc=trond.myklebust@hammerspace$(echo .)com \
--cc=wahrenst@gmx$(echo .)net \
--cc=wens@csie$(echo .)org \
--cc=yishaih@mellanox$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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