Project

General

Profile

Actions

Bug #5044

closed

define static inlines for most often used atomic functions

Added by Josef Sipek about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
kernel
Start date:
2014-07-28
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:

Description

Using static inlines here allows the compiler to optimize better. The GCC inline asm construct is template based (https://gcc.gnu.org/onlinedocs/gcc-4.4.4/gcc/Constraints.html) - the programmer specifies what the assembly code should look like, but leaves the register assignment up to the compiler. This lets the compiler make smarter choices rather than forcing it to load values into specific registers (which naive inline assembly constructs and function calls do).

This patch foregoes implementing atomic_*_nv() functions since they are more complex and used less often.

Interestingly enough, inlining the atomic operations yields smaller binary size. For example, here are binary sizes for genunix and unix with and without this patch:

   text    data     bss     dec     hex filename
1863438   38275  200704 2102417  201491 genunix-32-before
1861546   38275  200704 2100525  200d2d genunix-32-inline
2527864   63299  304232 2895395  2c2e23 genunix-64-before
2525256   63299  304232 2892787  2c23f3 genunix-64-inline

   text    data     bss     dec     hex filename
 924825  114404  258360 1297589  13ccb5 unix-32-i86pc-before
 920073  114404  258360 1292837  13ba25 unix-32-i86pc-inline
1335309  137636  526528 1999473  1e8271 unix-64-i86pc-before
1334101  137636  526528 1998265  1e7db9 unix-64-i86pc-inline

   text    data     bss     dec     hex filename
 929332  189188  378968 1497488  16d990 unix-32-i86xpv-before
 928308  189188  378968 1496464  16d590 unix-32-i86xpv-inline
1363434  206280  820448 2390162  247892 unix-64-i86xpv-before
1361954  206280  820448 2388682  2472ca unix-64-i86xpv-inline

Note: only the kernel uses these static inlines and therefore userspace is unaffected.

Actions

Also available in: Atom PDF