From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Yury Norov <yury.norov@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Nikolay Aleksandrov <razor@blackwall.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 0/4] netlink: add 'bitmap' attribute type and API
Date: Fri, 22 Jul 2022 16:55:14 +0200 [thread overview]
Message-ID: <20220722145514.767592-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20220721111318.1b180762@kernel.org>
From: Jakub Kicinski <kuba@kernel.org>
Date: Thu, 21 Jul 2022 11:13:18 -0700
> On Thu, 21 Jul 2022 17:59:46 +0200 Alexander Lobakin wrote:
> > BTW, Ethtool bitsets provide similar functionality, but it operates
> > with u32s (u64 is more convenient and optimal on most platforms) and
> > Netlink bitmaps is a generic interface providing policies and data
> > verification (Ethtool bitsets are declared simply as %NLA_BINARY),
> > generic getters/setters etc.
>
> Are you saying we don't need the other two features ethtool bitmaps
> provide? Masking and compact vs named representations?
Nah I didn't say that. I'm not too familiar with Ethtool bitsets,
just know that they're represented as arrays of u32s.
>
> I think that straight up bitmap with a fixed word is awkward and leads
> to too much boilerplate code. People will avoid using it. What about
> implementing a bigint type instead? Needing more than 64b is extremely
> rare, so in 99% of the cases the code outside of parsing can keep using
> its u8/u16/u32.
In-kernel code can still use single unsigned long for some flags if
it wouldn't need more than 64 bits in a couple decades and not
bother with the bitmap API. Same with userspace -- a single 64 is
fine for that API, just pass a pointer to it to send it as a bitmap
to the kernel.
Re 64b vs extremely rare -- I would say so 5 years go, but now more
and more bitfields run out of 64 bits. Link modes, netdev features,
...
Re bigint -- do you mean implementing u128 as a union, like
typedef union __u128 {
struct {
u32 b127_96;
u32 b95_64;
u32 b63_32;
u32 b31_0;
};
struct {
u64 b127_64;
u64 b63_0;
};
#ifdef __HAVE_INT128
__int128 b127_0;
#endif
} u128;
? We have similar feature in one of our internal trees and planning
to present generic u128 soon, but this doesn't work well for flags
I think.
bitmap API and bitops are widely used and familiar to tons of folks,
most platforms define their own machine-optimized bitops
implementation, arrays of unsigned longs are native...
Re awkward -- all u64 <-> bitmap conversion is implemented in the
core code in 4/4 and users won't need doing anything besides one
get/set. And still use bitmap/bitops API. Userspace, as I said,
can use a single __u64 as long as it fits into 64 bits.
Summarizing, I feel like bigints would lead to much more boilerplate
in both kernel and user spaces and need to implement a whole new API
instead of using the already existing and well-used bitmap one.
Continuation of using single objects with fixed size like %NLA_U* or
%NLA_BITFIELD_U32 will lead to introducing a new Netlink attr every
32/64 bits (or even 16 like with IP tunnels, that was the initial
reason why I started working on those 3 series). As Jake wrote me
in PM earlier,
"I like the concept of an NLA_BITMAP. I could have used this for
some of the devlink interfaces we've done, and it definitely feels
a bit more natural than being forced to a single u32 bitfield."
Thanks,
Olek
next prev parent reply other threads:[~2022-07-22 14:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 15:59 Alexander Lobakin
2022-07-21 15:59 ` [PATCH net-next 1/4] bitmap: add converting from/to 64-bit arrays of explicit byteorder Alexander Lobakin
2022-07-21 15:59 ` [PATCH net-next 2/4] bitmap: add a couple more helpers to work with arrays of u64s Alexander Lobakin
2022-07-21 15:59 ` [PATCH net-next 3/4] lib/test_bitmap: cover explicitly byteordered arr64s Alexander Lobakin
2022-07-21 15:59 ` [PATCH net-next 4/4] netlink: add 'bitmap' attribute type (%NL_ATTR_TYPE_BITMAP / %NLA_BITMAP) Alexander Lobakin
2022-07-21 18:13 ` [PATCH net-next 0/4] netlink: add 'bitmap' attribute type and API Jakub Kicinski
2022-07-22 14:55 ` Alexander Lobakin [this message]
2022-07-22 18:19 ` Jakub Kicinski
2022-07-23 15:52 ` Jakub Kicinski
2022-07-25 13:02 ` Alexander Lobakin
2022-07-25 18:53 ` Jakub Kicinski
2022-07-26 10:41 ` Alexander Lobakin
[not found] ` <CAHp75Ve7oXjNyc0GD5x9ZW=DVgCqmLOBfCP4O2cDi2DG=4SiwQ@mail.gmail.com>
2022-07-25 10:24 ` Alexander Lobakin
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=20220722145514.767592-1-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=yury.norov@gmail.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
all inboxes | Powered by JetHome®