bootlin / training-materials

Bootlin embedded Linux and kernel training materials
https://bootlin.com/training/
Other
603 stars 179 forks source link

Tinysystem: cpuinfo more portable and better looking #202

Closed sysopch closed 1 year ago

sysopch commented 1 year ago

The cpuinfo cgi-script greps for the 'Processor' string; this does not seem to apply to all architecture (on x86_64 it does not work). Grepping for 'model name' seems to be more portable.

Also, having all CPUs on the same line is a little ugly, with the help of sed we can have a single CPU per line. It requires to add sed in busybox config. The initial space added before echoing the result of the pipeline helps in aligning the resulting output.

michaelopdenacker commented 1 year ago

Thanks for the suggestion. I wonder whether there's an easier way to get the CPU name, but I haven't found yet. How much size does "sed" add to BusyBox? Cheers

sysopch commented 1 year ago

sed is just 12kB according to menuconfig.

I had a quick look on google (even if I doubt I'd find anything you did not think of already ;) ), the low level tool is always parsing /proc/cpuinfo. We could probably do with a single more complex sed, but I am not sure it is worth: less readable and less instructive, IMHO.

michaelopdenacker commented 1 year ago

Before I apply these changes, do you agree to give us "public domain" usage rights for them, please? In this case, your name will be kept in the commit history, but we would like Bootlin to keep the ability to switch to a different license (or license version number) for these materials, or to give a license exception to a customer funding some improvements or customizations.

Louson commented 1 year ago

Hello, I'm just passing by, but can't you use a while loop instead of sed ?

cat /proc/cpuinfo | grep "model name" | while read line; do echo "${line}<p>"; done

sysopch commented 1 year ago

Before I apply these changes, do you agree to give us "public domain" usage rights for them, please? In this case, your name will be kept in the commit history, but we would like Bootlin to keep the ability to switch to a different license (or license version number) for these materials, or to give a license exception to a customer funding some improvements or customizations.

Sure, no problem, whatever license you think is appropriate.

sysopch commented 1 year ago

Hello, I'm just passing by, but can't you use a while loop instead of sed ?

cat /proc/cpuinfo | grep "model name" | while read line; do echo "${line}<p>"; done

actually, this should work and does not require sed, I'll revise the proposal

Thanks

michaelopdenacker commented 1 year ago

Thanks for the update! Could you just group the 2 commits into one? We don't need the intermediate use of "sed". Thanks again

sysopch commented 1 year ago

Ok, done. Did not think of it because "you don't rewrite history if you already pushed it", but I am sure it's ok in this case.

Cheers Aldo

michaelopdenacker commented 1 year ago

Merged, thanks!