[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH V3 07/10] xen: re-define assign_pages and introduce assign_page


  • To: Penny Zheng <penny.zheng@xxxxxxx>, julien@xxxxxxx
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 19 Jul 2021 10:41:29 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Y275R2fWmI3oRSMRO9W7BLYHf1eDW1xwtRUm+FDLsk=; b=SnYM7gUrvGb078ecQyBb1IQNCHXmKVH0xdx5iILtNmLI7fE4pmYR28R65r+2jHyLTL8sUMZP0t5mx5yskN/YXGkdYSPeZaTj/YdnVsjkjBm7HdD5RyjTWvEKcHhDR02IQZp5RB5j3UXpOpelHAKcrZMgQgpHYstZigOiTP+QGxjM6fu6IH7Um0F20TcYyUtHPNcTcuYhyUY/zi7h+dBXQtIyaZpMIs7cQlrdftvIyUtJwaH8gXjaps1kfPBQJ2BpCSXwxel92zDW9tgIIskc7/dlTkfwBGA437dm6qkLXT3OtlXluLhFw3IXV9Ia32A/hdfbydto678D/zc55u0SqQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UYHlHz01rv8Ly10XfrQUB83o/Q4mybDj1ja9fKvUin+qDqMx3wFOpzeNsTaedh1xjPWD9JcDkyqXzQGtaa4y4xnRko5wd5/OyHkNSJRytXE6SZcF8HEX0zmbInhCdXmCOY4dDbMinN9WXTZSil322YFCGJ1arAIJ5XPWQpkEz97nkhD4eOeutm4Yo243gKrUEgOUBEurHHkKCfUeWbcMrLlKlZ+t4fKNJyZfjkoBotE9zMd9Ibp91vWvIrvI0U1QDJ2BQXChv1duawp48uKDGevb2JDVV+4EhnBQbqNtn1d2ptMy9Jvo6QiEjhOhimLhx6pSK766ZGOze1uM2eiyLg==
  • Authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=suse.com;
  • Cc: Bertrand.Marquis@xxxxxxx, Wei.Chen@xxxxxxx, nd@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx
  • Delivery-date: Mon, 19 Jul 2021 08:41:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.07.2021 07:18, Penny Zheng wrote:
> In order to deal with the trouble of count-to-order conversion when page 
> number
> is not in a power-of-two, this commit re-define assign_pages for nr pages and
> assign_page for original page with a single order.
> 
> Backporting confusion could be helped by altering the order of assign_pages
> parameters, such that the compiler would point out that adjustments at call
> sites are needed.

Back on the initial form of this patch Julien said:

"However, I think I would prefer if we introduce a new interface (maybe 
 assign_pages_nr()) rather than change the meaning of the field. This is 
 for two reasons:
    1) We limit the risk to make mistake when backporting a patch touch 
 assign_pages().
    2) Adding (1UL << order) for pretty much all the caller is not nice."

1) is taken care of here anyway (albeit see the remark below), and of the
callers only some would really need "1UL <<" added (others could simply
convert their literal 0 to literal 1). Julien - do you still think 2) is
pretty important to avoid at the, overall, 2 places that would be left?

> --- a/xen/arch/x86/pv/dom0_build.c
> +++ b/xen/arch/x86/pv/dom0_build.c
> @@ -556,7 +556,7 @@ int __init dom0_construct_pv(struct domain *d,
>          else
>          {
>              while ( count-- )
> -                if ( assign_pages(d, mfn_to_page(_mfn(mfn++)), 0, 0) )
> +                if ( assign_page(d, mfn_to_page(_mfn(mfn++)), 0, 0) )

I think in all cases where order-0 pages get passed, you'd rather want
to call assign_pages() directly (if, as per above, we'll keep both
functions in the first place).

> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -2283,8 +2283,8 @@ void init_domheap_pages(paddr_t ps, paddr_t pe)
>  
>  int assign_pages(
>      struct domain *d,
> +    unsigned long nr,
>      struct page_info *pg,
> -    unsigned int order,
>      unsigned int memflags)
>  {

I'm afraid I consider putting "nr" ahead of "pg" unusual (considering
the rest of our code base). How about

int assign_pages(
    struct page_info *pg,
    unsigned long nr,
    struct domain *d,
    unsigned int memflags)
{

?

> @@ -2354,6 +2354,11 @@ int assign_pages(
>      return rc;
>  }
>  
> +int assign_page(struct domain *d, struct page_info *pg, unsigned int order,
> +                unsigned int memflags)
> +{
> +    return assign_pages(d, (1UL << order), pg, memflags);

May I ask that you omit the unnecessary parentheses?

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.