If a large const array or struct is on the stack, make it static const so that the data does not have to be populated on the stack each time a function is entered. I keep on finding these in the kernel.
Right -- it's a hint, but the expectation these days is that is must be read-only. Similar things were fixed for PPC recently https://lkml.org/lkml/2018/2/28/1409 …
-
-
Heh, expectation is not reality :-)
-
You can have const register declarations, that's legal C, but not many CPUs have read-only registers. Const is a misnomer, it does not mean it is constant, it means the compiler should warning if it is written to. const register int x = 1; x++; /* compiler picks this up */
-
Yup, I don't disagree -- but where it's _possible_, it should be done. There's no reason that a local const structure or array should live anywhere except in .rodata.
-
I agree too. The expectation is to do the "safe" thing. Just shoving auto const variables on the stack is sometimes more performance optimal because it's cache hot and still complies with the spec, so I guess maybe why it's done that way.
-
Can we throw Coccinelle at this?
-
I believe this has been done already.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.