From: Eddie Kohler <kohler@cs.ucla.edu>
To: dccp@vger.kernel.org
Subject: Re: [RFC] [PATCH]: use explicit enums for CCID 3 states
Date: Wed, 15 Nov 2006 16:05:00 +0000 [thread overview]
Message-ID: <455B3AAC.90909@cs.ucla.edu> (raw)
In-Reply-To: <200611151401.41404@strip-the-willow>
Sure, straight enums use more space, but it's possible to use an enum
bitfield. That would get the best of both worlds.
Eddie
Arnaldo Carvalho de Melo wrote:
> On 11/15/06, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
>> This patch tackles the following problem:
>> * the ccid3_hc_{t,r}x_sock define ccid3hc{t,r}x_state as `u8',
>> but
>> in reality there can only be a few, pre-defined enum names
>> * this necessitates addiditional checking for unexpected values
>> which would otherwise be caught by the compiler
>
> My problem is with the changes to the structs, from u8 to enums, that
> take 4 bytes, <shameless plug>see using my new tool, codiff (code
> diff):
>
> [acme@newtoy net-2.6.20]$ codiff --structs --verbose
> /tmp/ccid3.o.before /tmp/ccid3.o.enum
> /pub/scm/linux/kernel/git/acme/net-2.6.20/net/dccp/ccids/ccid3.c:
> struct ccid3_hc_tx_sock | +4
> ccid3hctx_state;
> from: u8 /* 30(0) 1(0) */
> to: enum ccid3_hc_tx_states /* 32(0) 4(0) */
> struct ccid3_hc_rx_sock | +4
> ccid3hcrx_state:8;
> from: u64 /* 16(36) 8(8) */
> to: enum ccid3_hc_rx_states /* 20(0) 4(0) */
> 2 structs changed
> [acme@newtoy net-2.6.20]$
>
> </shameless plug>
>
> I removed the other parts of the patch (replacing printks+dump_stack
> with BUG) to see what would be the code impact of such change and was
> surprised:
>
> [acme@newtoy net-2.6.20]$ codiff --functions /tmp/ccid3.o.before
> /tmp/ccid3.o.enum
> /pub/scm/linux/kernel/git/acme/net-2.6.20/net/dccp/ccids/ccid3.c:
> ccid3_hc_rx_set_state | -33
> ccid3_hc_tx_set_state | -5
> ccid3_hc_rx_send_feedback | -16
> ccid3_hc_rx_init | -8
> ccid3_hc_tx_init | +3
> ccid3_hc_tx_no_feedback_timer | -14
> ccid3_hc_rx_packet_recv | -48
> ccid3_hc_rx_get_info | -5
> 8 functions changed, 3 bytes added, 129 bytes removed
> [acme@newtoy net-2.6.20]$
>
> Anyway, there are always tradeoffs, compiler gets more info, but we
> end up using more memory per socket instance, I guess we can stay like
> we are now, no? :-)
>
> - Arnaldo
>
> Probably because we stop using a u64 bitfield in the rx case...
> -
> To unsubscribe from this list: send the line "unsubscribe dccp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2006-11-15 16:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-15 14:01 [RFC] [PATCH]: use explicit enums for CCID 3 states Gerrit Renker
2006-11-15 15:10 ` Arnaldo Carvalho de Melo
2006-11-15 15:26 ` Gerrit Renker
2006-11-15 15:32 ` Arnaldo Carvalho de Melo
2006-11-15 16:05 ` Eddie Kohler [this message]
2006-11-15 17:33 ` Ian McDonald
2006-11-15 17:48 ` Gerrit Renker
2006-11-15 18:44 ` Arnaldo Carvalho de Melo
2006-11-15 19:02 ` Ian McDonald
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=455B3AAC.90909@cs.ucla.edu \
--to=kohler@cs.ucla.edu \
--cc=dccp@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.