Re: [Xen-devel] [PATCH 05/13] xen: simplify xen_set_identity_and_remap() by using global variables

2015-02-23 Thread Juergen Gross

On 02/19/2015 07:10 PM, David Vrabel wrote:



On 18/02/2015 06:51, Juergen Gross wrote:

xen_set_identity_and_remap() is used to prepare remapping of memory
conflicting with the E820 map. It is tracking the pfn where to remap
new memory via a local variable which is passed to a subfunction
which in turn returns the new value for that variable.

Additionally the targeted maximum pfn is passed as a parameter to
sub functions.

Simplify that construct by using just global variables in the
source for that purpose. This will make things simpler when we need
those values later, too.


I'm not convinced this actually simplifies anything.


Perhaps I should have emphasised the last sentence a bit more. I really
need the global variables when deferring the remap operation.

Juergen

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Xen-devel] [PATCH 05/13] xen: simplify xen_set_identity_and_remap() by using global variables

2015-02-23 Thread Juergen Gross

On 02/19/2015 07:10 PM, David Vrabel wrote:



On 18/02/2015 06:51, Juergen Gross wrote:

xen_set_identity_and_remap() is used to prepare remapping of memory
conflicting with the E820 map. It is tracking the pfn where to remap
new memory via a local variable which is passed to a subfunction
which in turn returns the new value for that variable.

Additionally the targeted maximum pfn is passed as a parameter to
sub functions.

Simplify that construct by using just global variables in the
source for that purpose. This will make things simpler when we need
those values later, too.


I'm not convinced this actually simplifies anything.


Perhaps I should have emphasised the last sentence a bit more. I really
need the global variables when deferring the remap operation.

Juergen

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Xen-devel] [PATCH 05/13] xen: simplify xen_set_identity_and_remap() by using global variables

2015-02-19 Thread David Vrabel



On 18/02/2015 06:51, Juergen Gross wrote:

xen_set_identity_and_remap() is used to prepare remapping of memory
conflicting with the E820 map. It is tracking the pfn where to remap
new memory via a local variable which is passed to a subfunction
which in turn returns the new value for that variable.

Additionally the targeted maximum pfn is passed as a parameter to
sub functions.

Simplify that construct by using just global variables in the
source for that purpose. This will make things simpler when we need
those values later, too.


I'm not convinced this actually simplifies anything.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Xen-devel] [PATCH 05/13] xen: simplify xen_set_identity_and_remap() by using global variables

2015-02-19 Thread David Vrabel



On 18/02/2015 06:51, Juergen Gross wrote:

xen_set_identity_and_remap() is used to prepare remapping of memory
conflicting with the E820 map. It is tracking the pfn where to remap
new memory via a local variable which is passed to a subfunction
which in turn returns the new value for that variable.

Additionally the targeted maximum pfn is passed as a parameter to
sub functions.

Simplify that construct by using just global variables in the
source for that purpose. This will make things simpler when we need
those values later, too.


I'm not convinced this actually simplifies anything.

David
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/13] xen: simplify xen_set_identity_and_remap() by using global variables

2015-02-17 Thread Juergen Gross
xen_set_identity_and_remap() is used to prepare remapping of memory
conflicting with the E820 map. It is tracking the pfn where to remap
new memory via a local variable which is passed to a subfunction
which in turn returns the new value for that variable.

Additionally the targeted maximum pfn is passed as a parameter to
sub functions.

Simplify that construct by using just global variables in the
source for that purpose. This will make things simpler when we need
those values later, too.

Signed-off-by: Juergen Gross 
---
 arch/x86/xen/setup.c | 63 +---
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index ab6c36e..0dda131 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -56,6 +56,9 @@ static struct {
 } xen_remap_buf __initdata __aligned(PAGE_SIZE);
 static unsigned long xen_remap_mfn __initdata = INVALID_P2M_ENTRY;
 
+static unsigned long xen_remap_pfn;
+static unsigned long xen_max_pfn;
+
 /* 
  * The maximum amount of extra memory compared to the base size.  The
  * main scaling factor is the size of struct page.  At extreme ratios
@@ -223,7 +226,7 @@ static int __init xen_free_mfn(unsigned long mfn)
  * as a fallback if the remapping fails.
  */
 static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn,
