18c2ecf20Sopenharmony_ci============================
28c2ecf20Sopenharmony_ciNUMA resource associativity
38c2ecf20Sopenharmony_ci============================
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ciAssociativity represents the groupings of the various platform resources into
68c2ecf20Sopenharmony_cidomains of substantially similar mean performance relative to resources outside
78c2ecf20Sopenharmony_ciof that domain. Resources subsets of a given domain that exhibit better
88c2ecf20Sopenharmony_ciperformance relative to each other than relative to other resources subsets
98c2ecf20Sopenharmony_ciare represented as being members of a sub-grouping domain. This performance
108c2ecf20Sopenharmony_cicharacteristic is presented in terms of NUMA node distance within the Linux kernel.
118c2ecf20Sopenharmony_ciFrom the platform view, these groups are also referred to as domains.
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciPAPR interface currently supports different ways of communicating these resource
148c2ecf20Sopenharmony_cigrouping details to the OS. These are referred to as Form 0, Form 1 and Form2
158c2ecf20Sopenharmony_ciassociativity grouping. Form 0 is the oldest format and is now considered deprecated.
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciHypervisor indicates the type/form of associativity used via "ibm,architecture-vec-5 property".
188c2ecf20Sopenharmony_ciBit 0 of byte 5 in the "ibm,architecture-vec-5" property indicates usage of Form 0 or Form 1.
198c2ecf20Sopenharmony_ciA value of 1 indicates the usage of Form 1 associativity. For Form 2 associativity
208c2ecf20Sopenharmony_cibit 2 of byte 5 in the "ibm,architecture-vec-5" property is used.
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciForm 0
238c2ecf20Sopenharmony_ci------
248c2ecf20Sopenharmony_ciForm 0 associativity supports only two NUMA distances (LOCAL and REMOTE).
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciForm 1
278c2ecf20Sopenharmony_ci------
288c2ecf20Sopenharmony_ciWith Form 1 a combination of ibm,associativity-reference-points, and ibm,associativity
298c2ecf20Sopenharmony_cidevice tree properties are used to determine the NUMA distance between resource groups/domains.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciThe “ibm,associativity” property contains a list of one or more numbers (domainID)
328c2ecf20Sopenharmony_cirepresenting the resource’s platform grouping domains.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciThe “ibm,associativity-reference-points” property contains a list of one or more numbers
358c2ecf20Sopenharmony_ci(domainID index) that represents the 1 based ordinal in the associativity lists.
368c2ecf20Sopenharmony_ciThe list of domainID indexes represents an increasing hierarchy of resource grouping.
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciex:
398c2ecf20Sopenharmony_ci{ primary domainID index, secondary domainID index, tertiary domainID index.. }
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciLinux kernel uses the domainID at the primary domainID index as the NUMA node id.
428c2ecf20Sopenharmony_ciLinux kernel computes NUMA distance between two domains by recursively comparing
438c2ecf20Sopenharmony_ciif they belong to the same higher-level domains. For mismatch at every higher
448c2ecf20Sopenharmony_cilevel of the resource group, the kernel doubles the NUMA distance between the
458c2ecf20Sopenharmony_cicomparing domains.
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciForm 2
488c2ecf20Sopenharmony_ci-------
498c2ecf20Sopenharmony_ciForm 2 associativity format adds separate device tree properties representing NUMA node distance
508c2ecf20Sopenharmony_cithereby making the node distance computation flexible. Form 2 also allows flexible primary
518c2ecf20Sopenharmony_cidomain numbering. With numa distance computation now detached from the index value in
528c2ecf20Sopenharmony_ci"ibm,associativity-reference-points" property, Form 2 allows a large number of primary domain
538c2ecf20Sopenharmony_ciids at the same domainID index representing resource groups of different performance/latency
548c2ecf20Sopenharmony_cicharacteristics.
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ciHypervisor indicates the usage of FORM2 associativity using bit 2 of byte 5 in the
578c2ecf20Sopenharmony_ci"ibm,architecture-vec-5" property.
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci"ibm,numa-lookup-index-table" property contains a list of one or more numbers representing
608c2ecf20Sopenharmony_cithe domainIDs present in the system. The offset of the domainID in this property is
618c2ecf20Sopenharmony_ciused as an index while computing numa distance information via "ibm,numa-distance-table".
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ciprop-encoded-array: The number N of the domainIDs encoded as with encode-int, followed by
648c2ecf20Sopenharmony_ciN domainID encoded as with encode-int
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciFor ex:
678c2ecf20Sopenharmony_ci"ibm,numa-lookup-index-table" =  {4, 0, 8, 250, 252}. The offset of domainID 8 (2) is used when
688c2ecf20Sopenharmony_cicomputing the distance of domain 8 from other domains present in the system. For the rest of
698c2ecf20Sopenharmony_cithis document, this offset will be referred to as domain distance offset.
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci"ibm,numa-distance-table" property contains a list of one or more numbers representing the NUMA
728c2ecf20Sopenharmony_cidistance between resource groups/domains present in the system.
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciprop-encoded-array: The number N of the distance values encoded as with encode-int, followed by
758c2ecf20Sopenharmony_ciN distance values encoded as with encode-bytes. The max distance value we could encode is 255.
768c2ecf20Sopenharmony_ciThe number N must be equal to the square of m where m is the number of domainIDs in the
778c2ecf20Sopenharmony_cinuma-lookup-index-table.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciFor ex:
808c2ecf20Sopenharmony_ciibm,numa-lookup-index-table = <3 0 8 40>;
818c2ecf20Sopenharmony_ciibm,numa-distace-table = <9>, /bits/ 8 < 10  20  80 20  10 160 80 160  10>;
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci::
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	  | 0    8   40
868c2ecf20Sopenharmony_ci	--|------------
878c2ecf20Sopenharmony_ci	  |
888c2ecf20Sopenharmony_ci	0 | 10   20  80
898c2ecf20Sopenharmony_ci	  |
908c2ecf20Sopenharmony_ci	8 | 20   10  160
918c2ecf20Sopenharmony_ci	  |
928c2ecf20Sopenharmony_ci	40| 80   160  10
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciA possible "ibm,associativity" property for resources in node 0, 8 and 40
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci{ 3, 6, 7, 0 }
978c2ecf20Sopenharmony_ci{ 3, 6, 9, 8 }
988c2ecf20Sopenharmony_ci{ 3, 6, 7, 40}
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ciWith "ibm,associativity-reference-points"  { 0x3 }
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci"ibm,lookup-index-table" helps in having a compact representation of distance matrix.
1038c2ecf20Sopenharmony_ciSince domainID can be sparse, the matrix of distances can also be effectively sparse.
1048c2ecf20Sopenharmony_ciWith "ibm,lookup-index-table" we can achieve a compact representation of
1058c2ecf20Sopenharmony_cidistance information.
106