public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Emmanuel Grumbach <egrumbach@gmail.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Julia Lawall <julia.lawall@lip6.fr>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
	Intel Linux Wireless <ilw@linux.intel.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-wireless <linux-wireless@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/11] use ether_addr_equal_64bits
Date: Mon, 6 Jan 2014 10:35:14 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.10.1401061033370.2079@hadrien> (raw)
In-Reply-To: <CAMuHMdXZQO7jj+V2mMyyLgDoz6iSLJ25+55Yow-Acb1=tE5sMg@mail.gmail.com>

On Mon, 6 Jan 2014, Geert Uytterhoeven wrote:

> On Tue, Dec 31, 2013 at 7:26 AM, Emmanuel Grumbach <egrumbach@gmail.com> wrote:
> > On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg
> > <johannes@sipsolutions.net> wrote:
> >>
> >> On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote:
> >> > On Mon, 30 Dec 2013, Johannes Berg wrote:
> >> > > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote:
> >> > > > > Is there any way we could catch (sparse, or some other script?) that
> >> > > > > struct reorganising won't break the condition needed ("within a
> >> > > > > structure that contains at least two more bytes")?
> >> > > >
> >> > > > What kind of reorganizing could happen?  Do you mean that the programmer
> >> > > > might do at some time in the future, or something the compiler might do?
> >> > >
> >> > > I'm just thinking of a programmer, e.g. changing a struct like this:
> >> > >
> >> > >  struct foo {
> >> > >    u8 addr[ETH_ALEN];
> >> > > -  u16 dummy;
> >> > >  };
> >> > >
> >> > > for example.
> >> >
> >> > That is easily resolved by:
> >> >
> >> > struct foo {
> >> >       u8 addr[ETH_ALEN];
> >> >       u16 required_padding;   /* do not remove upon pain of death */
> >> > };
>
> Adding the u16 also changes the alignment of the whole struct. So it may
> cost one additional byte _in front of_ the struct.
>
> <asking-stupid-question-see-answer-below>
> While you're at it, why not just making a new 64-bit aligned type for
> Ethernet addresses, so it'll also work for
> !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS?
> </asking-stupid-question-see-answer-below>
>
> >> That'd be a stupid waste of struct space. If anything, there should be
> >> *only* a comment saying that at least two bytes are needed - I'd still
> >> prefer an automated check.
> >
> > Frankly I am not sure I like the patch. This flow is not a fast path
>
> I also don't like it. To me this sounds like wasting space for nothing.
> BTW, would it be that more expensive to always do a 32+16 bit
> comparison?

No space is wasted by the patch.  The patch is only generated in the case
where there is currently enough space.

julia

> > at all. While I don't really care for the waste in iwlwifi (because
> > there isn't), I don't see the real point is make the code more
> > sensitive to changes to earn basically nothing.
>
> Thanks to this discussion, my eye fell on:
>
> static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2)
> {
>         const u16 *a = (const u16 *) addr1;
>         const u16 *b = (const u16 *) addr2;
>
>         BUILD_BUG_ON(ETH_ALEN != 6);
>         return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
> }
>
> What if addr1 or addr2 are odd, and this is running on an architecture that
> doesn't support unaligned accesses at all?? Have we been lucky forever?
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2014-01-06  9:35 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30 18:14 [PATCH 0/11] use ether_addr_equal_64bits Julia Lawall
2013-12-30 18:14 ` [PATCH 1/11] rt2x00: " Julia Lawall
2013-12-31 16:44   ` Gertjan van Wingerde
2013-12-30 18:14 ` [PATCH 2/11] ath5k: " Julia Lawall
2013-12-30 18:14 ` [PATCH 3/11] mac80211: " Julia Lawall
2013-12-30 18:10   ` Christian Lamparter
2013-12-30 18:15 ` [PATCH 4/11] " Julia Lawall
2013-12-30 18:56   ` Johannes Berg
2013-12-30 19:58     ` Julia Lawall
2013-12-30 21:25       ` Johannes Berg
2013-12-30 21:57         ` Henrique de Moraes Holschuh
     [not found]           ` <20131230215701.GA4938-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2013-12-30 23:13             ` Johannes Berg
2013-12-30 23:17               ` Joe Perches
2013-12-31  6:32                 ` Julia Lawall
     [not found]                   ` <alpine.DEB.2.02.1312310726540.1930-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2013-12-31 15:54                     ` Ben Greear
2013-12-31 16:09                       ` Julia Lawall
2013-12-31 16:27                         ` Ben Greear
2013-12-31 16:40                           ` Julia Lawall
2014-01-06  9:05                             ` Johannes Berg
     [not found]                               ` <1388999147.5891.2.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
2014-01-06  9:09                                 ` Julia Lawall
2014-01-06 10:17                                   ` Johannes Berg
2014-01-06  8:48                 ` Julia Lawall
2014-01-06  8:59                   ` Joe Perches
2014-01-06  9:04                     ` Julia Lawall
2014-01-06  9:07                       ` Johannes Berg
2014-01-06  9:20                         ` Julia Lawall
2013-12-31  6:26               ` Emmanuel Grumbach
2014-01-06  9:24                 ` Geert Uytterhoeven
2014-01-06  9:35                   ` Julia Lawall [this message]
2014-01-06 15:18                   ` Eric Dumazet
2014-01-06 10:48               ` Dan Carpenter
2014-01-17 10:18                 ` Dan Carpenter
2013-12-30 18:15 ` [PATCH 5/11] mwl8k: " Julia Lawall
2013-12-30 18:15 ` [PATCH 6/11] rtlwifi: " Julia Lawall
2013-12-30 21:08   ` Larry Finger
2013-12-30 18:15 ` [PATCH 7/11] iwlegacy: " Julia Lawall
2013-12-30 18:15 ` [PATCH 8/11] " Julia Lawall
2013-12-30 18:15 ` [PATCH 9/11] ipw2x00: " Julia Lawall
2013-12-30 18:15 ` [PATCH 10/11] at76c50x-usb: " Julia Lawall
2013-12-30 18:15 ` [PATCH 11/11] carl9170: " Julia Lawall
2013-12-30 18:10   ` Christian Lamparter
2014-01-17 21:24 ` [PATCH 0/11] " Pavel Machek
2014-01-17 22:02   ` Oleksij Rempel
2014-01-17 22:43     ` Pavel Machek

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=alpine.DEB.2.10.1401061033370.2079@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=egrumbach@gmail.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=geert@linux-m68k.org \
    --cc=hmh@hmh.eng.br \
    --cc=ilw@linux.intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --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