Bug #5044

define static inlines for most often used atomic functions

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

Status:ClosedStart date:2014-07-28
Priority:LowDue date:
Assignee:Josef Sipek% Done:

100%

Category:kernel
Target version:-
Difficulty:Bite-size Tags:needs-triage

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.

History

#1 Updated by Electric Monk about 4 years ago

  • % Done changed from 90 to 100
  • Status changed from New to Closed

git commit febac2a0e9cb29c6762618e32b7ca73916512d7f

commit  febac2a0e9cb29c6762618e32b7ca73916512d7f
Author: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Date:   2014-08-12T16:27:46.000Z

    5044 define static inlines for most often used atomic functions
    Reviewed by: Garrett D'Amore <garrett@damore.org>
    Approved by: Robert Mustacchi <rm@joyent.com>

Also available in: Atom