Re: [RFC][PATCH] bitfields API

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Pekka J Enberg <penberg@...>, Alexey Dobriyan <adobriyan@...>
Cc: David Miller <davem@...>, Ingo Molnar <mingo@...>, Andrew Morton <akpm@...>, <linux-kernel@...>
Date: Saturday, August 30, 2008 - 4:28 am

On Thu, Aug 28, 2008 at 9:38 PM, Vegard Nossum wrote:

Hm, and this is exactly the case for the "do_not_encrypt" field of skbuff:

#ifdef CONFIG_IPV6_NDISC_NODETYPE
__u8 ndisc_nodetype:2;
#endif
#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
__u8 do_not_encrypt:1;
#endif

So we have no way to know where or how big the filler should be. This is
why the simple patch above is not sufficient.

Alexey: I have a modified proposal with slightly different syntax for
DEFINE_BITFIELD. Can you say whether this is acceptable or not? Please
see this short mockup example:

<--- cut --->

#include
#include

#define DEFINE_BITFIELD(name, fields...) \
union { \
struct fields name; \
struct fields; \
};

#define KMEMCHECK_ANNOTATE_BITFIELD(bitfield) \
do { \
memset(&(bitfield), 0, sizeof(bitfield)); \
} while(0)

struct skbuff {
DEFINE_BITFIELD(flags1, {
uint8_t pkt_type:3,
fclone:2,
ipvs_property:1,
peeked:1,
nf_trace:1;
uint16_t protocol;
});

DEFINE_BITFIELD(flags2, {
#ifdef CONFIG_IPV6_NDISC_NODETYPE
uint8_t ndisc_nodetype:2;
#endif
#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
uint8_t do_not_encrypt:1;
#endif
});
};

void __alloc_skb(struct skbuff *skb)
{
KMEMCHECK_ANNOTATE_BITFIELD(skb->flags1);
KMEMCHECK_ANNOTATE_BITFIELD(skb->flags2);
}

<--- cut --->

Thanks,

Vegard
--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH] bitfields API, Vegard Nossum, (Thu Aug 28, 2:32 pm)
Re: [RFC][PATCH] bitfields API, Alexey Dobriyan, (Thu Aug 28, 2:40 pm)
Re: [RFC][PATCH] bitfields API, Vegard Nossum, (Thu Aug 28, 2:46 pm)
Re: [RFC][PATCH] bitfields API, Alexey Dobriyan, (Thu Aug 28, 3:05 pm)
Re: [RFC][PATCH] bitfields API, Vegard Nossum, (Thu Aug 28, 3:18 pm)
Re: [RFC][PATCH] bitfields API, Pekka Enberg, (Thu Aug 28, 3:07 pm)
Re: [RFC][PATCH] bitfields API, Pekka J Enberg, (Thu Aug 28, 3:02 pm)
Re: [RFC][PATCH] bitfields API, Vegard Nossum, (Thu Aug 28, 3:38 pm)
Re: [RFC][PATCH] bitfields API, Vegard Nossum, (Sat Aug 30, 4:28 am)
Re: [RFC][PATCH] bitfields API, Pekka Enberg, (Thu Aug 28, 2:40 pm)
Re: [RFC][PATCH] bitfields API, Adrian Bunk, (Thu Aug 28, 4:27 pm)
Re: [RFC][PATCH] bitfields API, Vegard Nossum, (Thu Aug 28, 4:59 pm)
Re: [RFC][PATCH] bitfields API, Pekka Enberg, (Thu Aug 28, 4:54 pm)