* [PATCH] memory: polish populate_physmap()
@ 2015-09-22 12:50 Jan Beulich
2015-09-22 14:13 ` Andrew Cooper
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2015-09-22 12:50 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Campbell, Keir Fraser, Ian Jackson, Tim Deegan
[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]
Adjust types, avoid a NULL check for a case where it's not needed, and
simplify setting a variable on the alternative path.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -92,7 +92,7 @@ static void increase_reservation(struct
static void populate_physmap(struct memop_args *a)
{
struct page_info *page;
- unsigned long i, j;
+ unsigned int i, j;
xen_pfn_t gpfn, mfn;
struct domain *d = a->domain;
@@ -147,27 +147,31 @@ static void populate_physmap(struct memo
put_page(page);
}
- page = mfn_to_page(gpfn);
+ mfn = gpfn;
+ page = mfn_to_page(mfn);
}
else
+ {
page = alloc_domheap_pages(d, a->extent_order, a->memflags);
- if ( unlikely(page == NULL) )
- {
- if ( !opt_tmem || (a->extent_order != 0) )
- gdprintk(XENLOG_INFO, "Could not allocate order=%d extent:"
- " id=%d memflags=%x (%ld of %d)\n",
- a->extent_order, d->domain_id, a->memflags,
- i, a->nr_extents);
- goto out;
+ if ( unlikely(!page) )
+ {
+ if ( !opt_tmem || a->extent_order )
+ gdprintk(XENLOG_INFO,
+ "Could not allocate order=%u extent: id=%d memflags=%#x (%u of %u)\n",
+ a->extent_order, d->domain_id, a->memflags,
+ i, a->nr_extents);
+ goto out;
+ }
+
+ mfn = page_to_mfn(page);
}
- mfn = page_to_mfn(page);
guest_physmap_add_page(d, gpfn, mfn, a->extent_order);
if ( !paging_mode_translate(d) )
{
- for ( j = 0; j < (1 << a->extent_order); j++ )
+ for ( j = 0; j < (1U << a->extent_order); j++ )
set_gpfn_from_mfn(mfn + j, gpfn + j);
/* Inform the domain of the new page's machine address. */
[-- Attachment #2: populate-physmap-cleanup.patch --]
[-- Type: text/plain, Size: 2301 bytes --]
memory: polish populate_physmap()
Adjust types, avoid a NULL check for a case where it's not needed, and
simplify setting a variable on the alternative path.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -92,7 +92,7 @@ static void increase_reservation(struct
static void populate_physmap(struct memop_args *a)
{
struct page_info *page;
- unsigned long i, j;
+ unsigned int i, j;
xen_pfn_t gpfn, mfn;
struct domain *d = a->domain;
@@ -147,27 +147,31 @@ static void populate_physmap(struct memo
put_page(page);
}
- page = mfn_to_page(gpfn);
+ mfn = gpfn;
+ page = mfn_to_page(mfn);
}
else
+ {
page = alloc_domheap_pages(d, a->extent_order, a->memflags);
- if ( unlikely(page == NULL) )
- {
- if ( !opt_tmem || (a->extent_order != 0) )
- gdprintk(XENLOG_INFO, "Could not allocate order=%d extent:"
- " id=%d memflags=%x (%ld of %d)\n",
- a->extent_order, d->domain_id, a->memflags,
- i, a->nr_extents);
- goto out;
+ if ( unlikely(!page) )
+ {
+ if ( !opt_tmem || a->extent_order )
+ gdprintk(XENLOG_INFO,
+ "Could not allocate order=%u extent: id=%d memflags=%#x (%u of %u)\n",
+ a->extent_order, d->domain_id, a->memflags,
+ i, a->nr_extents);
+ goto out;
+ }
+
+ mfn = page_to_mfn(page);
}
- mfn = page_to_mfn(page);
guest_physmap_add_page(d, gpfn, mfn, a->extent_order);
if ( !paging_mode_translate(d) )
{
- for ( j = 0; j < (1 << a->extent_order); j++ )
+ for ( j = 0; j < (1U << a->extent_order); j++ )
set_gpfn_from_mfn(mfn + j, gpfn + j);
/* Inform the domain of the new page's machine address. */
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memory: polish populate_physmap()
2015-09-22 12:50 [PATCH] memory: polish populate_physmap() Jan Beulich
@ 2015-09-22 14:13 ` Andrew Cooper
2015-09-22 14:35 ` Ian Campbell
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2015-09-22 14:13 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Ian Campbell, Ian Jackson, Keir Fraser, Tim Deegan
On 22/09/15 13:50, Jan Beulich wrote:
> Adjust types, avoid a NULL check for a case where it's not needed, and
> simplify setting a variable on the alternative path.
>
> Signed-off-by: Jan Beulich<jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memory: polish populate_physmap()
2015-09-22 14:13 ` Andrew Cooper
@ 2015-09-22 14:35 ` Ian Campbell
0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2015-09-22 14:35 UTC (permalink / raw)
To: Andrew Cooper, Jan Beulich, xen-devel
Cc: Ian Jackson, Keir Fraser, Tim Deegan
On Tue, 2015-09-22 at 15:13 +0100, Andrew Cooper wrote:
> On 22/09/15 13:50, Jan Beulich wrote:
> > Adjust types, avoid a NULL check for a case where it's not needed, and
> > simplify setting a variable on the alternative path.
> >
> > Signed-off-by: Jan Beulich<jbeulich@suse.com>
>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-22 14:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-22 12:50 [PATCH] memory: polish populate_physmap() Jan Beulich
2015-09-22 14:13 ` Andrew Cooper
2015-09-22 14:35 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).