* [PATCH] Supporting reading of system information from BIOS.
@ 2014-10-14 4:44 Rita Sinha
2014-10-14 8:15 ` Matt Wilson
2014-10-14 10:48 ` Andrew Cooper
0 siblings, 2 replies; 4+ messages in thread
From: Rita Sinha @ 2014-10-14 4:44 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper
This patch is in response to http://wiki.xenproject.org/wiki/Outreach_Program_Projects#CPU.2FRAM.2FPCI_diagram_tool project for applying to OPW-Round9.It adds support for reading system architecture information from BIOS rather than from sysfs and proc interfaces since in a virtualisation enviroment, some of this information is no longer accurate, particularly any information based around numbers of cpus.
---
dmidecode.pl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 dmidecode.pl
diff --git a/dmidecode.pl b/dmidecode.pl
new file mode 100644
index 0000000..76fdf78
--- /dev/null
+++ b/dmidecode.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+
+# dmidecode.pl - a script to read the system architecture information
+# directly from the BIOS. Only for Linux.
+#
+# Rita Sinha (rita.sinha89@gmail.com)
+# OPW Program-Round9
+# 14/10/14
+
+`id -u` == 0 || die "must be run as root";
+
+open(DmiFh, "/usr/sbin/dmidecode |") or
+ die "problem running dmidecode";
+$DmiNumProcs = 0;
+$DmiNumSockets = 0;
+while(<DmiFh>)
+ {
+ next unless /Central Processor/;
+ # We've found a processor (or at least a socket), keep going
+ while(<DmiFh>)
+ {
+ # Keep walking the dmidecode output to find out if
+ # the socket has a processor in it.
+ last if /^Handle/;
+ next unless /Status/;
+ $DmiNumSockets += 1;
+ /Populated/ and $DmiNumProcs += 1;
+ last;
+ }
+ }
+close DmiFh;
+
+open(CpuInfoFh, "/proc/cpuinfo") || die "failed to open /proc/cpuinfo!";
+$CpuInfoNumProcs = 0;
+while(<CpuInfoFh>)
+ {
+ next unless /^processor.*:/;
+ ($CpuInfoNumProcs) += (/^processor.*: (\d+)/);
+ }
+close CpuInfoFh;
+
+if ( $DmiNumProcs != $CpuInfoNumProcs )
+ {
+ print "Warning: dmidecode reports $DmiNumProcs processors, kernel reports $CpuInfoNumProcs processors.\n";
+ }
+
+if ( $DmiNumProcs != $DmiNumSockets )
+ {
+ print "Info: dmidecode reports $DmiNumSockets cpu sockets, but only $DmiNumProcs processors.\n";
+ }
+
--
1.8.3.1
The information contained in this electronic mail transmission
may be privileged and confidential, and therefore, protected
from disclosure. If you have received this communication in
error, please notify us immediately by replying to this
message and deleting it from your computer without copying
or disclosing it.
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Supporting reading of system information from BIOS.
2014-10-14 4:44 [PATCH] Supporting reading of system information from BIOS Rita Sinha
@ 2014-10-14 8:15 ` Matt Wilson
2014-10-14 8:43 ` Rita Sinha
2014-10-14 10:48 ` Andrew Cooper
1 sibling, 1 reply; 4+ messages in thread
From: Matt Wilson @ 2014-10-14 8:15 UTC (permalink / raw)
To: Rita Sinha; +Cc: Andrew Cooper, xen-devel
On Tue, Oct 14, 2014 at 10:14:07AM +0530, Rita Sinha wrote:
>
> This patch is in response to
> http://wiki.xenproject.org/wiki/Outreach_Program_Projects#CPU.2FRAM.2FPCI_diagram_tool
> project for applying to OPW-Round9.It adds support for reading
> system architecture information from BIOS rather than from sysfs and
> proc interfaces since in a virtualisation enviroment, some of this
> information is no longer accurate, particularly any information
> based around numbers of cpus.
Nice, thanks for taking this project on.
Have you considered implementing something that functions the same as
hwloc-gather-topology(1):
http://manpages.ubuntu.com/manpages/saucy/man1/hwloc-gather-topology.1.html
but instead of collecting information from /proc and /sys, it accesses
DMI and ACPI tables directly? This would let you reuse the existing
lstopo(1) command to display a graphical topology.
--msw
> ---
> dmidecode.pl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
> create mode 100644 dmidecode.pl
>
> diff --git a/dmidecode.pl b/dmidecode.pl
> new file mode 100644
> index 0000000..76fdf78
> --- /dev/null
> +++ b/dmidecode.pl
> @@ -0,0 +1,51 @@
> +#!/usr/bin/perl
> +
> +# dmidecode.pl - a script to read the system architecture information
> +# directly from the BIOS. Only for Linux.
> +#
> +# Rita Sinha (rita.sinha89@gmail.com)
> +# OPW Program-Round9
> +# 14/10/14
> +
> +`id -u` == 0 || die "must be run as root";
> +
> +open(DmiFh, "/usr/sbin/dmidecode |") or
> + die "problem running dmidecode";
> +$DmiNumProcs = 0;
> +$DmiNumSockets = 0;
> +while(<DmiFh>)
> + {
> + next unless /Central Processor/;
> + # We've found a processor (or at least a socket), keep going
> + while(<DmiFh>)
> + {
> + # Keep walking the dmidecode output to find out if
> + # the socket has a processor in it.
> + last if /^Handle/;
> + next unless /Status/;
> + $DmiNumSockets += 1;
> + /Populated/ and $DmiNumProcs += 1;
> + last;
> + }
> + }
> +close DmiFh;
> +
> +open(CpuInfoFh, "/proc/cpuinfo") || die "failed to open /proc/cpuinfo!";
> +$CpuInfoNumProcs = 0;
> +while(<CpuInfoFh>)
> + {
> + next unless /^processor.*:/;
> + ($CpuInfoNumProcs) += (/^processor.*: (\d+)/);
> + }
> +close CpuInfoFh;
> +
> +if ( $DmiNumProcs != $CpuInfoNumProcs )
> + {
> + print "Warning: dmidecode reports $DmiNumProcs processors, kernel reports $CpuInfoNumProcs processors.\n";
> + }
> +
> +if ( $DmiNumProcs != $DmiNumSockets )
> + {
> + print "Info: dmidecode reports $DmiNumSockets cpu sockets, but only $DmiNumProcs processors.\n";
> + }
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Supporting reading of system information from BIOS.
2014-10-14 8:15 ` Matt Wilson
@ 2014-10-14 8:43 ` Rita Sinha
0 siblings, 0 replies; 4+ messages in thread
From: Rita Sinha @ 2014-10-14 8:43 UTC (permalink / raw)
To: Matt Wilson; +Cc: Andrew Cooper, Xen-devel
Hi Matt,
Please find my response inline.
>
> Have you considered implementing something that functions the same as
> hwloc-gather-topology(1):
> http://manpages.ubuntu.com/manpages/saucy/man1/hwloc-gather-topology.1.html
>
> but instead of collecting information from /proc and /sys, it accesses
> DMI and ACPI tables directly? This would let you reuse the existing
> lstopo(1) command to display a graphical topology.
>
This patch is just to float my idea as to how I plan to implement this
project. It is open to any suggestions, ideas or queries from others
in the community.
Yes. Andrew and I have discussed that the hwloc method of
detection(reading the sysfs interface) for native linux is wrong and I
plan to reimplement it using DMI and ACPI tables data.
Regards,
Rita Sinha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Supporting reading of system information from BIOS.
2014-10-14 4:44 [PATCH] Supporting reading of system information from BIOS Rita Sinha
2014-10-14 8:15 ` Matt Wilson
@ 2014-10-14 10:48 ` Andrew Cooper
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2014-10-14 10:48 UTC (permalink / raw)
To: Rita Sinha, xen-devel
On 14/10/14 05:44, Rita Sinha wrote:
Thanks for having a stab at this. Some comments inline
> This patch is in response to http://wiki.xenproject.org/wiki/Outreach_Program_Projects#CPU.2FRAM.2FPCI_diagram_tool project for applying to OPW-Round9.It adds support for reading system architecture information from BIOS rather than from sysfs and proc interfaces since in a virtualisation enviroment, some of this information is no longer accurate, particularly any information based around numbers of cpus.
Would you mind formatting this to 80 columns wide?
Generally speaking, submission of patches need a Signed-off-by: tag.
> ---
> dmidecode.pl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
> create mode 100644 dmidecode.pl
>
> diff --git a/dmidecode.pl b/dmidecode.pl
> new file mode 100644
> index 0000000..76fdf78
> --- /dev/null
> +++ b/dmidecode.pl
> @@ -0,0 +1,51 @@
> +#!/usr/bin/perl
> +
> +# dmidecode.pl - a script to read the system architecture information
> +# directly from the BIOS. Only for Linux.
> +#
> +# Rita Sinha (rita.sinha89@gmail.com)
> +# OPW Program-Round9
> +# 14/10/14
> +
> +`id -u` == 0 || die "must be run as root";
> +
> +open(DmiFh, "/usr/sbin/dmidecode |") or
> + die "problem running dmidecode";
> +$DmiNumProcs = 0;
> +$DmiNumSockets = 0;
> +while(<DmiFh>)
> + {
> + next unless /Central Processor/;
> + # We've found a processor (or at least a socket), keep going
> + while(<DmiFh>)
> + {
> + # Keep walking the dmidecode output to find out if
> + # the socket has a processor in it.
> + last if /^Handle/;
> + next unless /Status/;
> + $DmiNumSockets += 1;
> + /Populated/ and $DmiNumProcs += 1;
> + last;
> + }
> + }
> +close DmiFh;
> +
> +open(CpuInfoFh, "/proc/cpuinfo") || die "failed to open /proc/cpuinfo!";
> +$CpuInfoNumProcs = 0;
> +while(<CpuInfoFh>)
> + {
> + next unless /^processor.*:/;
> + ($CpuInfoNumProcs) += (/^processor.*: (\d+)/);
> + }
> +close CpuInfoFh;
> +
> +if ( $DmiNumProcs != $CpuInfoNumProcs )
> + {
> + print "Warning: dmidecode reports $DmiNumProcs processors, kernel reports $CpuInfoNumProcs processors.\n";
> + }
> +
> +if ( $DmiNumProcs != $DmiNumSockets )
> + {
> + print "Info: dmidecode reports $DmiNumSockets cpu sockets, but only $DmiNumProcs processors.\n";
> + }
> +
Running this script in dom0 yields:
[root@fusebot ~]# ./dmidecode.pl
Warning: dmidecode reports 1 processors, kernel reports 4 processors.
This is a Xeon E3-1240 v3 system where dom0 has 4 vcpus.
Under Xen, each vcpu appears as a separate processor, which is why
/proc/cpuinfo and dmidecode disagree about the processor count. This
also goes to show that /proc/cpuinfo only sees the virtual layout, not
the physical layout.
I think it might be worth starting with a design of the first task we
discussed, including the indented source of the information to be used.
~Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-14 10:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-14 4:44 [PATCH] Supporting reading of system information from BIOS Rita Sinha
2014-10-14 8:15 ` Matt Wilson
2014-10-14 8:43 ` Rita Sinha
2014-10-14 10:48 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.