From: Keir Fraser Subject: Re: Some Problems about Xen Numa support ! Date: Tue, 27 May 2008 08:36:31 +0100 Message-ID: References: <20080527005253.7929613681C@ncic.ac.cn> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0305873026==" Return-path: In-Reply-To: <20080527005253.7929613681C@ncic.ac.cn> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: =?GB2312?B?wO7Rx8ftIA==?= , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --===============0305873026== Content-type: multipart/alternative; boundary="B_3294722194_513817" > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3294722194_513817 Content-type: text/plain; charset="GB2312" Content-transfer-encoding: quoted-printable Probably Linux lets yuou specify NUMA topology on the command line, or something like that, and the loop you point out is inherited from that support. -- Keir On 27/5/08 02:02, "=C0=EE=D1=C7=C7=ED" wrote: > Hi=A3=ACAll > I am reading the concerned source code of Numa support in Xen so= urce > tree. I have been puzzled with the initialization of Numa support. During= the > initialization, the function =A1=AEacpi_scan_nodes=A1=AF is called to scan the > information about numa system. It converts some temporary variables into = final > variables, such as nodes -> node_data=A1=A3My puzzles locate in the last line= s of > this function: > int __init acpi_scan_nodes(u64 start, u64 end) > { > =A1=AD=A1=AD=A1=AD > /* Finally register nodes */ > for_each_node_mask(i, nodes_parsed) > setup_node_bootmem(i, nodes[i].start, nodes[i].end); > for (i =3D 0; i < NR_CPUS; i++) { > if (cpu_to_node[i] =3D=3D NUMA_NO_NODE) > continue; > if (!node_isset(cpu_to_node[i], nodes_parsed)) > numa_set_node(i, NUMA_NO_NODE); > } > numa_init_array(); > return 0; > } > According my study, the variable =A1=AEcpu_to_node=A1=AF has a unified > value=A1=AANUMA_NO_NODE before this codes being executed. So, the =A1=AEfor loop=A1= =AF will > have no effect. Is it correct? > The following function =A1=AEnuma_init_array=A1=AF will be called. Its source cod= e is > here: > void __init numa_init_array(void) > { > int rr, i; > /* There are unfortunately some poorly designed mainboards aroun= d > that only connect memory to a single CPU. This breaks the 1:1 > cpu->node > mapping. To avoid this fill in the mapping for all possible > CPUs, as the number of CPUs is not known yet. > We round robin the existing nodes. */ > rr =3D first_node(node_online_map); > for (i =3D 0; i < NR_CPUS; i++) { > if (cpu_to_node[i] !=3D NUMA_NO_NODE) > continue; > numa_set_node(i, rr); > rr =3D next_node(rr, node_online_map); > if (rr =3D=3D MAX_NUMNODES) > rr =3D first_node(node_online_map); > } > =20 > } > I don=A1=AFt understand why it is called here. I think it should be called af= ter > cpu_to_node being initialized with correct value. > Thanks a lot! > =20 > -Techie > =20 > =20 >=20 --B_3294722194_513817 Content-type: text/html; charset="GB2312" Content-transfer-encoding: quoted-printable Re: Some Problems about Xen Numa support=A3=A1 Proba= bly Linux lets yuou specify NUMA topology on the command line, or something = like that, and the loop you point out is inherited from that support.

 -- Keir

On 27/5/08 02:02, "=C0=EE=D1=C7=C7=ED" <liyaq04@ncic.ac.cn> wrote:

Hi=A3=ACAll
         I am reading the conc= erned source code of Numa support in Xen source tree. I have been puzzled wi= th the initialization of Numa support. During the initialization, the functi= on ‘acpi_scan_nodes’ is called to scan the information about num= a system. It converts some temporary variables into final variables, such as= nodes -> node_data
=A1=A3M= y puzzles locate in the last lines of this function:
int __init acpi_scan_nodes(u64 start, u64 end)
{
………
         /* Finally register n= odes */
         for_each_node_mask(i,= nodes_parsed)
            &nb= sp;     setup_node_bootmem(i, nodes[i].start, nodes= [i].end);
         for (i =3D 0; i < NR= _CPUS; i++) {
            &nb= sp;     if (cpu_to_node[i] =3D=3D NUMA_NO_NODE)
            &nb= sp;            &= nbsp; continue;
            &nb= sp;     if (!node_isset(cpu_to_node[i], nodes_parse= d))
            &nb= sp;            &= nbsp; numa_set_node(i, NUMA_NO_NODE);
         }
        numa_init_array();
        return 0;
}
According my study, the variable ‘cpu_to_node’ has a unified va= lue—NUMA_NO_NODE before this codes being executed. So, the ‘for = loop’ will have no effect. Is it correct?
The following function ‘numa_init_array’ will be called. Its so= urce code is here:
void __init numa_init_array(void)
{
         int rr, i;
         /* There are unfortun= ately some poorly designed mainboards around
           that only= connect memory to a single CPU. This breaks the 1:1 cpu->node
           mapping. = To avoid this fill in the mapping for all possible
           CPUs, as = the number of CPUs is not known yet.
           We round = robin the existing nodes. */
         rr =3D first_node(node_= online_map);
         for (i =3D 0; i < NR= _CPUS; i++) {
            &nb= sp;     if (cpu_to_node[i] !=3D NUMA_NO_NODE)
            &nb= sp;            &= nbsp; continue;
            &nb= sp;    numa_set_node(i, rr);
            &nb= sp;     rr =3D next_node(rr, node_online_map);
            &nb= sp;     if (rr =3D=3D MAX_NUMNODES)
            &nb= sp;            &= nbsp; rr =3D first_node(node_online_map);
         }
 
}
I don’t understand why it is called here. I think it should be called= after cpu_to_node being initialized with correct value.
Thanks a lot!
 
-Techie
 
 


--B_3294722194_513817-- --===============0305873026== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0305873026==--