[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191205223044.GA250573@google.com>
Date: Thu, 5 Dec 2019 16:30:44 -0600
From: Bjorn Helgaas <helgaas@...nel.org>
To: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
Cc: andrew.murray@....com, maz@...nel.org,
linux-kernel@...r.kernel.org,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Emilio López <emilio@...pez.com.ar>,
Maxime Ripard <mripard@...nel.org>,
Chen-Yu Tsai <wens@...e.org>,
Mike Marciniszyn <mike.marciniszyn@...el.com>,
Dennis Dalessandro <dennis.dalessandro@...el.com>,
Yishai Hadas <yishaih@...lanox.com>,
Moni Shoua <monis@...lanox.com>,
David Woodhouse <dwmw2@...radead.org>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>,
Tom Lendacky <thomas.lendacky@....com>,
Mirko Lindner <mlindner@...vell.com>,
Stephen Hemminger <stephen@...workplumber.org>,
Jiri Pirko <jiri@...nulli.us>,
Solarflare linux maintainers <linux-net-drivers@...arflare.com>,
Edward Cree <ecree@...arflare.com>,
Martin Habets <mhabets@...arflare.com>,
Eric Biederman <ebiederm@...ssion.com>,
Thomas Graf <tgraf@...g.ch>,
Herbert Xu <herbert@...dor.apana.org.au>,
james.quinlan@...adcom.com, mbrugger@...e.com,
f.fainelli@...il.com, phil@...pberrypi.org, wahrenst@....net,
jeremy.linton@....com, linux-pci@...r.kernel.org,
linux-rpi-kernel@...ts.infradead.org,
Robin Murphy <robin.murphy@....con>,
Doug Ledford <dledford@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>,
"David S. Miller" <davem@...emloft.net>,
Trond Myklebust <trond.myklebust@...merspace.com>,
Anna Schumaker <anna.schumaker@...app.com>,
"J. Bruce Fields" <bfields@...ldses.org>,
Chuck Lever <chuck.lever@...cle.com>,
linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rdma@...r.kernel.org, iommu@...ts.linux-foundation.org,
netdev@...r.kernel.org, kexec@...ts.infradead.org,
linux-nfs@...r.kernel.org
Subject: Re: [PATCH v4 7/8] linux/log2.h: Fix 64bit calculations in
roundup/down_pow_two()
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
Powered by blists - more mailing lists