Changeset 53f9821 in mainline for arch/amd64/include/atomic.h


Ignore:
Timestamp:
2006-03-20T20:32:17Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
018d957e
Parents:
9d3e185
Message:

Cleanup of spinlocks, now compiles both ia32 and amd64 with
and without DEBUG_SPINLOCKS. Made spinlocks inline.
Moved syscall_handler to generic (it was identical for ia32,amd64 & mips32).
Made slightly faster syscall for ia32.
Made better interrupt routines for ia32.
Allow not saving non-scratch registers during interrupt on ia32,amd64,mips32.
Aligned interrupt handlers on ia32,amd64, this should prevent problems
with different instruction lengths.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/atomic.h

    r9d3e185 r53f9821  
    3131
    3232#include <arch/types.h>
     33#include <arch/barrier.h>
     34#include <preemption.h>
    3335
    3436typedef struct { volatile __u64 count; } atomic_t;
     
    102104
    103105
    104 extern void spinlock_arch(volatile int *val);
     106/** AMD64 specific fast spinlock */
     107static inline void atomic_lock_arch(atomic_t *val)
     108{
     109        __u64 tmp;
     110
     111        preemption_disable();
     112        __asm__ volatile (
     113                "0:;"
     114#ifdef CONFIG_HT
     115                "pause;" /* Pentium 4's HT love this instruction */
     116#endif
     117                "mov %0, %1;"
     118                "testq %1, %1;"
     119                "jnz 0b;"       /* Leightweight looping on locked spinlock */
     120               
     121                "incq %1;"      /* now use the atomic operation */
     122                "xchgq %0, %1;"
     123                "testq %1, %1;"
     124                "jnz 0b;"
     125                : "=m"(val->count),"=r"(tmp)
     126                );
     127        /*
     128         * Prevent critical section code from bleeding out this way up.
     129         */
     130        CS_ENTER_BARRIER();
     131}
    105132
    106133#endif
Note: See TracChangeset for help on using the changeset viewer.