Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 12 Jun 2020 16:07:18 +0200
From: Adam Zabrocki <>
Subject: Re: RE: ISRA optimized functions

On Fri, Jun 12, 2020 at 09:57:20AM +0200, Mikhail Morfikov wrote:
> On 12/06/2020 00:19, Adam Zabrocki wrote:
> > 
> > I would need to do manual investigation how your build process looks and works. 
> > However, I don't think it makes any sense.
> Actually it's not just my build process, only the kernel's bindeb-pkg target 
> which I think all people using Debian call when they're building their custom 
> kernels. It produces simple deb packages that can be installed via 
> apt-get/aptitude to make the system clean when you don't need them anymore. So
> this is quite common technique to build the kernel, at least on Debian/Ubuntu.

Sure, but this is not what I was refering to.

> > However, which function would be affected by such optimization purely 
> > depends on the kernel configuration.
> I have a question. There's "Compiler optimization level" in the kernel config 
> with the following options to choose:
> This is the default optimization level for the kernel, building
> with the "-O2" compiler flag for best performance and most
> helpful compile-time warnings.

This option is used to build "lowlatency" kernels. Default kernel is "generic". 
However, this single option by itself won't introduce such optimization.

> Choosing this option will pass "-Os" to your compiler resulting
> in a smaller kernel.
> So either one is used with the default to CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE. 
> Maybe this is the problem with "-O2"? If so, it's default and I don't think this 
> "-O2" flag can be removed without changing kernel distro config, which I don't 
> think is likely to happen. The following is from the Debian default kernel 
> config:
> $ grep CONFIG_CC_OPTIMIZE /boot/config-5.6.0-2-amd64

As I mentioned before, by itself it won't produce optimization which you are 
facing. There must be other dependencies which allows compiler for such 
optimization. E.g. no external callers etc. Here is an example for the Ubuntu 
20.xx default kernel which is "lowlatency":

$ uname -r
$ cat /proc/kallsyms |grep lookup_fast|head -1
0000000000000000 t lookup_fast
$ cat /proc/kallsyms |grep constprop|wc -l
# cat /boot/config-`uname -r`|grep CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE

As you can see, even CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is configured, so this 
is "lowlatency" kernel, and CONSTPROP optimization is enforced in various 
places (590 funtions was optimized using this method), function "lookup_fast" 
is not touched. This is Ubuntu 20.xx kernel package.
The main reason why you have that problem is unusual and specific kernel 
configuration which allows for such optimization.


pi3 (pi3ki31ny) - pi3 (at) itsec pl

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.