bogoMIPS value is changing

拈花ヽ惹草 提交于 2019-12-21 20:48:07

问题


I have been reading the cpuinfo file on my Samsung Galaxy (sgh-i897) to retrive the bogoMIPS value. And just now learning how to interpret such information.

Initially I did this under the main activity in a loading thread, and ALWAYS got a value of 997.59. I then moved the file reading method into a Service since I didn't need it in the UI until much later anyways. Once I did this, the value I read became quite different, and seems to change for each application start, always much slower, like in the 300 to 500 range.

My questions are:

  1. Does the Android OS / Linux cause a measurement of the bogoMIPS value and modify the cpuinfo file periodically?

  2. If so, is there a programatic way to force it?

  3. Why would it vary depending on if I am reading the file from a Service verses the main activity thread?

  4. Ultimately, if one wants the most correct number is it best to simply write our own timing loops to get it ourselves at the moment we need it? (assuming it's changing, due to cpu load, all the time anyhow?)


回答1:


Short answer: don't bother with BogoMIPS if you're not hacking the kernel.

What is this BogoMIPS thing?

Most tasks performed by an operating system kernel involve waiting for hardware, or more recently, processes running on other processor cores. The kernel has various methods to wait on different time scales. For the shortest periods of time, it will often simply 'run around in circles', more technically known as a "busy wait loop".

The BogoMIPS benchmark is just a busy wait loop. The kernel runs such a loop it, times it using a pretty reliable wall clock, and determines how long it needs to run a busy wait loop to wait for a specific amount of time.

Why does the BogoMIPS value change?

When a computer (smartphone, in this case) isn't performing a lot of work, it rarely has much need for a very fast processor. When the operating system notices it can do with less than the maximum frequency, it may throttle down the processor to a lower frequency. This is one of the ways the OS can reduce energy usage (relevant for battery-powered computers) and heat production (relevant for pretty much everything).

Of course, when the maximum frequency is lowered, the result of a BogoMIPS benchmark isn't relevant anymore, because every iteration in a busy wait loop will take longer. The kernel will rerun the benchmark and update the BogoMIPS value, so that busy waiting remains a reliable way of waiting for short periods of time.

Something similar holds when the need for processing rises, and the processor needs to be throttled up again.

How should I use this BogoMIPS value?

Unless you are hacking some part of the kernel that deals with timing, you shouldn't be bothered by the BogoMIPS value. In fact, you should use anything but the BogoMIPS value. There might be some way to determine the current CPU frequency using the Android SDK, or using information provided by /sys filesystem.




回答2:


You cannot force to change the bogoMIPs as that is rather temperamental under Android under the varying factors, initially at the start, (same as any other Linux kernel), the jiffies used on initial boot (arch/arm/boot/smp.c and arch/arm/boot/vmlinux.lds.S within the kernel source), is what determines the bogoMIPS (It is not to be taken for granted, that's partially the reason why its 'bogus' per se).

The factors that influences the skewing of the bogoMIPS is down to

  • How many services/widgets/apps running?
  • Is the CPU under/over-clocked? What frequency?
  • What sort of scheduler is in place (there's a few of them, deadline/ondemand/interactive to name but a few)
  • How is the kernel built? Is it optimized? What configuration used to build it?

The data used to "store" the value of the cpu's info is stored in the virtual directory created on boot within the /proc filesystem, it is there, visible and most, if not all, files in there are zero bytes and yet can read from it. It is created dynamically at boot time.



来源:https://stackoverflow.com/questions/11463448/bogomips-value-is-changing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!