From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.3 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,URIBL_BLOCKED, 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 60D7DC07E96 for ; Tue, 6 Jul 2021 09:59: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 09635619A0 for ; Tue, 6 Jul 2021 09:59:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09635619A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.150983.279105 (Exim 4.92) (envelope-from ) id 1m0hrX-0002D1-ED; Tue, 06 Jul 2021 09:59:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 150983.279105; Tue, 06 Jul 2021 09:59:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m0hrX-0002Cu-AA; Tue, 06 Jul 2021 09:59:31 +0000 Received: by outflank-mailman (input) for mailman id 150983; Tue, 06 Jul 2021 09:59:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m0hrW-0002Cg-3Y for xen-devel@lists.xenproject.org; Tue, 06 Jul 2021 09:59:30 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 60ed37f2-f6aa-477e-893b-832d121a948a; Tue, 06 Jul 2021 09:59:29 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2108.outbound.protection.outlook.com [104.47.18.108]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-9-1LOyhCd4OF2red7fDPWtNA-1; Tue, 06 Jul 2021 11:59:27 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4848.eurprd04.prod.outlook.com (2603:10a6:803:55::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.19; Tue, 6 Jul 2021 09:59:26 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::99d3:99cd:8adf:3eea]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::99d3:99cd:8adf:3eea%5]) with mapi id 15.20.4287.033; Tue, 6 Jul 2021 09:59:26 +0000 Received: from [10.156.60.236] (37.24.206.209) by PR0P264CA0111.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 09:59:25 +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: 60ed37f2-f6aa-477e-893b-832d121a948a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1625565568; 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=eltZ53WzeP6D32Cf1/FknSFJzekvUXZrLl6S5LDaCgM=; b=gvnobWSfkxIqzDYVYhlFhTaxZgfzsSSOyPcvKf9gTF8YPBlGlhE8ediBQwZr2BO5mOzGbO JL+Ye/p9MJrf4CNeSjBXKq1z13+SJjJ3u0mJTWW9kk2s2AAkCkAud5v2aIrHBi/fumope7 5Z9bB1FfPdrlXidyI7zO8WvmBbU91A0= X-MC-Unique: 1LOyhCd4OF2red7fDPWtNA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XAqVNqV6FnfnIjR/WkpjLWxTQ5JNoiMMWluXZP/4z1KZlrx4XTgdjutcff6AoBta6umLDCOJh4d21MR6lEQFaeDoiY7Ig0/Eg/q0jNszaHrxnW39QjyGxIPtPw1ojz9+dPNk1BoiSXm4BQVgFkF7umLtfRZGUio4Pyx+lBdMMDdPOrlXXW/NiGksyw5pS93JWn1mvfnE5bBbdObJJ1OOiPrlMFcZ2BkJ4grGY/fCywuCjd6F2NsGnCmN5bEpy1tPynLWIR7Cy3534UwcnKkFd2AAocKSyadoEKZaBx8seisiMMpp96FHSutvXV7fTa85YPeNbAXRzH/WvTYd6t6l0Q== 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=eltZ53WzeP6D32Cf1/FknSFJzekvUXZrLl6S5LDaCgM=; b=D9WsUrYgczfG7Cv5Lyv9d/cJhe7cYDHXByQAw0ML8Hr8/C/LVA+7lZIJpcwIVy0DXvxzbZRI729lyurskTRj2Ss/GQg+3t5q+9gxRDFYW8aXot88yDGkROhsS0baB+GE6OpbL9JToR6oEKoLgc3Zg/pAGCHxwJW08CJ0NZUEnq80sSHsgAs/CiR8OYltx4MzcIWucrjWyYz6fXz0KJDZbWKS2/JgKYGd3rC/bBghHOY/b+URrWdubhezGUxVSE5mbh5GQnkbEiZb0xB0gyxNseLyM1q3LquaXN4GTszpIh+IlPwimU1iTJ4H3+MCjCiQD2rovzWQTDP35+i11yXPgw== 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: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=suse.com; Subject: Re: [PATCH 6/9] xen/arm: introduce alloc_staticmem_pages and alloc_domstatic_pages To: Julien Grall Cc: Bertrand Marquis , Wei Chen , "xen-devel@lists.xenproject.org" , "sstabellini@kernel.org" , Penny Zheng References: <20210607024318.3988467-1-penny.zheng@arm.com> <20210607024318.3988467-7-penny.zheng@arm.com> From: Jan Beulich Message-ID: Date: Tue, 6 Jul 2021 11:59:24 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [37.24.206.209] X-ClientProxiedBy: PR0P264CA0111.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::27) 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: f74b8ba3-71f3-423a-3d5c-08d94064bccc X-MS-TrafficTypeDiagnostic: VI1PR04MB4848: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M82qvb0kUe+Y882982w3eV9GJw7DiBHucGRqxQJUHtI4M27UhAQrel1wfREqBJSurTf1DGP48cIlvcVLpH+11Hum9MlEoeoatph28l5JwxUOWWb72/3Xmr4Fx08O8d2eCqki/8ZZ6u3w1cUpFq65Hz6XkrxaAtW6yhj+7mHgL/ciTj2CGSbiXo/3n4ESqUSTcdRVuc9BOzUOM5+/jDMKx4MHxreftp5wHqEUVqrkKb3rO0scqIiEyO0fKSO/B2mZwl6BapyEeG1Oa0gJ5/8pHqdrr98bbyaFLsYEXNOgIAHSFtV0Ye2Zt4B0rrjC9wuOHcG5sYdCyZatBCi054/nC49DF++2EVuqK4KLDDNSnl3H7RX3lT6RebtWq2GfzLfDeIj0mn3g/D50h4q061RkLmYZaoLilLod/YxCVuo4H/5P1OfLgkVKct8791hwRxjUgOI0cxs6Weihu5PIk+xjKZrefnC/GjggmxrUsKUnn5bWDW8FMV0NRhkK10lGhaAWOuyZZO1Ts2MONnzp2OO5DsZytP4+HNQ+uRXAMz+BNbBNf/pOtG00x1IKJTsdmAMFsxKrAENNyJHsXLVMlCDczybUzZXSZ0Q4kKrMJ8EDWHGt2hxQ4Gwd8ljWIqcewc5vAH8SEcjWIk+RQKArwmo4rYrHyZVux567sft/NmvFwLqi2VbD369lMWLLAXxxXh6X/fpuPFGyr4TVOH4IlbhCAy+8KwJtOFHh+nE96LB30rk= 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:(396003)(39860400002)(136003)(376002)(346002)(366004)(16526019)(8936002)(31696002)(5660300002)(66946007)(66556008)(54906003)(53546011)(83380400001)(478600001)(66476007)(16576012)(36756003)(956004)(2616005)(186003)(316002)(38100700002)(31686004)(4326008)(86362001)(26005)(2906002)(6916009)(6486002)(8676002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X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1rN8BpOeZmNqkI4aTyfafK0PyOWM?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: f74b8ba3-71f3-423a-3d5c-08d94064bccc X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 09:59:25.9413 (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: CzORCWD7BuRMX9oZRXESyqWcsnmD7NxXy3SvvvPTgT2rYA7yQuqDioAa6XYN5o9tZYcy6BECnOW6sNcElb7W8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4848 On 06.07.2021 11:39, Julien Grall wrote: > Hi Jan & Penny, > > On 06/07/2021 07:53, Jan Beulich wrote: >> On 06.07.2021 07:58, Penny Zheng wrote: >>>> From: Jan Beulich >>>> Sent: Thursday, June 10, 2021 6:23 PM >>>> >>>> On 07.06.2021 04:43, Penny Zheng wrote: >>>>> --- a/xen/common/page_alloc.c >>>>> +++ b/xen/common/page_alloc.c >>>>> @@ -1065,6 +1065,75 @@ static struct page_info *alloc_heap_pages( >>>>> return pg; >>>>> } >>>>> >>>>> +#ifdef CONFIG_STATIC_ALLOCATION >>>>> +/* >>>>> + * Allocate nr_mfns contiguous pages, starting at #smfn, of static memory. >>>>> + * It is the equivalent of alloc_heap_pages for static memory */ >>>>> +static struct page_info *alloc_staticmem_pages(unsigned long nr_mfns, >>>>> + mfn_t smfn, >>>>> + unsigned int memflags) >>>>> +{ >>>>> + bool need_tlbflush = false; >>>>> + uint32_t tlbflush_timestamp = 0; >>>>> + unsigned long i; >>>>> + struct page_info *pg; >>>>> + >>>>> + /* For now, it only supports allocating at specified address. */ >>>>> + if ( !mfn_valid(smfn) || !nr_mfns ) >>>>> + { >>>>> + printk(XENLOG_ERR >>>>> + "Invalid %lu static memory starting at %"PRI_mfn"\n", >>>> >>>> Reading a log containing e.g. "Invalid 0 static memory starting at ..." I don't >>>> think I would recognize that the "0" is the count of pages. >>> >>> Sure. How about "try to allocate out of range page %"PRI_mfn"\n"? >> >> This still doesn't convey _both_ parts of the if() that would cause >> the log message to be issued. >> >>>>> + nr_mfns, mfn_x(smfn)); >>>>> + return NULL; >>>>> + } >>>>> + pg = mfn_to_page(smfn); >>>>> + >>>>> + for ( i = 0; i < nr_mfns; i++ ) >>>>> + { >>>>> + /* >>>>> + * Reference count must continuously be zero for free pages >>>>> + * of static memory(PGC_reserved). >>>>> + */ >>>>> + ASSERT(pg[i].count_info & PGC_reserved); >>>> >>>> What logic elsewhere guarantees that this will hold? ASSERT()s are to verify >>>> that assumptions are met. But I don't think you can sensibly assume the caller >>>> knows the range is reserved (and free), or else you could get away without any >>>> allocation function. >>> >>> The caller shall only call alloc_staticmem_pages when it knows range is reserved, >>> like, alloc_staticmem_pages is only called in the context of alloc_domstatic_pages >>> for now. >> >> If the caller knows the static ranges, this isn't really "allocation". >> I.e. I then question the need for "allocating" in the first place. > > We still need to setup the page so the reference counting works > properly. So can you clarify whether you are objecting on the name? If > yes, do you have a better suggestion? It's not the name alone but the disconnect between name and actual behavior. Note that here we've started from an ASSERT(), which is reasonable to have if the caller knows where static pages are, but which should be converted to an if() when talking about allocation (i.e. the caller may not have enough knowledge). If it's not really allocation, how about naming it "acquire" or "obtain" (and the config option perhaps STATIC_MEMORY)? Jan