What is asmlinkage ?
Rajat Sharma
fs.rajat at gmail.com
Fri Jan 4 02:35:18 EST 2013
> So with asmlinkage we request compiler to put args on stack. What is
advantage of this to start_kernel or in general to other functions ?
See its about implementation ease and little of performance too. Assuming
the default model of keeping arguments in registers is used. lets say
arguments are assumed to be in registers R1, R2, R3, R4, R5, R6 and beyond
that in stack. Since system call number is a transparent argument which is
chopped off when calling the actual kernel handler and if R1 had the system
call number, then you have to shift all register values and stack arguments
too.
Now consider that all arguments are pushed on stack (as enforced by
asmlinkage), you have all function argument in the beginning of the stack
and the system call number on top of the stack. you just need to pop out
stack top to remove system call number from function argument.
You might argue that why not always keep system call number on stack top
and use registers for function arguments? But thats part of the compiler
ABI and if you had fewer arguments lets say 2 only and used up R1 and R2
only, you may not jump to stack top directly for storing system call as its
turn for R3 as argument.
So, isn't it simpler implementation with everything on stack?
-Rajat
On Fri, Jan 4, 2013 at 12:13 PM, Rahul Bedarkar <rpal143 at gmail.com> wrote:
> Thanks. So with asmlinkage we request compiler to put args on stack. What
> is advantage of this to start_kernel or in general to other functions ?
>
> Regards,
> Rahul
>
>
> On Thu, Jan 3, 2013 at 9:34 PM, Mulyadi Santosa <mulyadi.santosa at gmail.com
> > wrote:
>
>> On Thu, Jan 3, 2013 at 7:40 PM, Rahul Bedarkar <rpal143 at gmail.com> wrote:
>> > Hi,
>> >
>> > I was searching for asmlinkage and found that it is already explained at
>> > http://kernelnewbies.org/FAQ/asmlinkage
>> >
>> > But I didn't get this. Can someone tell me about it in brief ?
>>
>> the point is, parameters which is usually passed via stack, is passed
>> using different way.
>>
>> A good example is system call.... they are passed using registers IIRC
>>
>>
>> --
>> regards,
>>
>> Mulyadi Santosa
>> Freelance Linux trainer and consultant
>>
>> blog: the-hydra.blogspot.com
>> training: mulyaditraining.blogspot.com
>>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130104/97d51c26/attachment-0001.html
More information about the Kernelnewbies
mailing list