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, 02 Apr 2015 06:11:46 -0700
From:	Joe Perches <joe@...ches.com>
To:	Nicholas Mc Guire <hofrat@...dl.org>
Cc:	John Stultz <john.stultz@...aro.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Aaron Sierra <asierra@...-inc.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC] allow constant folding in msecs_to_jiffies where
 possible for gcc

On Thu, 2015-04-02 at 08:37 +0200, Nicholas Mc Guire wrote:
> A number of cleanup patches where switching var * HZ / 1000
> constructs to msecs_to_jiffies(var) to ensure that all corener
> cases are handled properly. The downside of this though is that
> it now uses a function call and also was not performing
> constant folding where it was originally possible.
> 
> msecs_to_jiffies() will calculate jiffies even if constants are
> passed in that could be handled by constant folding at compile time
> using __builtin_constant_p() gcc can optimize the constant case
> again.

OK, but how could this actually work?

This code isn't visible in a module at compile time, so how
could the compiler actually optimize the function call away?

Look at the disassembly for any object that uses
msecs_to_jiffies(<constant>).

For instance: drivers/bluetooth/hci_vhci.o

	schedule_delayed_work(&data->open_timeout, msecs_to_jiffies(1000));
 60d:	bf e8 03 00 00       	mov    $0x3e8,%edi
 612:	e8 00 00 00 00       	callq  617 <vhci_open+0xc7>
			613: R_X86_64_PC32	msecs_to_jiffies-0x4

You need to make this code either a macro or static inline
in jiffies.h, and for that the kernel/timeconst.h file needs
to be available.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