From patchwork Tue Feb 23 02:34:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099785 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=-17.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,PDS_BAD_THREAD_QP_64,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 548D9C433E6 for ; Tue, 23 Feb 2021 02:35:33 +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 1F1E1614A7 for ; Tue, 23 Feb 2021 02:35:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F1E1614A7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.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.88523.166515 (Exim 4.92) (envelope-from ) id 1lENXp-0004c4-Mk; Tue, 23 Feb 2021 02:35:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88523.166515; Tue, 23 Feb 2021 02:35: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 1lENXp-0004bu-GO; Tue, 23 Feb 2021 02:35:25 +0000 Received: by outflank-mailman (input) for mailman id 88523; Tue, 23 Feb 2021 02:35: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 1lENXn-00046u-VU for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:24 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 62d32df6-b2f3-471e-a2c2-450356ae1247; Tue, 23 Feb 2021 02:35:07 +0000 (UTC) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11N2QQxp004083; Tue, 23 Feb 2021 02:35:04 GMT Received: from eur01-db5-obe.outbound.protection.outlook.com (mail-db5eur01lp2052.outbound.protection.outlook.com [104.47.2.52]) by mx0b-0039f301.pphosted.com with ESMTP id 36vqte83qr-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:04 +0000 Received: from AM0PR03MB3508.eurprd03.prod.outlook.com (2603:10a6:208:4f::23) by AM0PR0302MB3235.eurprd03.prod.outlook.com (2603:10a6:208:a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.32; Tue, 23 Feb 2021 02:34:59 +0000 Received: from AM0PR03MB3508.eurprd03.prod.outlook.com ([fe80::a9a4:6122:8de2:64cb]) by AM0PR03MB3508.eurprd03.prod.outlook.com ([fe80::a9a4:6122:8de2:64cb%6]) with mapi id 15.20.3846.042; Tue, 23 Feb 2021 02:34:59 +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: 62d32df6-b2f3-471e-a2c2-450356ae1247 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BebwjZqHmfzIbjnBu/31UGt8bl9qKaqCFPPRLnE8/VERJllMVuTwKTV4XKObOhpubLOxfb1fi2ytVMhqpAjrEdyjEIpAG4MT8/fb0Aoe+p5NxhycZHm9Ucrg2j6YxnIAnww71q333AhjB1Ky+wyqdNXzSnoEr9QV5v9+hFr6pbjPKbT1BaXSb1qh/uZcfHx4HGKX9HeBDdqyJpLcnRHyF04yYPw3UOr7/y1S3/g1zyhG9V8NWsIdZYNtvpjsoLH+Q8gptxkK3FA4x0Uc7CdI5cjPnEve19hk6ZaNosFTqjevM1lgg4SYH+N3nvbZ/sYXJQoBOsyBFAXypfsgjVIsqw== 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=5zq9Qig5UFOKzlvYCb9mxH6RosiS9ZEQ9G2xfCdQj3A=; b=oXlgQq/rGZu34TqCZD2aVCFucXcRx68BoF3MKTdWtQUXSbKkZNJunVk1y9Sz8rSSRiX0wvF1KolC2FJ6tmJ5s9p+Jm5Co+o0szwht6JXkuY5/C0VjSPvQQHcRlztQNvx3lMnltDRsOaDU3jGyuWvGwPACWrVpW8TtvI88pAKdTJ94NWgEDjnNil4NObohnSfGG7WFqfMRXsgh2YAOR8Ej2PN1OOvycBY32hZns+YZnSrD++lZkewZcAD3eil+r3hJfn7Yb4bhX8BzD/hPEgr29kvCQhuu6m5Ny02DXFi4Mg8exkeYjIOSc51m1Ydro6Q4DQcehMVP08S5AY6SplDKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5zq9Qig5UFOKzlvYCb9mxH6RosiS9ZEQ9G2xfCdQj3A=; b=k0PFlVZZHn1Uii+1WoQpsR69DztX+xPyT7GEDmiuZ1ALJl/P21p1Cs7eLm7hru1+hDyblCt/EHOnMXclpmzhgwl7mDXQYjvjv5PEadsnb6n2W04f5iE0O5IVSGYQVqRr6Pwo0KEHqPyLf2UuUFnAxwrg8qo2sbw5yEpKeAyV1/Uy20MOxzQ13Sc0Z0d6Ym7nDTQcYshw16+lyzA87ZK/JySXRyIgeHaNI7gh+UgSL6BFCupHqQIYoyb2PI8QlB0RMVkxr+L63iCEzUiMIpNFPcN2kdOj8MxilTiHrFcw9DShDgy2Q/5OZYbpmR4Qv+xaduHGdUCKDtV4+VgoqmCcmA== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 10/10] [HACK] alloc pages: enable preemption early Thread-Topic: [RFC PATCH 10/10] [HACK] alloc pages: enable preemption early Thread-Index: AQHXCYx6WMhDzv7reECPf5h9r1HBJg== Date: Tue, 23 Feb 2021 02:34:58 +0000 Message-ID: <20210223023428.757694-11-volodymyr_babchuk@epam.com> References: <20210223023428.757694-1-volodymyr_babchuk@epam.com> In-Reply-To: <20210223023428.757694-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.1 authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=epam.com; x-originating-ip: [176.36.48.175] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 24b9de1c-03b7-41d5-6ed2-08d8d7a39d45 x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:568; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SgiB155XE+2+GFV59/hdiPfQHHXoeFTE3Dp7amd0ORH4nxiFYgMM0HWXqMKMbujRWOpUwSu3Y9f3OApJQicuGA9tMUHBCdC3kIUGYm68rRwSiG/j5UYezcWSPer1l97kaClq8MvndkENHDIfYYA1baWagxtNN47W6hKQxf2a0vJSLqb5RLenpAb6ovj608cCvSb+YdZGtQRvESI1zMcavZmz573FM9nqRwCsO4kJUKFFoyC1AIn8XolKFlFJJ+ko8NjLjw2jvBq7F0r5OpiRCoesS42l5ofM3hr4YAZPhz6KeHf/mtthPjI1+Vu3P1oTWlnlgBmALruxwNgY50Rs1wXAWKOqh/k7MGzzloFoqcsj+BZw30mrQ7mrEHidI+uTfPYfkyF/6OSfB+g8WJGdkrYJnMrmeN3FwPjc/wwbRXpnkQrRub6pzohNB+oyLtXankUckuyB9HitMJpO3UTX+eUVxVT4CfiGGcwwdaQbJVtxB8r49pxHOWrp54ugpv75cEYhZPOCk8Mr3dixeuFlpQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR03MB3508.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(366004)(136003)(39860400002)(346002)(376002)(316002)(6512007)(8936002)(8676002)(86362001)(2906002)(4326008)(478600001)(6486002)(186003)(54906003)(66556008)(55236004)(83380400001)(66446008)(66946007)(66476007)(64756008)(71200400001)(1076003)(2616005)(26005)(76116006)(6916009)(36756003)(5660300002)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?yo7jjSK2uVnzGBGQhMbXOJ0Gx?= =?iso-8859-1?q?5rTzA3Vs6KqGP/LT52jRShjBzbePqMWFoOY+nrECjzwE8uXt4WBqFOgXdIh4?= =?iso-8859-1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Fs1NMt+eXzotw5PrSf4s4GuCccK9qslO?= =?iso-8859-1?q?U3y0eGHhObWfuXnOvkiIaO0EVCEZg2KHSXpLdUWTKqKSB3hlULSK8nBxRAZE?= =?iso-8859-1?q?Jftv/6jhp2yNQNVGl/kQKkFYvwju108ft2A+ELIWeLSUP13XfaNMwXwzoE1m?= =?iso-8859-1?q?rzFqAWu4gOw8DLcrbD5JImW4kWEgVMYiTBIwTqiOToE+4BeZEJLYesOVbzIU?= =?iso-8859-1?q?IZ2tG9FIyDoEWS8pLG2H2HX/peBj3XDp6xMsXputCJMY9NEQO2C4rUraDRK8?= =?iso-8859-1?q?fWd6o233Uo9k2SC5Fns/mi1W3W4wkoAJvKWO9LX/yLAgTK03USCWlyo1fDE0?= =?iso-8859-1?q?uuNcS/89tutCWpgRUAVF+wWqwbb6E1xgkHpdSS6Vho3E8ik3Ysu2oRLBZgW0?= =?iso-8859-1?q?eJEoJZxytFOIbK6LGZXZQ=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR03MB3508.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24b9de1c-03b7-41d5-6ed2-08d8d7a39d45 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:58.8171 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lyxjbXsVOQ6j4vN5L4qb6JwXqqAtjkbTr3+tHbqzwLN+xLNh2hv1CMKie3ntlzuAkW0+2JQLiVlCbl/MBvY4N5gHDjaRlo8PdsCUOvhnkL0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0302MB3235 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 adultscore=0 bulkscore=0 clxscore=1015 mlxlogscore=822 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 This code moves spin_unlock() and rcu_unlock_domain() earlier in the code just to decrease time we spent with preemption disabled. Proper fix is to replace spinlocks with mutexes, but mutexes are not implemented yet. With this patch enabled, allocation huge number of pages (e.g. 1GB of RAM) does not leads to problems with latency in time-critical domains. Signed-off-by: Volodymyr Babchuk --- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 21 ++------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index 76b9f58478..73c175f64e 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1390,6 +1390,8 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) pv_shim_online_memory(args.nr_extents, args.extent_order); #endif + rcu_unlock_domain(d); + switch ( op ) { case XENMEM_increase_reservation: @@ -1403,8 +1405,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) break; } - rcu_unlock_domain(d); - rc = args.nr_done; if ( args.preempted ) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 1744e6faa5..43c2f5d6e0 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -996,6 +996,8 @@ static struct page_info *alloc_heap_pages( if ( d != NULL ) d->last_alloc_node = node; + spin_unlock(&heap_lock); + for ( i = 0; i < (1 << order); i++ ) { /* Reference count must continuously be zero for free pages. */ @@ -1025,8 +1027,6 @@ static struct page_info *alloc_heap_pages( } - spin_unlock(&heap_lock); - if ( first_dirty != INVALID_DIRTY_IDX || (scrub_debug && !(memflags & MEMF_no_scrub)) ) { @@ -2274,23 +2274,6 @@ int assign_pages( goto out; } -#ifndef NDEBUG - { - unsigned int extra_pages = 0; - - for ( i = 0; i < (1ul << order); i++ ) - { - ASSERT(!(pg[i].count_info & ~PGC_extra)); - if ( pg[i].count_info & PGC_extra ) - extra_pages++; - } - - ASSERT(!extra_pages || - ((memflags & MEMF_no_refcount) && - extra_pages == 1u << order)); - } -#endif - if ( pg[0].count_info & PGC_extra ) { d->extra_pages += 1u << order;