linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: dsterba@suse.cz, Kent Overstreet <kent.overstreet@linux.dev>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-bcachefs@vger.kernel.org
Subject: Re: [GIT PULL] bcachefs
Date: Wed, 6 Sep 2023 20:53:31 -0300	[thread overview]
Message-ID: <ZPkQ+whuhTT6JtKN@kernel.org> (raw)
In-Reply-To: <ZPkPRpe4T9RgM/CV@kernel.org>

Em Wed, Sep 06, 2023 at 08:46:14PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Sep 06, 2023 at 04:34:32PM -0700, Linus Torvalds escreveu:
> > On Wed, 6 Sept 2023 at 16:20, David Sterba <dsterba@suse.cz> wrote:
> > >     I think I've always seen an int for enums, unless it was
> > > explicitly narrowed in the structure (:8) or by __packed attribute in
> > > the enum definition.
 
> > 'int' is definitely the default (and traditional) behavior.
  
> > But exactly because enums can act very differently depending on
> > compiler options (and some of those may have different defaults on
> > different architectures), we should never ever have a bare 'enum' as
> > part of a structure in any UAPI.
  
> > In fact, having an enum as a bitfield is much better for that case.
  
> > Doing a quick grep shows that sadly people haven't realized that.
  
> > Now: using -fshort-enum can break a _lot_ of libraries exactly for
> > this kind of reason, so the kernel isn't unusual, and I don't know of
> > anybody who actually uses -fshort-enum. I'm mentioning -fshort-enum
> > not because it's likely to be used, but mainly because it's an easy
> > way to show some issues.
  
> > You can get very similar issues by just having unusual enum values.  Doing
 
> >    enum mynum { val = 0x80000000 };
  
> > does something special too.
  
> > I leave it to the reader to figure out, but as a hint it's basically
> > exactly the same issue as I was trying to show with my crazy
> > -fshort-enum example.
> 
> Two extra hints:
 
