public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Alexey Dobriyan' <adobriyan@gmail.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"xemul@openvz.org" <xemul@openvz.org>
Subject: RE: [PATCH 3/3] netns: fix net_generic() "id - 1" bloat
Date: Tue, 13 Dec 2016 14:42:53 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB023DBE9@AcuExch.aculab.com> (raw)
In-Reply-To: <CACVxJT8fT0Lbe_ojNjU9DYYO=PO+QzA=jpQb7V6_US8W9D-KTQ@mail.gmail.com>

From: Alexey Dobriyan
> Sent: 13 December 2016 14:23
...
> Well, the point of the patch is to save .text, so might as well save
> as much as possible. Any form other than "ptr[id]" is going
> to be either bigger or bigger and slower and "ptr" should be the first field.

You've not read and understood the next bit:

> > However if you offset the 'id' values so that only
> > values 2 up are valid the code becomes:
> >         return net->gen2->ptr[id - 2];
> > which will be exactly the same code as:
> >         return net->gen1->ptr[id];
> > but it is much more obvious that 'id' values must be >= 2.
> >
> > The '2' should be generated from the structure offset, but with my method
> > is doesn't actually matter if it is wrong.

If you have foo->bar[id - const] then the compiler has to add the
offset of 'bar' and subtract for 'const'.
If the numbers match no add or subtract is needed.

It is much cleaner to do this by explicitly removing the offset on the
accesses than using a union.

	David


  reply	other threads:[~2016-12-13 14:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02  1:21 [PATCH 3/3] netns: fix net_generic() "id - 1" bloat Alexey Dobriyan
2016-12-05 12:49 ` David Laight
2016-12-05 14:48   ` Alexey Dobriyan
2016-12-07 10:49     ` David Laight
2016-12-13 14:23       ` Alexey Dobriyan
2016-12-13 14:42         ` David Laight [this message]
2016-12-14 13:19           ` Alexey Dobriyan
2016-12-14 14:41             ` David Laight

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=063D6719AE5E284EB5DD2968C1650D6DB023DBE9@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=adobriyan@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@openvz.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