Hexagon-setup: Combine four seq_printf() calls into one call in show_cpuinfo()
Subsystems (2)
PATCH 1/1 Hexagon-setup: Combine four seq_printf() calls into one call in show_cpuinfo()
From: Markus Elfring <[email protected]>
Date: Fri, 21 Oct 2016 08:18:38 +0200
Some data were printed into a sequence by four separate function calls. Print the same data by a single function call instead.
This issue was detected by using the Coccinelle software.
--- arch/hexagon/kernel/setup.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
arch/hexagon/kernel/setup.c +8 -7
@@ -132,13 +132,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)if (!cpu_online (cpu))return 0 ;#endif - -seq_printf (m,"processor\t: %d\n" , cpu); -seq_printf (m,"model name\t: Hexagon Virtual Machine\n" ); -seq_printf (m,"BogoMips\t: %lu.%02lu\n" , - (loops_per_jiffy *HZ ) /500000 , - ((loops_per_jiffy *HZ ) /5000 ) %100 ); -seq_printf (m,"\n" ); +seq_printf (m, +"processor\t: %d\n" +"model name\t: Hexagon Virtual Machine\n" +"BogoMips\t: %lu.%02lu\n" +"\n" , + cpu, + (loops_per_jiffy *HZ ) /500000 , + ((loops_per_jiffy *HZ ) /5000 ) %100 );return 0 ; }
Signature · 1 line
2.10.1
Quoted 26 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 21 Oct 2016 08:18:38 +0200Some data were printed into a sequence by four separate function calls. Print the same data by a single function call instead.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/hexagon/kernel/setup.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)arch/hexagon/kernel/setup.c +0
-5@@ -132,13 +132,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)if (!cpu_online (cpu))return 0 ;#endif - -seq_printf (m,"processor\t: %d\n" , cpu); -seq_printf (m,"model name\t: Hexagon Virtual Machine\n" ); - seq_printf(m, "BogoMips\t: %lu.%02lu\n", - (loops_per_jiffy * HZ) / 500000,
arch/hexagon/kernel/setup.c static int show_cpuinfo(struct seq_file *m, void *v) · line 142
Quoted 10 lines
arch/hexagon/kernel/setup.c +8
-2- ((loops_per_jiffy * HZ) / 5000) % 100); -seq_printf (m,"\n" ); +seq_printf (m, +"processor\t: %d\n" +"model name\t: Hexagon Virtual Machine\n" +"BogoMips\t: %lu.%02lu\n" +"\n" , + cpu, + (loops_per_jiffy *HZ ) /500000 , + ((loops_per_jiffy *HZ ) /5000 ) %100 );
This looks completely pointless. It is harder to see how the arguments fit into the strings and it is harder to see where the strings end and the arguments begin.
julia
Quoted 11 lines
arch/hexagon/kernel/setup.c +0
-1return 0 ; } --2.10.1
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines
Quoted 14 lines
+++
b/arch/hexagon/kernel/setup.carch/hexagon/kernel/setup.c +2
-7@@ -132,13 +132,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)if (!cpu_online (cpu))return 0 ;#endif - -seq_printf (m,"processor\t: %d\n" , cpu); -seq_printf (m,"model name\t: Hexagon Virtual Machine\n" ); -seq_printf (m,"BogoMips\t: %lu.%02lu\n" , - (loops_per_jiffy *HZ ) /500000 , - ((loops_per_jiffy *HZ ) /5000 ) %100 ); -seq_printf (m,"\n" ); +seq_printf (m, + "processor\t: %d\n"
Quoted 8 lines
arch/hexagon/kernel/setup.c static int show_cpuinfo(struct seq_file *m, void *v) · line 142
Quoted 6 lines
arch/hexagon/kernel/setup.c +6
-0+"model name\t: Hexagon Virtual Machine\n" +"BogoMips\t: %lu.%02lu\n" +"\n" , + cpu, + (loops_per_jiffy *HZ ) /500000 , + ((loops_per_jiffy * HZ) / 5000) % 100);This looks completely pointless.
Thanks for your software development opinion in this use case.
Quoted 2 lines
It is harder to see how the arguments fit into the strings and it is harder to see where the strings end and the arguments begin.
Is it really so difficult to interpret the suggested construction of a single (and relatively small) format string?
Regards,
Markus
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
It is harder to see how the arguments fit into the strings and it is harder to see where the strings end and the arguments begin.
Is it really so difficult to interpret the suggested construction of a single (and relatively small) format string?
It's not so difficult, so much as it makes things worse. It's easier the way it originally was. It might be interesting to see if the compiler could be taught to collapse the function calls, but (a) this isn't performance critical, and (b) the number of bytes saved is really tiny. But at least if the compiler was doing the work, it would at least deal with it everywhere.
- Ted
Quoted 5 lines
Quoted 2 lines
Is it really so difficult to interpret the suggested construction of a single (and relatively small) format string?
It's not so difficult, so much as it makes things worse. It's easier the way it originally was.
Thanks for your view on this refactoring approach.
Quoted 2 lines
It might be interesting to see if the compiler could be taught to collapse the function calls,
How does this wish fit to your previous rejection?
Quoted 1 line
but (a) this isn't performance critical,
This can be.
Quoted 1 line
and (b) the number of bytes saved is really tiny.
I imagine that the corresponding code and data size reduction could be occasionally useful, couldn't it?
Quoted 2 lines
But at least if the compiler was doing the work, it would at least deal with it everywhere.
I would find such an optimisation possibility also nice.
Can it become acceptable to achieve a similar effect by the application of scripts for the semantic patch language in the meantime?
Regards,
Markus
Quoted 4 lines · SF Markus Elfring
Quoted 2 lines
but (a) this isn't performance critical,
This can be.
In this case, no, it really can't possibly be performance critical. If you can't see why, you have no business trying to send patches.
Quoted 4 lines
Quoted 1 line
and (b) the number of bytes saved is really tiny.
I imagine that the corresponding code and data size reduction could be occasionally useful, couldn't it?
Note that in some cases, attempts to shirnk the code by tiny amounts can actually, paradoxically, cause the code to actually *expand*. In any case, shrinking the kernel by 0.00015% really won't matter, since for no other reason, we round memory used to 4k pages.
So keeping the code easily readible is aslo a consideration that needs to be taken into acconut.
Quoted 7 lines
Quoted 2 lines
But at least if the compiler was doing the work, it would at least deal with it everywhere.
I would find such an optimisation possibility also nice.
Can it become acceptable to achieve a similar effect by the application of scripts for the semantic patch language in the meantime?
The problem with scripts like this is that they very clearly don't have any human judgement. And when the person using the scripts also doesn't seem to have good judgement, it's a real problem.
When the author of the semantic patch language is telling you to stand down, and you still want to try to argue for blind application of patches, we have a really big problem. Especially when some of your patches have actually introduced bugs.
- Ted
Am 21.10.2016 um 19:53 schrieb Theodore Ts'o:
Quoted 27 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
but (a) this isn't performance critical,
This can be.
In this case, no, it really can't possibly be performance critical. If you can't see why, you have no business trying to send patches.
Quoted 4 lines
Quoted 1 line
and (b) the number of bytes saved is really tiny.
I imagine that the corresponding code and data size reduction could be occasionally useful, couldn't it?
Note that in some cases, attempts to shirnk the code by tiny amounts can actually, paradoxically, cause the code to actually *expand*. In any case, shrinking the kernel by 0.00015% really won't matter, since for no other reason, we round memory used to 4k pages.
So keeping the code easily readible is aslo a consideration that needs to be taken into acconut.
Quoted 5 lines
Quoted 2 lines
But at least if the compiler was doing the work, it would at least deal with it everywhere.
I would find such an optimisation possibility also nice.
Quoted 8 lines
Quoted 2 lines
Can it become acceptable to achieve a similar effect by the application of scripts for the semantic patch language in the meantime?
The problem with scripts like this is that they very clearly don't have any human judgement. And when the person using the scripts also doesn't seem to have good judgement, it's a real problem.
When the author of the semantic patch language is telling you to stand down,
A collaboration evolved between Julia and me during the years where different software development opinions can be usual. There are eventually further opinions from Linux contributors like you.
Quoted 8 lines
and you still want to try to argue for blind application of patches,
we have a really big problem.
Especially when some of your patches have actually introduced bugs.- Ted
Quoted 1 line
When the author of the semantic patch language is telling you to stand down,
The collaboration evolved between Julia and me during the years somehow. Different software development opinions occur then as usual. Further opinions from contributors like you can eventually show variations between disagreement and acceptance.
Quoted 1 line
and you still want to try to argue for blind application of patches,
I guess that we have got different views about "blind" tries.
Quoted 1 line
we have a really big problem.
I hope that potential communication difficulties can still be resolved.
Quoted 1 line
Especially when some of your patches have actually introduced bugs.
I assume that these incidents could be clarified further, couldn't they?
Regards,
Markus
Richard Kuo
Acked-byI wrote it the original way precisely for readability; it's easier, at least to me, to read and modify the old way.
However, in my development version I happen to be printing a lot more stuff.
To test, I collapsed 18 of my seq_printf's into one call. That reduced the function size by a couple hundred bytes. (Didn't do anything for the final kernel size though.)
If it makes things better, even if only slightly, doesn't introduce bugs, and doesn't otherwise violate any other rules (correct me if I'm wrong), I would personally accept the minor readability tradeoff in this case.
Quoted 28 lines · SF Markus Elfring
Quoted 1 line
When the author of the semantic patch language is telling you to stand down,
The collaboration evolved between Julia and me during the years somehow. Different software development opinions occur then as usual. Further opinions from contributors like you can eventually show variations between disagreement and acceptance.
Quoted 1 line
and you still want to try to argue for blind application of patches,
I guess that we have got different views about "blind" tries.
Quoted 1 line
we have a really big problem.
I hope that potential communication difficulties can still be resolved.
Quoted 1 line
Especially when some of your patches have actually introduced bugs.
I assume that these incidents could be clarified further, couldn't they?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html