[RFC PATCH 0/2] powerpc: CR based local atomic operation implementation
Madhavan Srinivasan
maddy at linux.vnet.ibm.com
Fri Nov 28 19:27:08 AEDT 2014
On Thursday 27 November 2014 07:35 PM, David Laight wrote:
> From: Madhavan Srinivasan
>> This patchset create the infrastructure to handle the CR based
>> local_* atomic operations. Local atomic operations are fast
>> and highly reentrant per CPU counters. Used for percpu
>> variable updates. Local atomic operations only guarantee
>> variable modification atomicity wrt the CPU which owns the
>> data and these needs to be executed in a preemption safe way.
>
> These are usually called 'restartable atomic sequences (RAS)'.
>
>> Here is the design of the first patch. Since local_* operations
>> are only need to be atomic to interrupts (IIUC), patch uses
>> one of the Condition Register (CR) fields as a flag variable. When
>> entering the local_*, specific bit in the CR5 field is set
>> and on exit, bit is cleared. CR bit checking is done in the
>> interrupt return path. If CR5[EQ] bit set and if we return
>> to kernel, we reset to start of local_* operation.
>
> I don't claim to be able to read ppc assembler.
> But I can't see the code that clears CR5[EQ] for the duration
> of the ISR.
I use crclr instruction at the end of the code block to clear the bit.
> Without it a nested interrupt will go through unwanted paths.
>
> There are also a lot of 'magic' constants in that assembly code.
>
All these constants are define in asm/ppc-opcode.h
> I also wonder if it is possible to inspect the interrupted
> code to determine the start/end of the RAS block.
> (Easiest if you assume that there is a single 'write' instruction
> as the last entry in the block.)
>
So each local_* function also have code in the __ex_table section. IIUC,
__ex_table contains two address. So if the return address found in the
first column of the _ex_table, use the corresponding address in the
second column to continue from.
> Also, how expensive is it to disable all interrupts?
>
In the patch 1/2, posted the numbers for that too.
> David
>
Regards
Maddy
More information about the Linuxppc-dev
mailing list