[PATCH] ARM: Add SWP/SWPB emulation for ARMv7 processors (v2)

Jamie Lokier jamie at shareable.org
Fri Dec 18 14:48:14 EST 2009


Russell King - ARM Linux wrote:
> On Fri, Dec 18, 2009 at 06:04:06PM +0000, Leif Lindholm wrote:
> > +static int swp_handler(struct pt_regs *regs, unsigned int instr)
> > +{
> > +	unsigned int address, destreg, data;
> > +	unsigned int res = 0;
> > +	long current_pid = sys_getpid();
> 
> Kernel functions calling system calls like this is frowned upon.  We
> know what the current PID is - it's available from current->pid.  No
> function call required.

Quick nitpick in case Leif follows that advice :-)

sys_getpid returns task_tgid_vnr(current).

It is neither ->pid (gettid returns that), nor directly dereferenced
because of the vnr part.  You'll have to decide whether current->tgid
or task_tgid_vnr(current), or current->pid after all are the
appropriate value in this situation.

-- Jamie



More information about the linux-arm-kernel mailing list