Functions _spin_lock_cb() and handle_ro_raz()
Hello everyone,
I am working on the violations of MISRA C:2012 Rule 8.10, whose headline says:
"An inline function shall be declared with the static storage class".
For both ARM64 and X86_64 builds,
function _spin_lock_cb() defined in spinlock.c violates the rule. Such function is declared in spinlock.h without
the inline function specifier: are there any reasons to do this? What about solving the violation by moving the function definition in spinlock.h and declaring it as static inline?
The same happens also for the function handle_ro_raz() in the ARM64 build, declared in traps.h and defined in traps.c.
Regards,
Federico Serafini
Quoted 10 lines · Federico Serafini
Hello everyone,
I am working on the violations of MISRA C:2012 Rule 8.10, whose headline says:
"An inline function shall be declared with the static storage class".For both ARM64 and
X86_64builds,
function_spin_lock_cb()defined inspinlock.cviolates the rule. Such function is declared inspinlock.hwithout
the inline function specifier: are there any reasons to do this?
Since this function was mentioned elsewhere already, I'm afraid I have to be a little blunt and ask back: Did you check the history of the function. Yes, it is intentional to be that way, for the function to be inlined into _spin_lock(), and for it to also be available for external callers (we have just one right now, but that could change).
Quoted 2 lines
What about solving the violation by moving the function definition in
spinlock.hand declaring it as static inline?
Did you try whether that would work at least purely mechanically? I'm afraid you'll find that it doesn't, because of LOCK_PROFILE_* being unavailable then. Yet we also don't want to expose all that in the header.
In the earlier context I did suggest already to make the function an always-inline one in spinlock.c, under a slightly altered name, and then have _spin_lock_cb() be a trivial wrapper just like _spin_lock() is. I guess best is going to be if I make and post a patch ...
Jan
Quoted 25 lines · Jan Beulich
Quoted 10 lines · Federico Serafini
Hello everyone,
I am working on the violations of MISRA C:2012 Rule 8.10, whose headline says:
"An inline function shall be declared with the static storage class".For both ARM64 and
X86_64builds,
function_spin_lock_cb()defined inspinlock.cviolates the rule. Such function is declared inspinlock.hwithout
the inline function specifier: are there any reasons to do this?Since this function was mentioned elsewhere already, I'm afraid I have to be a little blunt and ask back: Did you check the history of the function. Yes, it is intentional to be that way, for the function to be inlined into
_spin_lock(), and for it to also be available for external callers (we have just one right now, but that could change).Quoted 2 lines
What about solving the violation by moving the function definition in
spinlock.hand declaring it as static inline?Did you try whether that would work at least purely mechanically? I'm afraid you'll find that it doesn't, because of LOCK_PROFILE_* being unavailable then. Yet we also don't want to expose all that in the header.
Quoted 7 lines
In the earlier context I did suggest already to make the function an always-inline one in
spinlock.c, under a slightly altered name, and then have_spin_lock_cb()be a trivial wrapper just like_spin_lock()is. I guess best is going to be if I make and post a patch ...Jan
Thank you for the information.
Federico
(+ Bertrand and Stefano)
Quoted 1 line · Federico Serafini
Hello everyone,
Hi Federico,
Let me start with a tip to help reaching the maintainers and getting a more timely answer. Xen-devel has a large volume of e-mails (still less than Linux :)). So some of us will have filter to try to classify the e-mails received.
Commonly, all the e-mails where the person is in the CC/To list will go to the inbox. All the others will go a separate directory that may or may not be watched. Personally, I tend to glance in that directory, but I would not read all of them.
So I would highly recommend to CC the maintainers/reviewers of the specific component. You can find them in MAINTAINERS at the root of the Xen repository. We also have script like scripts/get_maintainers.pl that can help you to find who to CC.
If you pass '-f <file>', it will output the maintainers of that file. You can also use the script with patch to find all the maintainers to CC.
Now back to the subject of the e-mail.
Quoted 11 lines
I am working on the violations of MISRA C:2012 Rule 8.10, whose headline says:
"An inline function shall be declared with the static storage class".For both ARM64 and
X86_64builds,
function_spin_lock_cb()defined inspinlock.cviolates the rule. Such function is declared inspinlock.hwithout
the inline function specifier: are there any reasons to do this? What about solving the violation by moving the function definition inspinlock.hand declaring it as static inline?
Jan answered it and sent a patch. So I will skip the reply for this one.
Quoted 3 lines
The same happens also for the function
handle_ro_raz()in the ARM64 build, declared intraps.hand defined intraps.c.
I looked at the history and it is not clear to me why the 'inline' was added at first. That said, I don't see any value to ask the compiler to inline (which it would be free to ignore) the function.
So I would suggest to send a patch to remove the 'inline'.
Best regards,
Signature · 1 line
Julien Grall
Quoted 32 lines · Julien Grall
(+ Bertrand and Stefano)
Quoted 1 line · Federico Serafini
Hello everyone,
Hi Federico,
Let me start with a tip to help reaching the maintainers and getting a more timely answer. Xen-devel has a large volume of e-mails (still less than Linux :)). So some of us will have filter to try to classify the e-mails received.
Commonly, all the e-mails where the person is in the CC/To list will go to the inbox. All the others will go a separate directory that may or may not be watched. Personally, I tend to glance in that directory, but I would not read all of them.
So I would highly recommend to CC the maintainers/reviewers of the specific component. You can find them in
MAINTAINERSat the root of the Xen repository. We also have script likescripts/get_maintainers.plthat can help you to find who to CC.If you pass '-f <file>', it will output the maintainers of that file. You can also use the script with patch to find all the maintainers to CC.
Now back to the subject of the e-mail.
Quoted 11 lines
I am working on the violations of MISRA C:2012 Rule 8.10, whose headline says:
"An inline function shall be declared with the static storage class".For both ARM64 and
X86_64builds,
function_spin_lock_cb()defined inspinlock.cviolates the rule. Such function is declared inspinlock.hwithout
the inline function specifier: are there any reasons to do this? What about solving the violation by moving the function definition inspinlock.hand declaring it as static inline?Jan answered it and sent a patch. So I will skip the reply for this one.
Quoted 1 line
Quoted 9 lines
Quoted 2 lines
The same happens also for the function
handle_ro_raz()in the ARM64 build, declared intraps.hand defined intraps.c.I looked at the history and it is not clear to me why the 'inline' was added at first. That said, I don't see any value to ask the compiler to inline (which it would be free to ignore) the function.
So I would suggest to send a patch to remove the 'inline'.
Best regards,
Thank you Julien, very helpful.