Bug #5045

use atomic_{inc,dec}_* instead of atomic_add_*

Added by Josef Sipek almost 4 years ago. Updated almost 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

The atomic_{inc,dec}_* functions exist for programmer convenience but their existence allows for possible optimizations. For example, instead of using the "add" instruction and storing 1 as an immediate one can use the "inc" instruction yielding smaller binary size.

There are size savings for genuinx and unix:

   text    data     bss     dec     hex filename
1861546   38275  200704 2100525  200d2d genunix-32-inline
1861206   38275  200704 2100185  200bd9 genunix-32-incdec
2525256   63299  304232 2892787  2c23f3 genunix-64-inline
2525192   63299  304232 2892723  2c23b3 genunix-64-incdec

   text    data     bss     dec     hex filename
 920073  114404  258360 1292837  13ba25 unix-32-i86pc-inline
 919961  114404  258360 1292725  13b9b5 unix-32-i86pc-incdec
1334101  137636  526528 1998265  1e7db9 unix-64-i86pc-inline
1334101  137636  526528 1998265  1e7db9 unix-64-i86pc-incdec

   text    data     bss     dec     hex filename
 928308  189188  378968 1496464  16d590 unix-32-i86xpv-inline
 928196  189188  378968 1496352  16d520 unix-32-i86xpv-incdec
1361954  206280  820448 2388682  2472ca unix-64-i86xpv-inline
1361954  206280  820448 2388682  2472ca unix-64-i86xpv-incdec

History

#1 Updated by Electric Monk almost 4 years ago

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

git commit 1a5e258f5471356ca102c7176637cdce45bac147

commit  1a5e258f5471356ca102c7176637cdce45bac147
Author: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Date:   2014-08-12T18:36:36.000Z

    5045 use atomic_{inc,dec}_* instead of atomic_add_*
    Reviewed by: Matthew Ahrens <mahrens@delphix.com>
    Reviewed by: Garrett D'Amore <garrett@damore.org>
    Approved by: Robert Mustacchi <rm@joyent.com>

Also available in: Atom