Uninline atomic_t functions
Subsystems (2)
Quoted 2 lines · David S. Miller
I am going to apply this now to 2.6.x, but we should uninline some of this stuff afterwards as I agree with Peter.
Indeed, it saves a whopping 115KB in the final image. For 2.6.4 I think.
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1692 -> 1.1693
# arch/sparc/kernel/smp.c 1.11 -> 1.12
# include/asm-sparc/atomic.h 1.9 -> 1.10
# arch/sparc/lib/Makefile 1.6 -> 1.7
# (new) -> 1.1 arch/sparc/lib/atomic32.c
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/02/15 [email protected] 1.1693
# [SPARC32] Outline the atomic functions.
# --------------------------------------------
#
arch/sparc/kernel/smp.c +0 -3
@@ -56,9 +56,6 @@volatile int __cpu_number_map[NR_CPUS ];volatile int __cpu_logical_map[NR_CPUS ];cycles_t cacheflush_time =0 ;/* XXX */ -spinlock_t __atomic_hash[ATOMIC_HASH_SIZE ] = { - [0 ... (ATOMIC_HASH_SIZE -1 )] =SPIN_LOCK_UNLOCKED -};/* The only guaranteed locking primitive available on all Sparc * processors is 'ldstub [%reg + immediate], %dest_reg' which atomically
arch/sparc/lib/Makefile +2 -2
@@ -7,5 +7,5 @@ lib-y := mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o memcpy.o memset.o \ strlen.o checksum.o blockops.o memscan.o memcmp.o strncmp.o \ strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \ - copy_user.o locks.o atomic.o bitops.o debuglocks.o lshrdi3.o \ - ashldi3.o rwsem.o muldi3.o bitext.o + copy_user.o locks.o atomic.o atomic32.o bitops.o debuglocks.o \ + lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o
arch/sparc/lib/atomic32.c new file +52 -0
52 lines not on this page · raw message
include/asm-sparc/atomic.h +3 -36
@@ -11,49 +11,16 @@#define __ARCH_SPARC_ATOMIC__#include <linux/config.h> -#include <linux/spinlock.h> typedef struct {volatile int counter; }atomic_t ;#ifdef __KERNEL__ -#ifdef CONFIG_SMP - -#define ATOMIC_HASH_SIZE 4 -#define ATOMIC_HASH (a) (&__atomic_hash[(((unsigned long)a)>>8) & (ATOMIC_HASH_SIZE-1)]) -extern spinlock_t __atomic_hash[ATOMIC_HASH_SIZE ]; - -#else /* SMP */ - -#define ATOMIC_HASH_SIZE 1 -#define ATOMIC_HASH (a) 0 - -#endif /* SMP */ - -static inline int __atomic_add_return (int i,atomic_t *v) -{ -int ret; -unsigned long flags; -spin_lock_irqsave (ATOMIC_HASH (v), flags); - - ret = (v->counter += i); - -spin_unlock_irqrestore (ATOMIC_HASH (v), flags); -return ret; -} - -static inline void atomic_set (atomic_t *v,int i) -{ -unsigned long flags; -spin_lock_irqsave (ATOMIC_HASH (v), flags); - - v->counter = i; - -spin_unlock_irqrestore (ATOMIC_HASH (v), flags); -} -#define ATOMIC_INIT (i) { (i) } +extern int __atomic_add_return (int ,atomic_t *); +extern void atomic_set (atomic_t *,int ); +#define atomic_read (v) ((v)->counter)#define atomic_add (i, v) ((void)__atomic_add_return( (int)(i), (v)))
Signature · 1 line
Keith M Wesolowski