From: Jacob Keller <jacob.e.keller@intel.com>
To: David Laight <David.Laight@ACULAB.COM>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: Jiri Pirko <jiri@nvidia.com>, Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next v2 1/9] devlink: use min_t to calculate data_size
Date: Mon, 28 Nov 2022 10:31:04 -0800 [thread overview]
Message-ID: <395aa6d3-c423-266e-28e1-43f8d66dce2a@intel.com> (raw)
In-Reply-To: <d561b49935234451ac062f9f12c50e83@AcuMS.aculab.com>
On 11/24/2022 1:53 PM, David Laight wrote:
> From: Jacob Keller
>> Sent: 23 November 2022 20:38
>>
>> The calculation for the data_size in the devlink_nl_read_snapshot_fill
>> function uses an if statement that is better expressed using the min_t
>> macro.
>
> There ought to be a 'duck shoot' arranged for all uses of min_t().
> I was testing a patch (I might submit next week) that relaxes the
> checks in min() so that it doesn't error a lot of valid cases.
> In particular a positive integer constant can always be cast to (int)
> and the compare will DTRT.
>
> I found things like min_t(u32, u32_length, u64_limit) where
> you really don't want to mask the limit down.
> There are also the min_t(u8, ...) and min_t(u16, ...).
>
Wouldn't that example just want to be min_t(u64, ...)?
>
> ...
>> + data_size = min_t(u32, end_offset - curr_offset,
>> + DEVLINK_REGION_READ_CHUNK_SIZE);
>
> Here I think both xxx_offset are u32 - so the CHUNK_SIZE
> constant probably needs a U suffix.
Right. My understanding was that min_t would cast everything to a u32
when doing such comparison, and we know that
DEVLINK_REGION_READ_CHUNK_SIZE is < U32_MAX so this is ok?
Or am I misunderstanding?
>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>
next prev parent reply other threads:[~2022-11-28 18:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 20:38 [PATCH net-next v2 0/9] support direct read from region Jacob Keller
2022-11-23 20:38 ` [PATCH net-next v2 1/9] devlink: use min_t to calculate data_size Jacob Keller
2022-11-24 8:40 ` Jiri Pirko
2022-11-24 21:53 ` David Laight
2022-11-28 18:31 ` Jacob Keller [this message]
2022-11-29 8:54 ` David Laight
2022-11-23 20:38 ` [PATCH net-next v2 2/9] devlink: report extended error message in region_read_dumpit Jacob Keller
2022-11-24 8:42 ` Jiri Pirko
2022-11-24 8:46 ` Jiri Pirko
2022-11-28 18:16 ` Keller, Jacob E
2022-11-23 20:38 ` [PATCH net-next v2 3/9] devlink: find snapshot in devlink_nl_cmd_region_read_dumpit Jacob Keller
2022-11-24 8:47 ` Jiri Pirko
2022-11-23 20:38 ` [PATCH net-next v2 4/9] devlink: remove unnecessary parameter from chunk_fill function Jacob Keller
2022-11-24 8:49 ` Jiri Pirko
2022-11-23 20:38 ` [PATCH net-next v2 5/9] devlink: refactor region_read_snapshot_fill to use a callback function Jacob Keller
2022-11-24 9:12 ` Jiri Pirko
2022-11-28 18:27 ` Keller, Jacob E
2022-11-28 19:00 ` Jakub Kicinski
2022-11-28 19:22 ` Keller, Jacob E
2022-11-23 20:38 ` [PATCH net-next v2 6/9] devlink: support directly reading from region memory Jacob Keller
2022-11-24 9:05 ` Jiri Pirko
2022-11-28 18:34 ` Jacob Keller
2022-11-23 20:38 ` [PATCH net-next v2 7/9] ice: use same function to snapshot both NVM and Shadow RAM Jacob Keller
2022-11-23 20:38 ` [PATCH net-next v2 8/9] ice: document 'shadow-ram' devlink region Jacob Keller
2022-11-23 20:38 ` [PATCH net-next v2 9/9] ice: implement direct read for NVM and Shadow RAM regions Jacob Keller
2022-11-24 4:17 ` [PATCH net-next v2 0/9] support direct read from region Jakub Kicinski
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=395aa6d3-c423-266e-28e1-43f8d66dce2a@intel.com \
--to=jacob.e.keller@intel.com \
--cc=David.Laight@ACULAB.COM \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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).