-   unsigned long end_pfn, unsigned long nr_pages, unsigned long *released)
+   unsigned long end_pfn, unsigned long *released)
 {
unsigned long pfn, end;
int ret;
@@ -231,7 +234,7 @@ static void __init 
xen_set_identity_and_release_chunk(unsigned long start_pfn,
WARN_ON(start_pfn > end_pfn);
 
/* Release pages first. */
-   end = min(end_pfn, nr_pages);
+   end = min(end_pfn, xen_max_pfn);
for (pfn = start_pfn; pfn < end; pfn++) {
unsigned long mfn = pfn_to_mfn(pfn);
 
@@ -302,7 +305,7 @@ static void __init xen_update_mem_tables(unsigned long pfn, 
unsigned long mfn)
  * its callers.
  */
 static void __init xen_do_set_identity_and_remap_chunk(
-unsigned long start_pfn, unsigned long size, unsigned long remap_pfn)
+   unsigned long start_pfn, unsigned long size)
 {
unsigned long buf = (unsigned long)_remap_buf;
unsigned long mfn_save, mfn;
@@ -317,7 +320,7 @@ static void __init xen_do_set_identity_and_remap_chunk(
 
mfn_save = virt_to_mfn(buf);
 
-   for (ident_pfn_iter = start_pfn, remap_pfn_iter = remap_pfn;
+   for (ident_pfn_iter = start_pfn, remap_pfn_iter = xen_remap_pfn;
 ident_pfn_iter < ident_end_pfn;
 ident_pfn_iter += REMAP_SIZE, remap_pfn_iter += REMAP_SIZE) {
chunk = (left < REMAP_SIZE) ? left : REMAP_SIZE;
@@ -350,17 +353,16 @@ static void __init xen_do_set_identity_and_remap_chunk(
  * This function takes a contiguous pfn range that needs to be identity mapped
  * and:
  *
- *  1) Finds a new range of pfns to use to remap based on E820 and remap_pfn.
+ *  1) Finds a new range of pfns to use to remap based on E820 and
+ * xen_remap_pfn.
  *  2) Calls the do_ function to actually do the mapping/remapping work.
  *
  * The goal is to not allocate additional memory but to remap the existing
  * pages. In the case of an error the underlying memory is simply released back
  * to Xen and not remapped.
  */
-static unsigned long __init xen_set_identity_and_remap_chunk(
-   unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
-   unsigned long remap_pfn, unsigned long *released,
-   unsigned long *remapped)
+static void __init xen_set_identity_and_remap_chunk(unsigned long start_pfn,
+   unsigned long end_pfn, unsigned long *released, unsigned long *remapped)
 {
unsigned long pfn;
unsigned long i = 0;
@@ -373,30 +375,30 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
unsigned long remap_range_size;
 
/* Do not remap pages beyond the current allocation */
-   if (cur_pfn >= nr_pages) {
+   if (cur_pfn >= xen_max_pfn) {
/* Identity map remaining pages */
set_phys_range_identity(cur_pfn, cur_pfn + size);
break;
}
-   if (cur_pfn + size > nr_pages)
-   size = nr_pages - cur_pfn;
+   if (cur_pfn + size > xen_max_pfn)
+   size = xen_max_pfn - cur_pfn;
 
-   remap_range_size = xen_find_pfn_range(_pfn);
+   remap_range_size = xen_find_pfn_range(_remap_pfn);
if (!remap_range_size) {
pr_warning("Unable to find available pfn range, not 
remapping identity pages\n");
xen_set_identity_and_release_chunk(cur_pfn,
-   cur_pfn + left, nr_pages, released);
+  

[PATCH 05/13] xen: simplify xen_set_identity_and_remap() by using global variables

2015-02-17 Thread Juergen Gross
xen_set_identity_and_remap() is used to prepare remapping of memory
conflicting with the E820 map. It is tracking the pfn where to remap
new memory via a local variable which is passed to a subfunction
which in turn returns the new value for that variable.

Additionally the targeted maximum pfn is passed as a parameter to
sub functions.

Simplify that construct by using just global variables in the
source for that purpose. This will make things simpler when we need
those values later, too.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 arch/x86/xen/setup.c | 63 +---
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index ab6c36e..0dda131 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -56,6 +56,9 @@ static struct {
 } xen_remap_buf __initdata __aligned(PAGE_SIZE);
 static unsigned long xen_remap_mfn __initdata = INVALID_P2M_ENTRY;
 
+static unsigned long xen_remap_pfn;
+static unsigned long xen_max_pfn;
+
 /* 
  * The maximum amount of extra memory compared to the base size.  The
  * main scaling factor is the size of struct page.  At extreme ratios
@@ -223,7 +226,7 @@ static int __init xen_free_mfn(unsigned long mfn)
  * as a fallback if the remapping fails.
  */
 static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn,
-   unsigned long end_pfn, unsigned long nr_pages, unsigned long *released)
+   unsigned long end_pfn, unsigned long *released)
 {
unsigned long pfn, end;
int ret;
@@ -231,7 +234,7 @@ static void __init 
xen_set_identity_and_release_chunk(unsigned long start_pfn,
WARN_ON(start_pfn  end_pfn);
 
/* Release pages first. */
-   end = min(end_pfn, nr_pages);
+   end = min(end_pfn, xen_max_pfn);
for (pfn = start_pfn; pfn  end; pfn++) {
unsigned long mfn = pfn_to_mfn(pfn);
 
@@ -302,7 +305,7 @@ static void __init xen_update_mem_tables(unsigned long pfn, 
unsigned long mfn)
  * its callers.
  */
 static void __init xen_do_set_identity_and_remap_chunk(
-unsigned long start_pfn, unsigned long size, unsigned long remap_pfn)
+   unsigned long start_pfn, unsigned long size)
 {
unsigned long buf = (unsigned long)xen_remap_buf;
unsigned long mfn_save, mfn;
@@ -317,7 +320,7 @@ static void __init xen_do_set_identity_and_remap_chunk(
 
mfn_save = virt_to_mfn(buf);
 
-   for (ident_pfn_iter = start_pfn, remap_pfn_iter = remap_pfn;
+   for (ident_pfn_iter = start_pfn, remap_pfn_iter = xen_remap_pfn;
 ident_pfn_iter  ident_end_pfn;
 ident_pfn_iter += REMAP_SIZE, remap_pfn_iter += REMAP_SIZE) {
chunk = (left  REMAP_SIZE) ? left : REMAP_SIZE;
@@ -350,17 +353,16 @@ static void __init xen_do_set_identity_and_remap_chunk(
  * This function takes a contiguous pfn range that needs to be identity mapped
  * and:
  *
- *  1) Finds a new range of pfns to use to remap based on E820 and remap_pfn.
+ *  1) Finds a new range of pfns to use to remap based on E820 and
+ * xen_remap_pfn.
  *  2) Calls the do_ function to actually do the mapping/remapping work.
  *
  * The goal is to not allocate additional memory but to remap the existing
  * pages. In the case of an error the underlying memory is simply released back
  * to Xen and not remapped.
  */
-static unsigned long __init xen_set_identity_and_remap_chunk(
-   unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
-   unsigned long remap_pfn, unsigned long *released,
-   unsigned long *remapped)
+static void __init xen_set_identity_and_remap_chunk(unsigned long start_pfn,
+   unsigned long end_pfn, unsigned long *released, unsigned long *remapped)
 {
unsigned long pfn;
unsigned long i = 0;
@@ -373,30 +375,30 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
unsigned long remap_range_size;
 
/* Do not remap pages beyond the current allocation */
-   if (cur_pfn = nr_pages) {
+   if (cur_pfn = xen_max_pfn) {
/* Identity map remaining pages */
set_phys_range_identity(cur_pfn, cur_pfn + size);
break;
}
-   if (cur_pfn + size  nr_pages)
-   size = nr_pages - cur_pfn;
+   if (cur_pfn + size  xen_max_pfn)
+   size = xen_max_pfn - cur_pfn;
 
-   remap_range_size = xen_find_pfn_range(remap_pfn);
+   remap_range_size = xen_find_pfn_range(xen_remap_pfn);
if (!remap_range_size) {
pr_warning(Unable to find available pfn range, not 
remapping identity pages\n);
xen_set_identity_and_release_chunk(cur_pfn,
-   cur_pfn + left, nr_pages, released);
+