diff mbox

[Xen-devel,for-4.5,v3,2/3] xen: add helpers for PDX mask initialisation calculations

Message ID 1410988863-15238-2-git-send-email-ian.campbell@citrix.com
State New
Headers show

Commit Message

Ian Campbell Sept. 17, 2014, 9:21 p.m. UTC
I wanted to make fill_mask a public function so I could use it on ARM, but it
was actually easier to think of a (semi) reasonable public name for the users
of it, so that is what I have done.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
---
v3: New patch
---
 xen/arch/x86/srat.c   |   16 +++-------------
 xen/common/pdx.c      |   18 ++++++++++++++++++
 xen/include/xen/pdx.h |    3 +++
 3 files changed, 24 insertions(+), 13 deletions(-)

Comments

Jan Beulich Sept. 18, 2014, 10:03 a.m. UTC | #1
>>> On 17.09.14 at 23:21, <ian.campbell@citrix.com> wrote:
> I wanted to make fill_mask a public function so I could use it on ARM, but it
> was actually easier to think of a (semi) reasonable public name for the 
> users
> of it, so that is what I have done.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
Julien Grall Sept. 18, 2014, 7:16 p.m. UTC | #2
Hi Ian,

On 17/09/14 14:21, Ian Campbell wrote:
> +/* Sets all bits from the most-significant 1-bit down to the LSB */
> +static u64 __init fill_mask(u64 mask)
> +{
> +        while (mask & (mask + 1))
> +                mask |= mask + 1;
> +        return mask;
> +}
> +
> +u64 pdx_init_mask(u64 base_addr)


[..]

> +u64 pdx_region_mask(u64 base, u64 len)

fill_mask is marked as __init. For consistency, those 2 functions should 
be marked too.


Regards,
diff mbox

Patch

diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 2b05272..29fc724 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -339,13 +339,6 @@  void __init acpi_numa_arch_fixup(void) {}
 
 static u64 __initdata srat_region_mask;
 
-static u64 __init fill_mask(u64 mask)
-{
-	while (mask & (mask + 1))
-		mask |= mask + 1;
-	return mask;
-}
-
 static int __init srat_parse_region(struct acpi_subtable_header *header,
 				    const unsigned long end)
 {
@@ -366,8 +359,7 @@  static int __init srat_parse_region(struct acpi_subtable_header *header,
 		       ma->base_address, ma->base_address + ma->length - 1);
 
 	srat_region_mask |= ma->base_address |
-			    fill_mask(ma->base_address ^
-				      (ma->base_address + ma->length - 1));
+			    pdx_region_mask(ma->base_address, ma->length);
 
 	return 0;
 }
@@ -381,7 +373,7 @@  void __init srat_parse_regions(u64 addr)
 	    acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat))
 		return;
 
-	srat_region_mask = fill_mask(addr - 1);
+	srat_region_mask = pdx_init_mask(addr);
 	acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
 			      srat_parse_region, 0);
 
@@ -389,9 +381,7 @@  void __init srat_parse_regions(u64 addr)
 		if (e820.map[i].type != E820_RAM)
 			continue;
 
-		if (~mask &
-		    fill_mask(e820.map[i].addr ^
-			      (e820.map[i].addr + e820.map[i].size - 1)))
+		if (~mask & pdx_region_mask(e820.map[i].addr, e820.map[i].size))
 			mask = 0;
 	}
 
diff --git a/xen/common/pdx.c b/xen/common/pdx.c
index 11349a7..a9c326f 100644
--- a/xen/common/pdx.c
+++ b/xen/common/pdx.c
@@ -41,6 +41,24 @@  int __mfn_valid(unsigned long mfn)
                            pdx_group_valid));
 }
 
+/* Sets all bits from the most-significant 1-bit down to the LSB */
+static u64 __init fill_mask(u64 mask)
+{
+        while (mask & (mask + 1))
+                mask |= mask + 1;
+        return mask;
+}
+
+u64 pdx_init_mask(u64 base_addr)
+{
+	return fill_mask(base_addr - 1);
+}
+
+u64 pdx_region_mask(u64 base, u64 len)
+{
+	return fill_mask(base ^ (base + len - 1));
+}
+
 void set_pdx_range(unsigned long smfn, unsigned long emfn)
 {
     unsigned long idx, eidx;
diff --git a/xen/include/xen/pdx.h b/xen/include/xen/pdx.h
index 624f04f..18fe8e5 100644
--- a/xen/include/xen/pdx.h
+++ b/xen/include/xen/pdx.h
@@ -13,6 +13,9 @@  extern unsigned long pfn_top_mask, ma_top_mask;
                          (sizeof(*frame_table) & -sizeof(*frame_table)))
 extern unsigned long pdx_group_valid[];
 
+extern u64 pdx_init_mask(u64 base_addr);
+extern u64 pdx_region_mask(u64 base, u64 len);
+
 extern void set_pdx_range(unsigned long smfn, unsigned long emfn);
 
 #define page_to_pdx(pg)  ((pg) - frame_table)