From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH v5 15/24] libxc: indentation change to xc_hvm_build_x86.c Date: Thu, 12 Feb 2015 19:44:45 +0000 Message-ID: <1423770294-9779-16-git-send-email-wei.liu2@citrix.com> References: <1423770294-9779-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423770294-9779-1-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Wei Liu , ian.campbell@citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, JBeulich@suse.com, ufimtseva@gmail.com List-Id: xen-devel@lists.xenproject.org Move a while loop in xc_hvm_build_x86 one block to the right. No functional change introduced. Functional changes will be introduced in next patch. Signed-off-by: Wei Liu Cc: Ian Campbell Cc: Ian Jackson Cc: Dario Faggioli Cc: Elena Ufimtseva Acked-by: Ian Campbell --- tools/libxc/xc_hvm_build_x86.c | 153 ++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 72 deletions(-) diff --git a/tools/libxc/xc_hvm_build_x86.c b/tools/libxc/xc_hvm_build_x86.c index c81a25b..ecc3224 100644 --- a/tools/libxc/xc_hvm_build_x86.c +++ b/tools/libxc/xc_hvm_build_x86.c @@ -353,98 +353,107 @@ static int setup_guest(xc_interface *xch, cur_pages = 0xc0; stat_normal_pages = 0xc0; - while ( (rc == 0) && (nr_pages > cur_pages) ) { - /* Clip count to maximum 1GB extent. */ - unsigned long count = nr_pages - cur_pages; - unsigned long max_pages = SUPERPAGE_1GB_NR_PFNS; - - if ( count > max_pages ) - count = max_pages; - - cur_pfn = page_array[cur_pages]; - - /* Take care the corner cases of super page tails */ - if ( ((cur_pfn & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && - (count > (-cur_pfn & (SUPERPAGE_1GB_NR_PFNS-1))) ) - count = -cur_pfn & (SUPERPAGE_1GB_NR_PFNS-1); - else if ( ((count & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && - (count > SUPERPAGE_1GB_NR_PFNS) ) - count &= ~(SUPERPAGE_1GB_NR_PFNS - 1); - - /* Attemp to allocate 1GB super page. Because in each pass we only - * allocate at most 1GB, we don't have to clip super page boundaries. - */ - if ( ((count | cur_pfn) & (SUPERPAGE_1GB_NR_PFNS - 1)) == 0 && - /* Check if there exists MMIO hole in the 1GB memory range */ - !check_mmio_hole(cur_pfn << PAGE_SHIFT, - SUPERPAGE_1GB_NR_PFNS << PAGE_SHIFT, - mmio_start, mmio_size) ) + while ( (rc == 0) && (nr_pages > cur_pages) ) { - long done; - unsigned long nr_extents = count >> SUPERPAGE_1GB_SHIFT; - xen_pfn_t sp_extents[nr_extents]; - - for ( i = 0; i < nr_extents; i++ ) - sp_extents[i] = page_array[cur_pages+(i< 0 ) - { - stat_1gb_pages += done; - done <<= SUPERPAGE_1GB_SHIFT; - cur_pages += done; - count -= done; - } - } + /* Clip count to maximum 1GB extent. */ + unsigned long count = nr_pages - cur_pages; + unsigned long max_pages = SUPERPAGE_1GB_NR_PFNS; - if ( count != 0 ) - { - /* Clip count to maximum 8MB extent. */ - max_pages = SUPERPAGE_2MB_NR_PFNS * 4; if ( count > max_pages ) count = max_pages; - - /* Clip partial superpage extents to superpage boundaries. */ - if ( ((cur_pfn & (SUPERPAGE_2MB_NR_PFNS-1)) != 0) && - (count > (-cur_pfn & (SUPERPAGE_2MB_NR_PFNS-1))) ) - count = -cur_pfn & (SUPERPAGE_2MB_NR_PFNS-1); - else if ( ((count & (SUPERPAGE_2MB_NR_PFNS-1)) != 0) && - (count > SUPERPAGE_2MB_NR_PFNS) ) - count &= ~(SUPERPAGE_2MB_NR_PFNS - 1); /* clip non-s.p. tail */ - - /* Attempt to allocate superpage extents. */ - if ( ((count | cur_pfn) & (SUPERPAGE_2MB_NR_PFNS - 1)) == 0 ) + + cur_pfn = page_array[cur_pages]; + + /* Take care the corner cases of super page tails */ + if ( ((cur_pfn & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && + (count > (-cur_pfn & (SUPERPAGE_1GB_NR_PFNS-1))) ) + count = -cur_pfn & (SUPERPAGE_1GB_NR_PFNS-1); + else if ( ((count & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && + (count > SUPERPAGE_1GB_NR_PFNS) ) + count &= ~(SUPERPAGE_1GB_NR_PFNS - 1); + + /* Attemp to allocate 1GB super page. Because in each pass + * we only allocate at most 1GB, we don't have to clip + * super page boundaries. + */ + if ( ((count | cur_pfn) & (SUPERPAGE_1GB_NR_PFNS - 1)) == 0 && + /* Check if there exists MMIO hole in the 1GB memory + * range */ + !check_mmio_hole(cur_pfn << PAGE_SHIFT, + SUPERPAGE_1GB_NR_PFNS << PAGE_SHIFT, + mmio_start, mmio_size) ) { long done; - unsigned long nr_extents = count >> SUPERPAGE_2MB_SHIFT; + unsigned long nr_extents = count >> SUPERPAGE_1GB_SHIFT; xen_pfn_t sp_extents[nr_extents]; for ( i = 0; i < nr_extents; i++ ) - sp_extents[i] = page_array[cur_pages+(i< 0 ) { - stat_2mb_pages += done; - done <<= SUPERPAGE_2MB_SHIFT; + stat_1gb_pages += done; + done <<= SUPERPAGE_1GB_SHIFT; cur_pages += done; count -= done; } } - } - /* Fall back to 4kB extents. */ - if ( count != 0 ) - { - rc = xc_domain_populate_physmap_exact( - xch, dom, count, 0, pod_mode, &page_array[cur_pages]); - cur_pages += count; - stat_normal_pages += count; + if ( count != 0 ) + { + /* Clip count to maximum 8MB extent. */ + max_pages = SUPERPAGE_2MB_NR_PFNS * 4; + if ( count > max_pages ) + count = max_pages; + + /* Clip partial superpage extents to superpage + * boundaries. */ + if ( ((cur_pfn & (SUPERPAGE_2MB_NR_PFNS-1)) != 0) && + (count > (-cur_pfn & (SUPERPAGE_2MB_NR_PFNS-1))) ) + count = -cur_pfn & (SUPERPAGE_2MB_NR_PFNS-1); + else if ( ((count & (SUPERPAGE_2MB_NR_PFNS-1)) != 0) && + (count > SUPERPAGE_2MB_NR_PFNS) ) + count &= ~(SUPERPAGE_2MB_NR_PFNS - 1); /* clip non-s.p. tail */ + + /* Attempt to allocate superpage extents. */ + if ( ((count | cur_pfn) & (SUPERPAGE_2MB_NR_PFNS - 1)) == 0 ) + { + long done; + unsigned long nr_extents = count >> SUPERPAGE_2MB_SHIFT; + xen_pfn_t sp_extents[nr_extents]; + + for ( i = 0; i < nr_extents; i++ ) + sp_extents[i] = + page_array[cur_pages+(i< 0 ) + { + stat_2mb_pages += done; + done <<= SUPERPAGE_2MB_SHIFT; + cur_pages += done; + count -= done; + } + } + } + + /* Fall back to 4kB extents. */ + if ( count != 0 ) + { + rc = xc_domain_populate_physmap_exact( + xch, dom, count, 0, pod_mode, &page_array[cur_pages]); + cur_pages += count; + stat_normal_pages += count; + } } } -- 1.9.1