From patchwork Wed Feb 23 16:04:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12757165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6F41FC433F5 for ; Wed, 23 Feb 2022 16:04:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.277531.474069 (Exim 4.92) (envelope-from ) id 1nMu86-0007Wx-C0; Wed, 23 Feb 2022 16:04:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 277531.474069; Wed, 23 Feb 2022 16:04:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu86-0007Wq-8t; Wed, 23 Feb 2022 16:04:38 +0000 Received: by outflank-mailman (input) for mailman id 277531; Wed, 23 Feb 2022 16:04:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nMu85-00064O-10 for xen-devel@lists.xenproject.org; Wed, 23 Feb 2022 16:04:37 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4bee537c-94c2-11ec-8eb8-a37418f5ba1a; Wed, 23 Feb 2022 17:04:36 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2052.outbound.protection.outlook.com [104.47.13.52]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-16-ST5p_GrHNC20dxGWWejDcQ-1; Wed, 23 Feb 2022 17:04:34 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB3PR0402MB3803.eurprd04.prod.outlook.com (2603:10a6:8:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Wed, 23 Feb 2022 16:04:32 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.022; Wed, 23 Feb 2022 16:04:32 +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: 4bee537c-94c2-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645632275; 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=c0HTObp3YJHfE/uo6Cw54yUOSGjrcQcQ2DoP9QPbuT4=; b=MzfkmX9mSAA8fG2Kk7xA9vQkN+R+/1dd/a6dbeVWIocd11KNYQlfJv50+n6x2nGPB2iQaS BlWulrb7USHOhbe/6nuI6wFwJRTk/Cb2TEpZZJQ3IxW5Lbmw5EYJcab+UBnA//vc8vYMSz InFCN4BZ5+HaJSNI63ObtChHDphTA1s= X-MC-Unique: ST5p_GrHNC20dxGWWejDcQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DnoGcvjpGOCw2/KNiC75fZjWsUL6EVBZdVidcg6OXrpMjR44lVZovtzTBYIKe8ghYoVnMmA3c7b1APMJlZNiFfv6LhSYwfjdVhcP61Kp++sTrHh4DG0EVQOrXX/8A3MSGl14wEknZeDrKXrEPahNOCHBLdUTRqBDYkQG+CAs5ejclkpwMn1J6Wc0DwiXBtieTxjLj1Q1cR0I2mcEx6+PD+7OiKcSexznqA0mVw0JQBZN0NQU+c3/uanwatWsqjw8OmBg1FZq3aRymjdH8naLBbgB8t1xif/BQ2OXXOCqvvWb5tAoxFTXDaQqNslXcu6s+kCRr/cPuCnFinGKmRplPw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c0HTObp3YJHfE/uo6Cw54yUOSGjrcQcQ2DoP9QPbuT4=; b=WrDHh2h4pIv+lDQzuL9521foq7aOShXKvDvQQ7k0Lke7Fb5dLEQEoUJvjc0ymn6z7riHpgeQrvabgZ0YbeocnDEuJLG5rday55b6oyAR+TvUQV9rlsMr2o8myEIPzRX2znj8jdh69mOnuozb0fdNTWxKiJvMdfWu48HRus+3AgsycY7SttjmBs5yQIqkVyeDRgDYYoN1BQGbxcZZzl3YtgiF3hwBbyOiz0uJXinUFi9TVHa1IvrDtH3gdkhunC5sSuAkEQpwJdpbwD1C/mJE4eiOBsn1AATIEvmHFuogM77Fmq4EwRgAeH3Iv7cwWGc61HT0HP+jcDmRtJoIYrRY4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 23 Feb 2022 17:04:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 11/14] shr_pages field is MEM_SHARING-only Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu References: In-Reply-To: X-ClientProxiedBy: AM7PR02CA0012.eurprd02.prod.outlook.com (2603:10a6:20b:100::22) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e192341-4fe7-4004-4c74-08d9f6e62dec X-MS-TrafficTypeDiagnostic: DB3PR0402MB3803:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s6lpIxStBEmhwTnParHSK0fvUq/209veCbXgl6W7GoQzqCfpW7AHe/VqjoW++6twYKwiGnlO/8OThFbI1sCMj19BF+PVAMp0Cz4bpIrtxsp017m8cD4FlxJQa32yg3UWwbCy4O9/z4MsRDQjpyH06YJbHHSEN+35wRJAjur2GaoyALQTC+8OYmuUFHCkKPSGCoXtQANsMBNkrAmJYVJu43I5Aio/a1pJCUdLIn2qiwWl8EXt5rZgAbyjnoZSjivGxGSnn4FPDO5VdjNCoClG2wTLXWdAsYQMSkIQ2G1HKJtQDpwyh7X6UMGjErT/T1c7CMfJylF4K4Uycrclaux+lN2FAMhE1DQYsSODVWkN2zX0dVSFtihn7RyfD5Juj/YPvyDnQOjlZVjGseZ2fi59oiaEAwXr3Adrx2+oTZBLtQ5Uwq8Ols1mR5p0/u6/CBIMnXTS9U6LluenR6E0By9LyEz9YMvz1dbUaA4P29BRwt2Xh+PhfC97j33asvjiaKl+mtWnIOJx6iIthvfu6YXdkcoXNWS9+GCN5XoiwU1KUWXhGSuMIj3qPKXhGyz3hiv8r/eKhYwW/rcAeGarCHNjlKpUy4uKm/60yhlYkWqpeMWD4cItKaRWA/fqtTE26QVzLy1nrMIktf4xC3VyMFBB4cuzTTih8is6B7EdnuXOgXRLBxtW1GKnPEEvzXxRTOAW/90N1y8pRRC3kQwH9+/TzbFFD8nD/pMOQ7lTcB1eHF87hF1ObqhRUtmr8JdCzzMd 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:(13230001)(366004)(6512007)(66476007)(8676002)(6916009)(6506007)(31686004)(86362001)(8936002)(31696002)(6486002)(316002)(66556008)(508600001)(66946007)(26005)(5660300002)(36756003)(83380400001)(4326008)(38100700002)(186003)(2906002)(54906003)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VDz+C7ZTFbfQvEjUpvL6rECRC3W2?= =?utf-8?q?4jzY0qDXdN4on6/gRjYFsUGvGw2TGX+s0ziAntfPnMROyLJ7MfZZfs95ghqw5MVOx?= =?utf-8?q?KcV0MzAKx26a01jCKX9g1xZhIyJdsyvrS8UmoRy0WZxPWfYH/OlOcAUQtLvOGgb5b?= =?utf-8?q?aFPzdCH2xjePgpsvedwzeQhqAiKzlscnEauGh/CxLkhuqEOcaPximsz0ByfhU9u+/?= =?utf-8?q?1nsQxBkEjI9c/WaBi7h6S9PCWyGy0sptQIHkBa8NI26FlXNFhKNu+bs6DrFbqh79m?= =?utf-8?q?lLcwORW7chd+D9lUgEMDUyM5w+IYF8xKst+0E6kHnmZ2yG/LqC4RM+MqhruHp+7Ka?= =?utf-8?q?FQnTjSbCA3eebvahquGM6y3xs5ZA9QHCexX1MAI+KRz5a/vWmNheC6deA6AB14VZ0?= =?utf-8?q?BieyoId+ggJ4nm2gD1JE4t1R7TnEOeM4ieeYqJfPF/XtUAvon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GtDFLv9kNFYsLfr/U4B?= =?utf-8?q?DeKKjzeAb+ZPFcaaTjkamPjT7qY53tOJs9RlQRZ675OxMN3WhMDMdJFKfNMTjsWJY?= =?utf-8?q?aRfytif+yOfashMT7hSrhvU05UZlUx2UKdaQbVI/jwm7RlbjjHX2ZiGJOElNyg5su?= =?utf-8?q?e3C/agGu4thX+yXcuy4O05SyPM8NB+xVsiu7cpIPYpmNB0kbpua8i42xqfICnGATf?= =?utf-8?q?S+bUmZlruR1zVS5c19hMgjHQ9fAGyH8pMQOpuodnSObfiXDRXIcGwyg=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e192341-4fe7-4004-4c74-08d9f6e62dec X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:04:32.4413 (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: SFyDBtjzEiPkhQH2+gxfHn/6ZS3qcSPMmWf/RP3QWkaND0RL/lodLlhzTxqsOG/uMfOC2bNjJ5JHhfrzYszpqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3803 Conditionalize it and its uses accordingly. The main goal though is to demonstrate that x86's p2m_teardown() is now empty when !HVM, which in particular means the last remaining use of p2m_lock() in this cases goes away. Signed-off-by: Jan Beulich Reviewed-by: Tamas K Lengyel Reviewed-by: George Dunlap --- I was on the edge of introducing a helper for atomic_read(&d->shr_pages) but decided against because of dump_domains() not being able to use it sensibly (I really want to omit the output field altogether there when !MEM_SHARING). --- a/xen/arch/x86/mm/p2m-basic.c +++ b/xen/arch/x86/mm/p2m-basic.c @@ -159,7 +159,6 @@ void p2m_teardown(struct p2m_domain *p2m { #ifdef CONFIG_HVM struct page_info *pg; -#endif struct domain *d; if ( !p2m ) @@ -169,16 +168,17 @@ void p2m_teardown(struct p2m_domain *p2m p2m_lock(p2m); +#ifdef CONFIG_MEM_SHARING ASSERT(atomic_read(&d->shr_pages) == 0); +#endif -#ifdef CONFIG_HVM p2m->phys_table = pagetable_null(); while ( (pg = page_list_remove_head(&p2m->pages)) ) d->arch.paging.free_page(d, pg); -#endif p2m_unlock(p2m); +#endif } void p2m_final_teardown(struct domain *d) --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -109,7 +109,9 @@ void getdomaininfo(struct domain *d, str info->tot_pages = domain_tot_pages(d); info->max_pages = d->max_pages; info->outstanding_pages = d->outstanding_pages; +#ifdef CONFIG_MEM_SHARING info->shr_pages = atomic_read(&d->shr_pages); +#endif info->paged_pages = atomic_read(&d->paged_pages); info->shared_info_frame = gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info)))); --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -274,9 +274,16 @@ static void dump_domains(unsigned char k printk(" refcnt=%d dying=%d pause_count=%d\n", atomic_read(&d->refcnt), d->is_dying, atomic_read(&d->pause_count)); - printk(" nr_pages=%d xenheap_pages=%d shared_pages=%u paged_pages=%u " - "dirty_cpus={%*pbl} max_pages=%u\n", - domain_tot_pages(d), d->xenheap_pages, atomic_read(&d->shr_pages), + printk(" nr_pages=%u xenheap_pages=%u" +#ifdef CONFIG_MEM_SHARING + " shared_pages=%u" +#endif + " paged_pages=%u" + " dirty_cpus={%*pbl} max_pages=%u\n", + domain_tot_pages(d), d->xenheap_pages, +#ifdef CONFIG_MEM_SHARING + atomic_read(&d->shr_pages), +#endif atomic_read(&d->paged_pages), CPUMASK_PR(d->dirty_cpumask), d->max_pages); printk(" handle=%02x%02x%02x%02x-%02x%02x-%02x%02x-" --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -385,7 +385,11 @@ struct domain unsigned int outstanding_pages; /* pages claimed but not possessed */ unsigned int max_pages; /* maximum value for domain_tot_pages() */ unsigned int extra_pages; /* pages not included in domain_tot_pages() */ + +#ifdef CONFIG_MEM_SHARING atomic_t shr_pages; /* shared pages */ +#endif + atomic_t paged_pages; /* paged-out pages */ /* Scheduling. */