|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2/8] x86/setup: Fix badpage= handling for memory above HYPERVISOR_VIRT_END
On 01.02.2020 01:32, David Woodhouse wrote:
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -1758,6 +1758,18 @@ int query_page_offline(mfn_t mfn, uint32_t *status)
> return 0;
> }
>
> +static unsigned long contig_avail_pages(struct page_info *pg, unsigned long
> max_pages)
> +{
> + unsigned long i;
> +
> + for ( i = 0 ; i < max_pages; i++)
Nit: Stray blank before first semicolon.
> + {
> + if ( pg[i].count_info & PGC_broken )
> + break;
> + }
> + return i;
Further nits: Commonly we omit the braces in cases like this one.
We also like to have blank lines before the main return statement
of a function.
> @@ -1846,6 +1863,63 @@ static unsigned long avail_heap_pages(
> return free_pages;
> }
>
> +static void mark_bad_pages(void)
__init please
> +{
> + unsigned long bad_spfn, bad_epfn;
> + const char *p;
> + struct page_info *pg;
> +#ifdef CONFIG_X86
> + const struct platform_bad_page *badpage;
> + unsigned int i, j, array_size;
> +
> + badpage = get_platform_badpages(&array_size);
> + if ( badpage )
> + {
> + for ( i = 0; i < array_size; i++ )
> + {
> + for ( j = 0; j < 1UL << badpage->order; j++ )
Either you mean badpage[i].* here and below, or you're missing an
increment of badpage somewhere.
> + {
> + if ( mfn_valid(_mfn(badpage->mfn + j)) )
> + {
> + pg = mfn_to_page(_mfn(badpage->mfn + j));
> + pg->count_info |= PGC_broken;
> + page_list_add_tail(pg, &page_broken_list);
> + }
> + }
> + }
> + }
> +#endif
> +
> + /* Check new pages against the bad-page list. */
> + p = opt_badpage;
> + while ( *p != '\0' )
> + {
> + bad_spfn = simple_strtoul(p, &p, 0);
> + bad_epfn = bad_spfn;
> +
> + if ( *p == '-' )
> + {
> + p++;
> + bad_epfn = simple_strtoul(p, &p, 0);
> + if ( bad_epfn < bad_spfn )
> + bad_epfn = bad_spfn;
> + }
> +
> + if ( *p == ',' )
> + p++;
> + else if ( *p != '\0' )
> + break;
I think this common (with init_boot_pages()) part of parsing
would better abstracted out, such there will be just one
instance of, and hence there's no risk of things going out of
sync.
> + while ( mfn_valid(_mfn(bad_spfn)) && bad_spfn < bad_epfn )
As per init_boot_pages() as well as per the "bad_epfn = bad_spfn;"
you have further up, the range here is inclusive at its end. I'm
also uncertain about the stopping at the first !mfn_valid() -
there may well be further valid pages later on.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |