English 中文(简体)
Why spinlock in linux kernel is in the ".subsection 1" (or ".text.lock.smth")?
原标题:

In linux kernel in the implementation of spinlocks, e.g. http://lxr.linux.no/#linux+v2.6.18/include/asm-i386/semaphore.h#L97

  97static inline void down(struct semaphore * sem)
  98{
  99        might_sleep();
 100        __asm__ __volatile__(
 101                "# atomic down operation
	"
 102                LOCK_PREFIX "decl %0
	"     /* --sem->count */
 103                "js 2f
"
 104                "1:
"
 105                LOCK_SECTION_START("")
 106                "2:	lea %0,%%eax
	"
 107                "call __down_failed
	"
 108                "jmp 1b
"
 109                LOCK_SECTION_END
 110                :"+m" (sem->count)
 111                :
 112                :"memory","ax");
 113}

LOCK_SECTION_START and LOCK_SECTION_END are used. They are defined in http://lxr.linux.no/#linux+v2.6.18/include/linux/spinlock.h#L63 as

  61#define LOCK_SECTION_NAME ".text.lock."KBUILD_BASENAME
  62
  63#define LOCK_SECTION_START(extra)               
  64        ".subsection 1
	"                     
  65        extra                                   
  66        ".ifndef " LOCK_SECTION_NAME "
	"     
  67        LOCK_SECTION_NAME ":
	"               
  68        ".endif
"
  69
  70#define LOCK_SECTION_END                        
  71        ".previous
	"

So all locked operations are partly putted in subsection 1 or section .text.lock.SMTH_STRING.

What reason is for it?

最佳回答

I m not 100% sure, but I think this is related to SMP alternatives for i386, where kernel can switch between SMP and UP at boot or even at runtime.

问题回答

暂无回答




相关问题
List of suspected Malicious patterns

I am doing an anti-virus project by disassembling its code and analyzing it. So I want a list of the Suspected Malicious pattern codes, so I can observe which is suspected and which is not? So I want ...

Prefetch for Intel Core 2 Duo

Has anyone had experience using prefetch instructions for the Core 2 Duo processor? I ve been using the (standard?) prefetch set (prefetchnta, prefetcht1, etc) with success for a series of P4 ...

How are mutex and lock structures implemented?

I understand the concept of locks, mutex and other synchronization structures, but how are they implemented? Are they provided by the OS, or are these structures dependent on special CPU instructions ...

Installing GNU Assembler in OSX

No matter how hard I google, I can t seem to find a (relatively) easy-to-follow instruction on how to install the GNU Assembler on a mac. I know I can use gcc -c (Apple Clang on a Mac) to assemble .s ...

8086 assembler,INT 16,2

I got stuck at this thing,I want to see if right shift button has been pressed,so I have this assambler code: mov ah,2 int 16h ;calling INT 16,2 - Read Keyboard Flags interrupt mov ah,...

Translate a FOR to assembler

I need to translate what is commented within the method, to assembler. I have a roughly idea, but can t. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, ...

热门标签