All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Alexei Starovoitov' <alexei.starovoitov@gmail.com>,
	Daniel Borkmann <dborkman@redhat.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>,
	Tejun Heo <tj@kernel.org>
Subject: RE: [PATCH net-next 5/5] net: sctp: fix incorrect type in gfp initializer
Date: Thu, 12 Jun 2014 08:46:44 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1725B905@AcuExch.aculab.com> (raw)
In-Reply-To: <CAADnVQLyNCUU0+onEHbygVE-M3WK59uB=NoKWi1V4Rh+6AZkVA@mail.gmail.com>

From: Alexei Starovoitov
> On Wed, Jun 11, 2014 at 8:09 AM, Daniel Borkmann <dborkman@redhat.com> wrote:
> > On 06/11/2014 04:55 PM, David Laight wrote:
> >>
> >> From: Daniel Borkmann
...
> >>> --- a/net/sctp/associola.c
> >>> +++ b/net/sctp/associola.c
> >>> @@ -1591,7 +1591,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association
> >>> *asoc,
> >>>   /* Set an association id for a given association */
> >>>   int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
> >>>   {
> >>> -       bool preload = gfp & __GFP_WAIT;
> >>> +       bool preload = !!(gfp & __GFP_WAIT);
> >>>         int ret;
> >>>
> >>>         /* If the id is already assigned, keep it. */
> >>> --
> >>
> >>
> >> I was wondering if the compiler still manages to optimise this in a
> >> manner that avoids actually calculating the boolean value...
> >>
> >> So I disassembled the compilation I just did of the old code (gcc 4.7.3).
> >> The object code looks strange.
> 
> I'm not sure where you see this.
> Just tried with gcc 4.7.2 on x64 and assembler code is exactly the
> same before/after this change.

I was slightly worried it might generate the boolean value - something
that you really don't want it to do.

I only looked at the output for the old version.
The compiler seemed to have converted:
	if (preload)
		x();
	y;
	if (preload)
		z();
into:
	if (preload) {
		x(); y; z();
	} else {
		y;
	}
and then found out that z() was empty, leaving two copies of y().

	David

> >> I think that idr_preload_end() must be an empty inline function.
> >
> >
> > Cc'ing Tejun. ;-)
> >
> >
> >> The compiler has duplicated the code between the two 'if (preload)'
> >> clauses (to avoid the conditional test), and the failed to tail
> >> merge everything in the latter stages.
> >> I suspect that an empty '#define' would generate smaller code.
> >>
> >>         David


WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: 'Alexei Starovoitov' <alexei.starovoitov@gmail.com>,
	Daniel Borkmann <dborkman@redhat.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>,
	Tejun Heo <tj@kernel.org>
Subject: RE: [PATCH net-next 5/5] net: sctp: fix incorrect type in gfp initializer
Date: Thu, 12 Jun 2014 08:46:44 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1725B905@AcuExch.aculab.com> (raw)
In-Reply-To: <CAADnVQLyNCUU0+onEHbygVE-M3WK59uB=NoKWi1V4Rh+6AZkVA@mail.gmail.com>

RnJvbTogQWxleGVpIFN0YXJvdm9pdG92DQo+IE9uIFdlZCwgSnVuIDExLCAyMDE0IGF0IDg6MDkg
QU0sIERhbmllbCBCb3JrbWFubiA8ZGJvcmttYW5AcmVkaGF0LmNvbT4gd3JvdGU6DQo+ID4gT24g
MDYvMTEvMjAxNCAwNDo1NSBQTSwgRGF2aWQgTGFpZ2h0IHdyb3RlOg0KPiA+Pg0KPiA+PiBGcm9t
OiBEYW5pZWwgQm9ya21hbm4NCi4uLg0KPiA+Pj4gLS0tIGEvbmV0L3NjdHAvYXNzb2Npb2xhLmMN
Cj4gPj4+ICsrKyBiL25ldC9zY3RwL2Fzc29jaW9sYS5jDQo+ID4+PiBAQCAtMTU5MSw3ICsxNTkx
LDcgQEAgaW50IHNjdHBfYXNz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ICcjZGVmaW5lJyB3b3VsZCBnZW5lcmF0ZSBzbWFs
bGVyIGNvZGUuDQo+ID4+DQo+ID4+ICAgICAgICAgRGF2aWQNCg0K

  reply	other threads:[~2014-06-12  8:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 14:34 [PATCH net-next 0/5] SCTP update Daniel Borkmann
2014-06-11 14:34 ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 1/5] ktime: add ktime_after and ktime_before helper Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 2/5] net: sctp: refactor active path selection Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 3/5] net: sctp: migrate most recently used transport to ktime Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 4/5] net: sctp: improve sctp_select_active_and_retran_path selection Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 5/5] net: sctp: fix incorrect type in gfp initializer Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:55   ` David Laight
2014-06-11 15:09     ` Daniel Borkmann
2014-06-11 15:09       ` Daniel Borkmann
2014-06-11 17:18       ` Alexei Starovoitov
2014-06-11 17:18         ` Alexei Starovoitov
2014-06-12  8:46         ` David Laight [this message]
2014-06-12  8:46           ` David Laight
2014-06-18 18:30           ` Tejun Heo
2014-06-18 18:30             ` Tejun Heo
2014-06-19  8:13             ` David Laight
2014-06-19 13:46               ` 'Tejun Heo'
2014-06-19 13:46                 ` 'Tejun Heo'

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=063D6719AE5E284EB5DD2968C1650D6D1725B905@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tj@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.