Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3895C433F5 for ; Fri, 10 Sep 2021 11:08:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96710611B0 for ; Fri, 10 Sep 2021 11:08:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 96710611B0 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.184278.332869 (Exim 4.92) (envelope-from ) id 1mOeOQ-0006sP-1Y; Fri, 10 Sep 2021 11:08:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 184278.332869; Fri, 10 Sep 2021 11:08:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOeOP-0006sI-Sp; Fri, 10 Sep 2021 11:08:25 +0000 Received: by outflank-mailman (input) for mailman id 184278; Fri, 10 Sep 2021 11:08:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOeOO-0006sC-Cp for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 11:08:24 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e22acd82-c857-4bed-9850-3d65dd72e900; Fri, 10 Sep 2021 11:08:23 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2105.outbound.protection.outlook.com [104.47.18.105]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-13-WcJUBCybPsWRGO0-TsH9WQ-1; Fri, 10 Sep 2021 13:08:21 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4381.eurprd04.prod.outlook.com (2603:10a6:803:6d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.25; Fri, 10 Sep 2021 11:08:19 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4500.017; Fri, 10 Sep 2021 11:08:18 +0000 Received: from [10.156.60.236] (37.24.206.209) by PR0P264CA0176.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 11:08:18 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e22acd82-c857-4bed-9850-3d65dd72e900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1631272102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U6PaK6ivapCMzL9OJchzgrN1fvV7qgqf9f/WPfBEGH0=; b=AM5aj5Nyvh/GP9AfbpXfz2VK983abdbzlN0NNia0yPttvZmFWVokOnnhhfKkezb/FOIo8b +NU8ShaLzXnU/4C9ifqR+D0D3Pj1pe/Q4V5+dXQVDZ7KvckS64AAGekISxowj9UvniDuAm YqI6aBGQv2k6fL7XJ44e8d5YZlqzDjk= X-MC-Unique: WcJUBCybPsWRGO0-TsH9WQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CsBb6ve44klN8xjX5VmDG/WLTZSiQutOlvwYkjdHLMV2Bdggg+5k4Zb7MHnh0sj5sec7VijkXNyUp5lp/pl+L4R15nO717p0xsg1HCEm90IUr2mi7KuuCHxWnDso7nowHUA3oLw7/+OjPT6McjTBukP3MgQ9Yo0jKDmYd8Z75yyK9EYZESYD2gyeAykpLKO9/rLgYdbwtQJpKanixUQK6Etr7xmH2MiizDEv4Rxku/VjDwJlwx3Eb1WvqxYRftNpNbZe8jdWy2QV9SjSp4U8b8gorA2h1hu5H6+jflHUwqfxT0NKaSDURVswBKVD4U51g4kKwuluWTQwpz5Q2O+7kg== 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; bh=U6PaK6ivapCMzL9OJchzgrN1fvV7qgqf9f/WPfBEGH0=; b=GZocYwOQqKX75sI8g9iC0i2RgsxxbY0SnvlK3WQUYndhXWpuBrN5RwNU27cN3FUjEEkjm1yToAkK0vInf7WN3BwP2RaU0v9bc5VReDWz3VpUKyb3yd+fQGkzAV3D91tZnNUqw1bePjsTdRJO/hsCcr2GFiGcuRd8G7xpDwx6CklLadZlqLrWNSijadyneR7bp9q8aw2BJz23LtlL9amq2sFVxhA+2dJSSjsemjrnVBPrGGMm64CDvsQdZTdsNiOMbcb58q58CmDNt5HTpOVX6JF4mfoK0p0MN5IQRpjZW2Djn2CelgNM4lgyxebDY7ec2WZ+7CHToO2qzymWlDZqGw== 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 Authentication-Results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com; Subject: Re: [PATCH v7 5/7] xen: re-define assign_pages and introduce a new function assign_page To: Penny Zheng Cc: Bertrand.Marquis@arm.com, Wei.Chen@arm.com, xen-devel@lists.xenproject.org, sstabellini@kernel.org, julien@xen.org References: <20210910025215.1671073-1-penny.zheng@arm.com> <20210910025215.1671073-6-penny.zheng@arm.com> From: Jan Beulich Message-ID: Date: Fri, 10 Sep 2021 13:08:16 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <20210910025215.1671073-6-penny.zheng@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PR0P264CA0176.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::20) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c66232eb-8728-4e6c-ed4c-08d9744b4b82 X-MS-TrafficTypeDiagnostic: VI1PR04MB4381: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R1BVq2hMwURoCE2gsHIifSYd4LVVO+lcdlnFTWBtLezkAwUyUwa8/klqpBJ/VdTPxrtncVug+p7GYWc/oGungdjWgeyZH/fVt/Ab2JN/pJEiKftN47ALX24y3fhsD7U+/2zcYlPYxUZAhUIftd5U7z07Ihin7gwVBkxui3wMbG9WkPY3u31qkrdl7Arv6D1MVFrKaA10X+f6L82fjATlmn+SYpAomF4UXqjncRdXjqr4P7ds9WdRE6tUdyi2oD52s1t7NWATRdTDHf+BMX2KpYVDgedXOkYY2qUgkJB337fpvzQV4Q+wpsUxOCNqiPvIn/esWjQgRLvd1GqV8PnBNqevj+buGm1HAUGfv5nJYvdziVc0c2oD6k8BLEuBAey4n2cUumeqhDZlUZ7Qw1CmFII8/Gk3Z4ykhYqI335fYG6UejWG3Yb52DyhhRnVOqtor+XXymZpmCZiNODJB1oygrMovzTQWrahDUP7kc2jla1Vvp5pzf2b0nifhkrqkm9K5nflfREyfYkrA8O/PFUUWW7mYGA2ak/N9pXiEHppjAv4pAej/0kYgxjPhflbbsVXIXA5I+StFhq39dDjZFZU78/5Zebn+rQRQtPxWC/W0kkSuaW511GEUZ+AExe1c4gmWfis/fIfmH4rny4/Lk0NUk2Xkm4RvUC9uzJYOF/80PKs51Efs0CjMFX+uo9sWD8RrAAhrBe7VyFOi7kBWga/pa9MRGnV2N1tGHyJO6PD2S4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(376002)(39860400002)(396003)(136003)(366004)(53546011)(31696002)(31686004)(316002)(2906002)(38100700002)(86362001)(956004)(478600001)(16576012)(2616005)(66946007)(36756003)(83380400001)(6486002)(26005)(66556008)(66476007)(6916009)(4326008)(5660300002)(186003)(8936002)(8676002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WndMRWFHVFNrTHFNZWQ5MWtp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: c66232eb-8728-4e6c-ed4c-08d9744b4b82 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 11:08:18.9095 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hMXPDzckw4CcM+ipQWghN2nPnZKBhvE+lk0hBVnVH4Mq8xMeUT/XR/fuPzNZ5TYojASrexqcWJg8valkk/y3ZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4381 On 10.09.2021 04:52, 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. Thanks, this now takes care of my primary concern. However, I (now?) have another (I thought I would have mentioned this before): > --- a/xen/common/page_alloc.c > +++ b/xen/common/page_alloc.c > @@ -2259,9 +2259,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) > > > int assign_pages( > - struct domain *d, > struct page_info *pg, > - unsigned int order, > + unsigned long nr, If this really is to be "unsigned long" (and not "unsigned int"), then... > @@ -2281,7 +2281,7 @@ int assign_pages( > { > unsigned int extra_pages = 0; > > - for ( i = 0; i < (1ul << order); i++ ) > + for ( i = 0; i < nr; i++ ) ... you will want to (a) show that there is a need for this in the remaining patches of this series and (b) prove that despite the remaining patches potentially using this, albeit at boot/init time only, there isn't any problem from ending up with 4 billion (or more) iteration loops that would then result. On x86 at least I'm sure this would be an issue. Otherwise I would request that in the subsequent patches requests be suitably broken up, with process_pending_softirqs() invoked in between. Which would get me back to my feeling that the original assign_pages() is quite good enough, as your new code would need to split requests now anyway (and to avoid the need for that splitting was the primary argument in favor of the change here). > @@ -2290,18 +2290,18 @@ int assign_pages( > > ASSERT(!extra_pages || > ((memflags & MEMF_no_refcount) && > - extra_pages == 1u << order)); > + extra_pages == nr)); > } > #endif > > if ( pg[0].count_info & PGC_extra ) > { > - d->extra_pages += 1u << order; > + d->extra_pages += nr; > memflags &= ~MEMF_no_refcount; > } > else if ( !(memflags & MEMF_no_refcount) ) > { > - unsigned int tot_pages = domain_tot_pages(d) + (1 << order); > + unsigned int tot_pages = domain_tot_pages(d) + nr; > > if ( unlikely(tot_pages > d->max_pages) ) > { > @@ -2313,10 +2313,10 @@ int assign_pages( > } > > if ( !(memflags & MEMF_no_refcount) && > - unlikely(domain_adjust_tot_pages(d, 1 << order) == (1 << order)) ) > + unlikely(domain_adjust_tot_pages(d, nr) == nr) ) > get_knownalive_domain(d); > > - for ( i = 0; i < (1 << order); i++ ) > + for ( i = 0; i < nr; i++ ) > { > ASSERT(page_get_owner(&pg[i]) == NULL); > page_set_owner(&pg[i], d); > @@ -2331,6 +2331,11 @@ int assign_pages( > return rc; > } > > +int assign_page(struct page_info *pg, unsigned int order, struct domain *d, > + unsigned int memflags) > +{ > + return assign_pages(pg, 1UL << order, d, memflags); > +} > > struct page_info *alloc_domheap_pages( > struct domain *d, unsigned int order, unsigned int memflags) > @@ -2373,7 +2378,7 @@ struct page_info *alloc_domheap_pages( > pg[i].count_info = PGC_extra; > } > } > - if ( assign_pages(d, pg, order, memflags) ) > + if ( assign_page(pg, order, d, memflags) ) Note that here, for example, order is necessarily no larger than MAX_ORDER. Jan