mh0rst / turionpowercontrol

Automatically exported from code.google.com/p/turionpowercontrol
9 stars 4 forks source link

Node/processor detection logic needs improvement #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run ./TurionPowerControl -l on a machine with dual-node CPU (eg. G34 Opteron)

What is the expected output? What do you see instead?
TPC appears to think that system has (nodes*cpus-per-package) cores
rather than (nodes*cpus-per-package/cpus-per-node) processors.
With dual-node processors, TPC tries to report status of twice
as many cores as there are in the system.

What version of the product are you using? On what operating system?
SVN rev 6

Please provide any additional information below.
Output attached.

Original issue reported on code.google.com by kszy...@gmail.com on 9 Apr 2011 at 11:41

Attachments:

GoogleCodeExporter commented 9 years ago
Err, (nodes*cpus-per-package/cpus-per-node) was meant to read: 
(nodes*cpus-per-package/nodes-per-package).

Original comment by kszy...@gmail.com on 9 Apr 2011 at 11:46

GoogleCodeExporter commented 9 years ago
Below is the code snippet I used with TPC 0.30 to perform the detection of 
nodes_per_package:

                /* discover number of nodes per processor */
                Cpuid(0x1,&eax,&ebx,&ecx,&edx);

                int model = (eax & 0xf0) >> 4;
                int modelExtended = ((eax & 0xf0000) >> 12) + model;
                int nodes_per_package = 1; /* default to 1 */

                if (modelExtended >= 8) {
                        ret = ReadPciConfigDwordEx(MISC_CONTROL_3, 0xe8, &val);
                        if (ret == TRUE) { 
                                if (val & (1 << 29)) {
                                        nodes_per_package = 2;
                                }
                        } else {
                                printf ("error discovering nodes per package, results may be unreliable\n");
                        }
                }

Original comment by kszy...@gmail.com on 9 Apr 2011 at 11:49

GoogleCodeExporter commented 9 years ago
I also checked values for F0x60 and F0x160 and they are (on a 48-core system):
F0x060: 0x000F0070
F0x160: 0x00010000
== they correspond to CpuCnt of 0x2Fh which translates to 48 on a revision D 
processor.

So I guess total number of processors could also be retrieved directly
rather than derived from values of total_nodes, cpus_per_package and 
nodes_per_package.

It seems answer to question posed in this comment:

                /* TODO: bugbug, physical cores is per processor or it is per system?
                I suppose that the physical cores variable
                should contain the number of cores per-node (or per-processor) and
                not the whole number of cores in the system.

is: "CpuCnt reflects total number of cores in the system."

Original comment by kszy...@gmail.com on 10 Apr 2011 at 12:33

GoogleCodeExporter commented 9 years ago
And just for the record -- CPUID 0x80000008 reflects total number of processors
in a package (regardless of number of nodes).

Original comment by kszy...@gmail.com on 10 Apr 2011 at 12:38

GoogleCodeExporter commented 9 years ago
Patch implementing "nodes per package" method attached and new output attached.

Original comment by kszy...@gmail.com on 10 Apr 2011 at 12:59

Attachments:

GoogleCodeExporter commented 9 years ago
diff source code has been merged!

Original comment by paolo.sa...@gmail.com on 10 Apr 2011 at 4:10