lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 15 May 2014 09:04:07 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Joe Perches' <joe@...ches.com>,
	Alexei Starovoitov <alexei.starovoitov@...il.com>
CC:	Veaceslav Falico <vfalico@...il.com>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	Jay Vosburgh <j.vosburgh@...il.com>,
	"Andy Gospodarek" <andy@...yhouse.net>,
	Veaceslav Falico <vfalico@...hat.com>
Subject: RE: [PATCH net-next 0/5] bonding: simple macro cleanup

From: Joe Perches
> On Wed, 2014-05-14 at 09:10 -0700, Alexei Starovoitov wrote:
> > from compiler point of view it's actually easier to deal with inline functions
> > than macros. I'd suggest to do the full conversion the other way around:
> > convert all macros to static inline. Developers will enjoy better type safety
> > and compiler will enjoy more opportunities to optimize code.
> 
> Agree about the type safety, but sometimes a compiler will
> generate worse code with static inlines than #defines.

Sometimes yes - mainly because the #define version happens
at a much earlier stage in the compilation so is subject
to additional optimisations.
For most functions it either has no effect, or doesn't matter.

If you are trying to squeeze out every last unwanted clock cycle
then #defines can help.
Take the following real example:

#define ASM_COMMENT(text) asm volatile( "#" text " line " STR(__LINE__) :: )
#define hdlc_put_ind(rx_hdlc) do { \
        (++hdlc_ind_next - 1)->hi_rqst = rx_hdlc; \
        if (predict_false(hdlc_ind_next == hdlc_ind_last)) { \
            hdlc_ind_next = hdlc_ind; \
            ASM_COMMENT("ring wrapped"); \
        } \
    } while (0)

The ASM_COMMENT here is important - it stops gcc tail merging the
call in code like:
	if (foo) {
		...
		hdlc_put_ind(bar);
	} else {
		...
		hdlc_put_ind(baz);
	}
	continue;

With an inline function you can't force two copies be generated.

But most of the network stack isn't optimised to that level!

	David



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