Messages in this thread | | | From | Linus Torvalds <> | Date | Wed, 15 Nov 2017 09:27:07 -0800 | Subject | Re: [PATCH] x86: use cpufreq_quick_get() for /proc/cpuinfo "cpu MHz" again |
| |
On Tue, Nov 14, 2017 at 11:43 PM, Ingo Molnar <mingo@kernel.org> wrote: > > I also think that /proc/cpuinfo is a pretty bad interface for many uses - I > personally only very rarely need the cpuinfo of _all_ CPUs. > > We we should eventually have /proc/cpu/N/info or so, so that 99% of the times > cpuinfo is needed to report bugs we can do: > > cat /proc/cpu/0/info
I don't disagree in theory, and I used to enthusiastically support the "let's make one value per file" model.
But in practice it's a pain, and I no longer really think it's viable except for debugging.
As an example, I can do
cat /proc/cpuinfo | grep MHz
and get a nice overview of what's going on. If I were a system stat program, I'd do that too.
In contrast, tell me where in /sys something useful is?
Honestly, the /sys directory structure _looks_ much more organized, and it's lovely for some things, but it's a confusing jungle, and finding things there is a complete and utter pain.
Yes, you can get the same thing:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
but here's the deal: time that on your 120-core machine some day.
In other words, /proc/cpuinfo is not perfect. But the "let's split things out" really doesn't work either. It's worse. It _sounds_ good in theory, but it really really sucks.
I'm convinced that /sys is wonderful for management purposes. But no, this whole "we should have individual files" is often a huge huge mistake.
In fact, I think the current patch for CPU MHz shows exactly why /proc/cpuinfo is actually hugely superior to the crazy "one file per cpu" model: we could gather the statistics in parallel, all together, and make it be reasonable.
Again, try that "cat" example again, and time it.
(And yes, I also know that "cpu*/cpufreq" is a symlink, but the direct names are illogical, and no faster for me. Try it if you like:
time cat /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq > /dev/null
and then look at /proc/cpuinfo again, and realize how lovely that human-readable file actually is).
Linus
| |