> ⬢[acme@toolbox perf-tools-next]$ grep KIND_ENUM64 include/uapi/linux/btf.h
> 	BTF_KIND_ENUM64		= 19,	/* Enumeration up to 64-bit values */
> /* BTF_KIND_ENUM64 is followed by multiple "struct btf_enum64".
> ⬢[acme@toolbox perf-tools-next]$
 
> ⬢[acme@toolbox perf-tools-next]$ pahole --help |& grep enum
>       --skip_encoding_btf_enum64   Do not encode ENUM64s in BTF.
> ⬢[acme@toolbox perf-tools-next]$
 
> :-)

Some examples:

[root@five perf-tools-next]# bpftool btf dump file /sys/kernel/btf/vmlinux  | grep -w ENUM64
[2954] ENUM64 '(anon)' encoding=SIGNED size=8 vlen=28
[6519] ENUM64 'blake2b_iv' encoding=UNSIGNED size=8 vlen=8
[12990] ENUM64 '(anon)' encoding=UNSIGNED size=8 vlen=3
[16283] ENUM64 'netdev_priv_flags' encoding=UNSIGNED size=8 vlen=33
[21717] ENUM64 '(anon)' encoding=UNSIGNED size=8 vlen=11
[28247] ENUM64 'ib_uverbs_device_cap_flags' encoding=UNSIGNED size=8 vlen=28
[34836] ENUM64 'perf_callchain_context' encoding=UNSIGNED size=8 vlen=7
[48851] ENUM64 '(anon)' encoding=UNSIGNED size=8 vlen=9
[54703] ENUM64 'hmm_pfn_flags' encoding=UNSIGNED size=8 vlen=7
[root@five perf-tools-next]# pahole netdev_priv_flags
enum netdev_priv_flags {
	IFF_802_1Q_VLAN           = 1,
	IFF_EBRIDGE               = 2,
	IFF_BONDING               = 4,
	IFF_ISATAP                = 8,
	IFF_WAN_HDLC              = 16,
	IFF_XMIT_DST_RELEASE      = 32,
	IFF_DONT_BRIDGE           = 64,
	IFF_DISABLE_NETPOLL       = 128,
	IFF_MACVLAN_PORT          = 256,
	IFF_BRIDGE_PORT           = 512,
	IFF_OVS_DATAPATH          = 1024,
	IFF_TX_SKB_SHARING        = 2048,
	IFF_UNICAST_FLT           = 4096,
	IFF_TEAM_PORT             = 8192,
	IFF_SUPP_NOFCS            = 16384,
	IFF_LIVE_ADDR_CHANGE      = 32768,
	IFF_MACVLAN               = 65536,
	IFF_XMIT_DST_RELEASE_PERM = 131072,
	IFF_L3MDEV_MASTER         = 262144,
	IFF_NO_QUEUE              = 524288,
	IFF_OPENVSWITCH           = 1048576,
	IFF_L3MDEV_SLAVE          = 2097152,
	IFF_TEAM                  = 4194304,
	IFF_RXFH_CONFIGURED       = 8388608,
	IFF_PHONY_HEADROOM        = 16777216,
	IFF_MACSEC                = 33554432,
	IFF_NO_RX_HANDLER         = 67108864,
	IFF_FAILOVER              = 134217728,
	IFF_FAILOVER_SLAVE        = 268435456,
	IFF_L3MDEV_RX_HANDLER     = 536870912,
	IFF_NO_ADDRCONF           = 1073741824,
	IFF_TX_SKB_NO_LINEAR      = 2147483648,
	IFF_CHANGE_PROTO_DOWN     = 4294967296,
}

[root@five perf-tools-next]# pahole --hex ib_uverbs_device_cap_flags
enum ib_uverbs_device_cap_flags {
	IB_UVERBS_DEVICE_RESIZE_MAX_WR         = 0x1,
	IB_UVERBS_DEVICE_BAD_PKEY_CNTR         = 0x2,
	IB_UVERBS_DEVICE_BAD_QKEY_CNTR         = 0x4,
	IB_UVERBS_DEVICE_RAW_MULTI             = 0x8,
	IB_UVERBS_DEVICE_AUTO_PATH_MIG         = 0x10,
	IB_UVERBS_DEVICE_CHANGE_PHY_PORT       = 0x20,
	IB_UVERBS_DEVICE_UD_AV_PORT_ENFORCE    = 0x40,
	IB_UVERBS_DEVICE_CURR_QP_STATE_MOD     = 0x80,
	IB_UVERBS_DEVICE_SHUTDOWN_PORT         = 0x100,
	IB_UVERBS_DEVICE_PORT_ACTIVE_EVENT     = 0x400,
	IB_UVERBS_DEVICE_SYS_IMAGE_GUID        = 0x800,
	IB_UVERBS_DEVICE_RC_RNR_NAK_GEN        = 0x1000,
	IB_UVERBS_DEVICE_SRQ_RESIZE            = 0x2000,
	IB_UVERBS_DEVICE_N_NOTIFY_CQ           = 0x4000,
	IB_UVERBS_DEVICE_MEM_WINDOW            = 0x20000,
	IB_UVERBS_DEVICE_UD_IP_CSUM            = 0x40000,
	IB_UVERBS_DEVICE_XRC                   = 0x100000,
	IB_UVERBS_DEVICE_MEM_MGT_EXTENSIONS    = 0x200000,
	IB_UVERBS_DEVICE_MEM_WINDOW_TYPE_2A    = 0x800000,
	IB_UVERBS_DEVICE_MEM_WINDOW_TYPE_2B    = 0x1000000,
	IB_UVERBS_DEVICE_RC_IP_CSUM            = 0x2000000,
	IB_UVERBS_DEVICE_RAW_IP_CSUM           = 0x4000000,
	IB_UVERBS_DEVICE_MANAGED_FLOW_STEERING = 0x20000000,
	IB_UVERBS_DEVICE_RAW_SCATTER_FCS       = 0x400000000,
	IB_UVERBS_DEVICE_PCI_WRITE_END_PADDING = 0x1000000000,
	IB_UVERBS_DEVICE_FLUSH_GLOBAL          = 0x4000000000,
	IB_UVERBS_DEVICE_FLUSH_PERSISTENT      = 0x8000000000,
	IB_UVERBS_DEVICE_ATOMIC_WRITE          = 0x10000000000,
}

[root@five perf-tools-next]#

  reply	other threads:[~2023-09-06 23:53 UTC|newest]

Thread overview: 141+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-03  3:25 [GIT PULL] bcachefs Kent Overstreet
2023-09-05 13:24 ` Christoph Hellwig
2023-09-06  0:00   ` Kent Overstreet
2023-09-06  0:41     ` Matthew Wilcox
2023-09-06 16:10       ` Kent Overstreet
2023-09-06 17:57         ` Darrick J. Wong
2023-09-08  9:37     ` Christoph Hellwig
2023-09-06 19:36 ` Linus Torvalds
2023-09-06 20:02   ` Linus Torvalds
2023-09-06 20:20     ` Linus Torvalds
2023-09-06 21:55       ` Arnaldo Carvalho de Melo
2023-09-06 23:13         ` David Sterba
2023-09-06 23:34           ` Linus Torvalds
2023-09-06 23:46             ` Arnaldo Carvalho de Melo
2023-09-06 23:53               ` Arnaldo Carvalho de Melo [this message]
2023-09-06 23:16         ` Linus Torvalds
2023-09-10  0:53       ` Kent Overstreet
2023-09-07 20:37   ` Kent Overstreet
2023-09-07 20:51     ` Linus Torvalds
2023-09-07 23:40   ` Kent Overstreet
2023-09-08  6:29     ` Martin Steigerwald
2023-09-08  9:11     ` Joshua Ashton
2023-09-06 22:28 ` Nathan Chancellor
2023-09-07  0:03   ` Kees Cook
2023-09-07 14:29     ` Chris Mason
2023-09-07 20:39     ` Kent Overstreet
2023-09-08 10:50       ` Brian Foster
2023-09-08 23:05     ` Dave Chinner
2023-09-08 10:59 ` Thank you! (was: Re: [GIT PULL] bcachefs) Martin Steigerwald
  -- strict thread matches above, loose matches on Subject: below --
2023-06-26 21:46 [GIT PULL] bcachefs Kent Overstreet
2023-06-26 23:11 ` Jens Axboe
2023-06-27  0:06   ` Kent Overstreet
2023-06-27  1:13     ` Jens Axboe
2023-06-27  2:05       ` Kent Overstreet
2023-06-27  2:59         ` Jens Axboe
2023-06-27  3:10           ` Kent Overstreet
2023-06-27 17:16           ` Jens Axboe
2023-06-27 20:15             ` Kent Overstreet
2023-06-27 22:05               ` Dave Chinner
2023-06-27 22:41                 ` Kent Overstreet
2023-06-28 14:40                 ` Jens Axboe
2023-06-28 14:48                   ` Thomas Weißschuh
2023-06-28 14:58                     ` Jens Axboe
2023-06-28  3:16               ` Jens Axboe
2023-06-28  4:01                 ` Kent Overstreet
2023-06-28 14:58                   ` Jens Axboe
2023-06-28 15:22                     ` Jens Axboe
2023-06-28 17:56                       ` Kent Overstreet
2023-06-28 20:45                         ` Jens Axboe
2023-06-28 16:57                     ` Jens Axboe
2023-06-28 17:33                       ` Christian Brauner
2023-06-28 17:52                       ` Kent Overstreet
2023-06-28 20:44                         ` Jens Axboe
2023-06-28 21:17                           ` Jens Axboe
2023-06-28 22:13                             ` Kent Overstreet
2023-06-28 22:33                               ` Jens Axboe
2023-06-28 22:55                                 ` Kent Overstreet
2023-06-28 23:14                                   ` Jens Axboe
2023-06-28 23:50                                     ` Kent Overstreet
2023-06-29  1:00                                       ` Dave Chinner
2023-06-29  1:33                                         ` Jens Axboe
2023-06-29 11:18                                           ` Christian Brauner
2023-06-29 14:17                                             ` Kent Overstreet
2023-06-29 15:31                                             ` Kent Overstreet
2023-06-30  9:40                                               ` Christian Brauner
2023-07-06 15:20                                                 ` Kent Overstreet
2023-07-06 16:26                                                   ` Jens Axboe
2023-07-06 16:34                                                     ` Kent Overstreet
2023-06-29  1:29                                       ` Jens Axboe
2023-07-06 20:15                             ` Kent Overstreet
2023-06-28 17:54                     ` Kent Overstreet
2023-06-28 20:54                       ` Jens Axboe
2023-06-28 22:14                         ` Jens Axboe
2023-06-28 23:04                           ` Kent Overstreet
2023-06-28 23:11                             ` Jens Axboe
2023-06-27  2:33       ` Kent Overstreet
2023-06-27  2:59         ` Jens Axboe
2023-06-27  3:19           ` Matthew Wilcox
2023-06-27  3:22             ` Kent Overstreet
2023-06-27  3:52 ` Christoph Hellwig
2023-06-27  4:36   ` Kent Overstreet
2023-07-06 15:56 ` Kent Overstreet
2023-07-06 16:40   ` Josef Bacik
2023-07-06 17:38     ` Kent Overstreet
2023-07-06 19:17       ` Eric Sandeen
2023-07-06 19:31         ` Kent Overstreet
2023-07-06 21:19       ` Darrick J. Wong
2023-07-06 22:43         ` Kent Overstreet
2023-07-07 13:13           ` Jan Kara
2023-07-07 13:52             ` Kent Overstreet
2023-07-07  8:48         ` Christian Brauner
2023-07-07  9:18           ` Kent Overstreet
2023-07-07 16:26             ` James Bottomley
2023-07-07 16:48               ` Kent Overstreet
2023-07-07 17:04                 ` James Bottomley
2023-07-07 17:26                   ` Kent Overstreet
2023-07-08  3:54               ` Matthew Wilcox
2023-07-08  4:10                 ` Kent Overstreet
2023-07-08  4:31                 ` Kent Overstreet
2023-07-08 15:02                   ` Theodore Ts'o
2023-07-08 15:23                     ` Kent Overstreet
2023-07-08 16:42                 ` James Bottomley
2023-07-09  1:16                   ` Kent Overstreet
2023-07-07  9:35           ` Kent Overstreet
2023-07-07  2:04       ` Theodore Ts'o
2023-07-07 12:18       ` Brian Foster
2023-07-07 14:49         ` Kent Overstreet
2023-07-12  2:54   ` Kent Overstreet
2023-07-12 19:48     ` Kees Cook
2023-07-12 19:57       ` Kent Overstreet
2023-07-12 22:10     ` Darrick J. Wong
2023-07-12 23:57       ` Kent Overstreet
2023-08-09  1:27     ` Linus Torvalds
2023-08-10 15:54       ` Kent Overstreet
2023-08-10 16:40         ` Linus Torvalds
2023-08-10 18:02           ` Kent Overstreet
2023-08-10 18:09             ` Linus Torvalds
2023-08-10 17:52         ` Jan Kara
2023-08-11  2:47           ` Kent Overstreet
2023-08-11  8:10             ` Jan Kara
2023-08-11  8:13               ` Christian Brauner
2023-08-10 22:39         ` Darrick J. Wong
2023-08-10 23:47           ` Linus Torvalds
2023-08-11  2:40             ` Jens Axboe
2023-08-11  4:03             ` Kent Overstreet
2023-08-11  5:20               ` Linus Torvalds
2023-08-11  5:29                 ` Kent Overstreet
2023-08-11  5:53                   ` Linus Torvalds
2023-08-11  7:52                     ` Christian Brauner
2023-08-11 14:31                     ` Jens Axboe
2023-08-11  3:45           ` Kent Overstreet
2023-08-21  0:09             ` Dave Chinner
2023-08-10 23:07         ` Matthew Wilcox
2023-08-11 10:54         ` Christian Brauner
2023-08-11 12:58           ` Kent Overstreet
2023-08-14  7:25             ` Christian Brauner
2023-08-14 15:23               ` Kent Overstreet
2023-08-11 13:21           ` Kent Overstreet
2023-08-11 22:56             ` Darrick J. Wong
2023-08-14  7:21             ` Christian Brauner
2023-08-14 15:27               ` Kent Overstreet

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=ZPkQ+whuhTT6JtKN@kernel.org \
    --to=acme@kernel.org \
    --cc=dsterba@suse.cz \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).