From patchwork Tue Feb 23 02:34:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099781 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 562C1C4332D for ; Tue, 23 Feb 2021 02:35:28 +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 11DE3614A7 for ; Tue, 23 Feb 2021 02:35:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11DE3614A7 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.88514.166407 (Exim 4.92) (envelope-from ) id 1lENXU-000476-Ck; Tue, 23 Feb 2021 02:35:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88514.166407; Tue, 23 Feb 2021 02:35:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXU-00046z-7i; Tue, 23 Feb 2021 02:35:04 +0000 Received: by outflank-mailman (input) for mailman id 88514; Tue, 23 Feb 2021 02:35:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXS-00046p-Bv for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:02 +0000 Received: from mx0a-0039f301.pphosted.com (unknown [148.163.133.242]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f3dbc9a8-3a03-4c02-b139-eb8fd8326a0b; Tue, 23 Feb 2021 02:35:01 +0000 (UTC) Received: from pps.filterd (m0174677.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11N2PMaR026304; Tue, 23 Feb 2021 02:35:00 GMT Received: from eur01-ve1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2050.outbound.protection.outlook.com [104.47.1.50]) by mx0a-0039f301.pphosted.com with ESMTP id 36vq3kr64x-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:34:59 +0000 Received: from AM0PR03MB3508.eurprd03.prod.outlook.com (2603:10a6:208:4f::23) by AM0PR03MB4082.eurprd03.prod.outlook.com (2603:10a6:208:70::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Tue, 23 Feb 2021 02:34:55 +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:55 +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: f3dbc9a8-3a03-4c02-b139-eb8fd8326a0b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ILj3bBHfEiUMCREsS+BKq7fCjQJP3qdoZCtWoK1RvOke0nKZsj9S77E0THWkfH7X/rl8OAtEY0UtqaiuLZyJF6gFWqOg5U7w9Ta5vl4Fkq2B3uWsgJvq1XxEkHuOXladrGRvlvZB3+DTou36EuqCgkk8uy1Un9ceEsT42TYgw51vWUDJlQqYG2/Ke7J5Be24tQanuna8XhcDHk25geHyMTkCJwv2DhS51Yc0QCO9v3j+IaCnJXG4ob4C8Q9yf1t9O/+//HzPpRwxlPvs5IjDdbF98QiBjAsTv3gWoNHxo7LkJynfkc2TNLVYYLvyiTjr10FNnT7ib6Sxc5WFJZZqCw== 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=tpKHysdqPazW6fGzt3svNddiygNyG3avYaAeAhXrZRY=; b=lgf4la7IBw82a7bcvFzWNDtkjOTkd5BDBUGnCfEP8P0a5Mov8a1HfC+NiLd4yAQMqy+Ghvq9jzUobb450pwI35r2EfSUz5dJW0KvlLe72Tg+yfAkT+pZAT1xxnirQ7sKXfleocq3X3mmsG0r4MZHsCTVKVHYL7xgBNIQyj+FHjP0F1ke9Dd5HsA+CCemmrc9wEDVc50o0Ijqgp4c8k+H+3+lQ7SQIWYVcQCO63tOXtEsH7efNbFPA3XJAOZmRcYMjqO6fblYMGxwXAQP8OUU68hl1Qp6e6NX/FNUG+Vvpg5RSnu71hNB24TwvkXXeZ0Gmg5Tez+GeI0k3FAUt2kLPg== 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=tpKHysdqPazW6fGzt3svNddiygNyG3avYaAeAhXrZRY=; b=zUOwQBT3y4kV3dyNYL+NWdf5VDL3lvxv4B0e82dnHHq+5hNA+acXLBt8DaaQvhiNlYeTWaLzZ59zOBA5qx9ZkPl4aSksTCxneujqolLDDoqgH931PDwO0wmrfw+Cf2P0l1HZBYB/5B0N+rgTbWs7z/OuAMIzAPpHkjVol5raHaFartj4JJzQ/35JdpAwghmfsOVzigabqN//nthmzJ5ktsoipTInVe4e6+DugypuWvRYBPzJkHmJ9rl2jganMSU/n5BXRvYm2Fn01nncdmTcKL1gjY07wJuKfgtM3YmysDcImMvLfBqQMqIY1W3oXLqMN1VcvJ6OvlaB9Hc6nB2zSw== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , George Dunlap , Dario Faggioli Subject: [RFC PATCH 01/10] sched: core: save IRQ state during locking Thread-Topic: [RFC PATCH 01/10] sched: core: save IRQ state during locking Thread-Index: AQHXCYx4NBzFu5keaEOeI3LkFrTKiA== Date: Tue, 23 Feb 2021 02:34:55 +0000 Message-ID: <20210223023428.757694-2-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: cc0fc91f-ed67-49c5-104e-08d8d7a39b41 x-ms-traffictypediagnostic: AM0PR03MB4082: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:469; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lSyqVPhJG6ukJTGokHeu/8MBuWC6Stinw8mx64JPqDVitSHF07PuS5s/zi7WhQS7+w+Db2zGzX+Xofmqxa9l093vzejv/zzpse6f0axaGQABJ886ORbTMwrsrmHgMq6eJhAHu1RTdsXnEfrCSYOZhx0EVDRG+RySR0VAZ1OUbhemTolb6pY+JjSealz5kgOuk0MjqQGQFEl0v0oRF8QtwBJpMHkE8AV4tjTVmyjIp4iCagTvvdh2O8XClHzDUS5PKBL/0qxozpiFcVhN9EOBj3i6/5t3uakC7yHjgt3IE4dVwdnUM7hKaDOzcRWs+il8bnG6jT22qAUm9xVjW2u8HirTzZoCttPrY98k0xHq915yBV8QnvIUs0KtERvCbMuq/xfXIbbn+OL+GrskJZLuzDIfl+fdhnyeeWzmOfYJbMe4YCCzHuEXQ/eKuPuGqYVdH05q9lpoB57qM/GUwGJjNEHLxdeAgcRBIpYCjY2Z4q4jcuOHRay1rN/XZT/D/am63CqoKDzWuMa678YdYcmwlg== 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)(39860400002)(346002)(366004)(136003)(376002)(1076003)(8676002)(186003)(66446008)(76116006)(2906002)(71200400001)(55236004)(4326008)(6486002)(478600001)(36756003)(26005)(66556008)(54906003)(64756008)(83380400001)(6916009)(2616005)(66476007)(86362001)(6512007)(316002)(6506007)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?EiKN0SUDa3y6ujQT39WViKPNN?= =?iso-8859-1?q?ZfmtApZorSxFbQ5MNCuMCHtS2iXXhp6NRO+gqG6D2cMZd3rpR5hu6EJFt4Xp?= =?iso-8859-1?q?D2VzkQW7K992WG1ri3ovHJ8gInXR+lQQYTb4H4Aqq7L1LRRGVJauwqK3i0Uv?= =?iso-8859-1?q?gqvrCXZp92qF8qktq6JzrKZtiTD4DYB2xZyzGWnIFBU1k+bo50UsyExij8AB?= =?iso-8859-1?q?zjJK/1/pd8WheNRDmji730rQLG6WJcbKWWUS+hup4SJfVAjZDfzlGNLfc8k2?= =?iso-8859-1?q?y7NC3DQfErYmQG7EesVIFTtLavfVxFTUYvanTQdJTm63jhq58x2iNbvN2cuZ?= =?iso-8859-1?q?DVtazjjqjFuBSpsG2MjxJQyJMWwLPLoMp5fqRLRBKVE2EjUMl8kXVL+iPexV?= =?iso-8859-1?q?G/ZzlCYNZBsNnIiAoju8UqHbchRfJ2gZltgwd1lJXIGSiG1k5fXFBQUngAch?= =?iso-8859-1?q?ZV/PBO5HjbU+nnqCakDWEpKf1LA5aJnLGDOo0hXttZ5BPQItYuBYIuREoUiR?= =?iso-8859-1?q?Cy3UABlArw+qjY0CNR69gh+FVesmsMBnuDFSapdViIyuNnm+1JWJYaT+qOfH?= =?iso-8859-1?q?Z0u7FoimN7Bm16VeXsFr9zHWwkJDFbdEhjslLbieOrWzHxWfu1cCZL/9ZdJM?= =?iso-8859-1?q?2EerrTPZrPDdN8deQepZjG2z2kHOml65GonMCo/1VnnoY2LPc+cwODRk9Aet?= =?iso-8859-1?q?1RoSCO0GEU9p9TH3I91vXl/Zj6IqyKugCgPyOoSz2Y6VIW2IYmLMSFQ1fR/2?= =?iso-8859-1?q?PiTBDdVmPrhHmJP+HCJYliBf1zEAm2JNtq0z9ZyATkwiPdqGBm51QpYnonJp?= =?iso-8859-1?q?yl1WTCcdWNdhDoSLu5jzFO4zmdJCYjvbac1/mwdipfua3RUErI4pyXuNIDiP?= =?iso-8859-1?q?bMIXCUmuB3lSoiUyshvhzYnS6E2Q0z/ofEgTUlzaepHmdXUKG7fK0e7+eMAW?= =?iso-8859-1?q?Em9/w+pUkPJsGbjrHgYUELNW6t0f8Lo1oDYEjGbeSMhvWhBchMb+gpuageqA?= =?iso-8859-1?q?9sHdq7NNBoYwz9AGSst583x9jP0LcNECiYfrcZSL5eFlisV24YrN2mqOIRL0?= =?iso-8859-1?q?XAPw/daSeL9m/tHOmyT+BtARgkoS5tOV1RgFkyAOLNn2hF3/8yE81T5svtQ6?= =?iso-8859-1?q?6PnMwABfEJz+qCGwS+HGy9cB98OMWLlUdsvJhRJ7HV0saDeD2qMedwczRYF1?= =?iso-8859-1?q?Oa8vtXUd9kkEPiwhOxQdxMGQds7TnyJ6C4xTmh6ODCGnpNLtkEVoJCizBjZN?= =?iso-8859-1?q?PzpCILXZgJz6FCM4Soxa/SqbTS4MsRwgndfBpswPv1xa31C/hh9ACucZgG8X?= =?iso-8859-1?q?IGGi7RLn0KguCeqGBak6A1chQ+TBdn+Ur0r45oRihi9sbfbANW1CrFjYhxf?= 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: cc0fc91f-ed67-49c5-104e-08d8d7a39b41 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:55.6839 (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: bQW1NGyCh4FDQzBPXQe46aJBBSs9pjiArjAypXldUPsocKb2tl+v9zw5GYlLgTqRMyNOqrqm0zeUFHc1d8YBhJHPb0+r6tcmHc/cYB9a5wY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB4082 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 impostorscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=891 clxscore=1015 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 With XEN preemption enabled, scheduler functions can be called with IRQs disabled (for example, at end of IRQ handler), so we should save and restore IRQ state in schedulers code. Signed-off-by: Volodymyr Babchuk --- xen/common/sched/core.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 9745a77eee..7e075613d5 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2470,7 +2470,8 @@ static struct vcpu *sched_force_context_switch(struct vcpu *vprev, * sched_res_rculock has been dropped. */ static struct sched_unit *sched_wait_rendezvous_in(struct sched_unit *prev, - spinlock_t **lock, int cpu, + spinlock_t **lock, + unsigned long *flags, int cpu, s_time_t now) { struct sched_unit *next; @@ -2500,7 +2501,7 @@ static struct sched_unit *sched_wait_rendezvous_in(struct sched_unit *prev, prev->rendezvous_in_cnt++; atomic_set(&prev->rendezvous_out_cnt, 0); - pcpu_schedule_unlock_irq(*lock, cpu); + pcpu_schedule_unlock_irqrestore(*lock, *flags, cpu); sched_context_switch(vprev, v, false, now); @@ -2530,7 +2531,7 @@ static struct sched_unit *sched_wait_rendezvous_in(struct sched_unit *prev, prev->rendezvous_in_cnt++; atomic_set(&prev->rendezvous_out_cnt, 0); - pcpu_schedule_unlock_irq(*lock, cpu); + pcpu_schedule_unlock_irqrestore(*lock, *flags, cpu); raise_softirq(SCHED_SLAVE_SOFTIRQ); sched_context_switch(vprev, vprev, false, now); @@ -2538,11 +2539,11 @@ static struct sched_unit *sched_wait_rendezvous_in(struct sched_unit *prev, return NULL; /* ARM only. */ } - pcpu_schedule_unlock_irq(*lock, cpu); + pcpu_schedule_unlock_irqrestore(*lock, *flags, cpu); cpu_relax(); - *lock = pcpu_schedule_lock_irq(cpu); + *lock = pcpu_schedule_lock_irqsave(cpu, flags); /* * Check for scheduling resource switched. This happens when we are @@ -2557,7 +2558,7 @@ static struct sched_unit *sched_wait_rendezvous_in(struct sched_unit *prev, ASSERT(is_idle_unit(prev)); atomic_set(&prev->next_task->rendezvous_out_cnt, 0); prev->rendezvous_in_cnt = 0; - pcpu_schedule_unlock_irq(*lock, cpu); + pcpu_schedule_unlock_irqrestore(*lock, *flags, cpu); rcu_read_unlock(&sched_res_rculock); return NULL; } @@ -2574,12 +2575,13 @@ static void sched_slave(void) spinlock_t *lock; bool do_softirq = false; unsigned int cpu = smp_processor_id(); + unsigned long flags; ASSERT_NOT_IN_ATOMIC(); rcu_read_lock(&sched_res_rculock); - lock = pcpu_schedule_lock_irq(cpu); + lock = pcpu_schedule_lock_irqsave(cpu, &flags); now = NOW(); @@ -2590,7 +2592,7 @@ static void sched_slave(void) if ( v ) { - pcpu_schedule_unlock_irq(lock, cpu); + pcpu_schedule_unlock_irqrestore(lock, flags, cpu); sched_context_switch(vprev, v, false, now); @@ -2602,7 +2604,7 @@ static void sched_slave(void) if ( !prev->rendezvous_in_cnt ) { - pcpu_schedule_unlock_irq(lock, cpu); + pcpu_schedule_unlock_irqrestore(lock, flags, cpu); rcu_read_unlock(&sched_res_rculock); @@ -2615,11 +2617,11 @@ static void sched_slave(void) stop_timer(&get_sched_res(cpu)->s_timer); - next = sched_wait_rendezvous_in(prev, &lock, cpu, now); + next = sched_wait_rendezvous_in(prev, &lock, &flags, cpu, now); if ( !next ) return; - pcpu_schedule_unlock_irq(lock, cpu); + pcpu_schedule_unlock_irqrestore(lock, flags, cpu); sched_context_switch(vprev, sched_unit2vcpu_cpu(next, cpu), is_idle_unit(next) && !is_idle_unit(prev), now); @@ -2637,6 +2639,7 @@ static void schedule(void) s_time_t now; struct sched_resource *sr; spinlock_t *lock; + unsigned long flags; int cpu = smp_processor_id(); unsigned int gran; @@ -2646,7 +2649,7 @@ static void schedule(void) rcu_read_lock(&sched_res_rculock); - lock = pcpu_schedule_lock_irq(cpu); + lock = pcpu_schedule_lock_irqsave(cpu, &flags); sr = get_sched_res(cpu); gran = sr->granularity; @@ -2657,7 +2660,7 @@ static void schedule(void) * We have a race: sched_slave() should be called, so raise a softirq * in order to re-enter schedule() later and call sched_slave() now. */ - pcpu_schedule_unlock_irq(lock, cpu); + pcpu_schedule_unlock_irqrestore(lock, flags, cpu); rcu_read_unlock(&sched_res_rculock); @@ -2676,7 +2679,7 @@ static void schedule(void) prev->rendezvous_in_cnt = gran; cpumask_andnot(mask, sr->cpus, cpumask_of(cpu)); cpumask_raise_softirq(mask, SCHED_SLAVE_SOFTIRQ); - next = sched_wait_rendezvous_in(prev, &lock, cpu, now); + next = sched_wait_rendezvous_in(prev, &lock, &flags, cpu, now); if ( !next ) return; } @@ -2687,7 +2690,7 @@ static void schedule(void) atomic_set(&next->rendezvous_out_cnt, 0); } - pcpu_schedule_unlock_irq(lock, cpu); + pcpu_schedule_unlock_irqrestore(lock, flags, cpu); vnext = sched_unit2vcpu_cpu(next, cpu); sched_context_switch(vprev, vnext, From patchwork Tue Feb 23 02:34:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099769 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 E7239C433E0 for ; Tue, 23 Feb 2021 02:35:25 +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 A6C9664E3F for ; Tue, 23 Feb 2021 02:35:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6C9664E3F 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.88518.166455 (Exim 4.92) (envelope-from ) id 1lENXc-0004EZ-QF; Tue, 23 Feb 2021 02:35:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88518.166455; Tue, 23 Feb 2021 02:35:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXc-0004ER-Kz; Tue, 23 Feb 2021 02:35:12 +0000 Received: by outflank-mailman (input) for mailman id 88518; Tue, 23 Feb 2021 02:35:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXc-00046p-7F for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:12 +0000 Received: from mx0a-0039f301.pphosted.com (unknown [148.163.133.242]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 25fbc6db-e3bc-4661-b022-f6e721c1303b; Tue, 23 Feb 2021 02:35:03 +0000 (UTC) Received: from pps.filterd (m0174677.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11N2PMaS026304; Tue, 23 Feb 2021 02:35:01 GMT Received: from eur01-ve1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2050.outbound.protection.outlook.com [104.47.1.50]) by mx0a-0039f301.pphosted.com with ESMTP id 36vq3kr64x-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:00 +0000 Received: from AM0PR03MB3508.eurprd03.prod.outlook.com (2603:10a6:208:4f::23) by AM0PR03MB4082.eurprd03.prod.outlook.com (2603:10a6:208:70::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Tue, 23 Feb 2021 02:34:56 +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:56 +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: 25fbc6db-e3bc-4661-b022-f6e721c1303b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CvtP5KMBplTBWpgA6/CvU5jOwv9Af/k5Xbh57TfCHRdCgHI8E0UbUmr9CrnxaK3Vm5zPJUhSzf1WsRdp5+x+Q/8M56T5KO1hUVjrHzYbFSdruSevpde4Z8SbZEQhFh4NE7xA4UDKfVIQvaC84rfpzRDdEUJE++lJ3MP5Sm7L7HfNvz2H5b3npX7v/yXz58XloyfWeQsWiGHQzkjSBnmJINcWo8S8g4m6uBjKrjpV7yaSpReKYWRZ1uvkgmcJlMQY3YPRVGdc9dNpRjMhxDUPr80sKDWnbHfiDtfwvokcRAvakJILu+lx5PKt00tNNGu+okwqHbOE9/EQ5DW5QGfJ9w== 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=QJTEpv4AaTo8JBp7LsUk0AWc8Ja4nv4Eo3TfeWXSlUU=; b=T5AYYPqAqrpYKj8JVdeZoHb3cgrDqP0j6dtnaxW0pM6j81cpXvL9vKEM531IeaQoQVQaPGFG83wunAZKoDbQEI0mAR/2xOkr1FIiK3BrmS+v0NtvUsvl1RwMRUMr6HNd/kSGwwmRgShpAHx7U3Cbib84liEb51d7qhe6nfgdktyT2XwQVkDwfut5qClAgtFl3IVVGzB71FFQX4QKO+Nx6kkFNoDqk2hT5UmAAvJmiXLaT/PORgHwWQVjvxMUMHGSyiaWNa4nVwhq9m04Jopnu4vADva4Lts2oomT8QaEpFjup238DNMwvMKFVNtGzpeDxD71YEYfkXSsC+DIAgoAMg== 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=QJTEpv4AaTo8JBp7LsUk0AWc8Ja4nv4Eo3TfeWXSlUU=; b=JyVQxcrqLsMJ6BVmrwNGH+0zeVQtsEOWxM4y6sYfk++saiBG4DU4sBFgZWubhtjum/ay8gNIoOyqMCunfkswUdsHDbm5HrMtqzKiZX0yyuCEfMnzF163u+D1bC5NBb3l/BwwPJ6L1yhngPN5Pm5kJC1nfrfS0S0Yss7NMlNk5DvctbQxo9s+5MVSanbVNEeNovHq7WBtBbHnfn2tHVTmvjIVRg2Eqc+ORpg+9j5fUokiaILF6UUheh0fF6PRxcW0SvY7KJQL7bKK0krYVOghHRY9ppV3gXYgOStaVv8e3Qzdf/Xt9Da13XskLf1gqrGDNxsA9rSQla4ZAqQyxPvXGQ== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Dario Faggioli , Meng Xu , George Dunlap Subject: [RFC PATCH 02/10] sched: rt: save IRQ state during locking Thread-Topic: [RFC PATCH 02/10] sched: rt: save IRQ state during locking Thread-Index: AQHXCYx4gKfh+6izfkCEXHj4/bqk4w== Date: Tue, 23 Feb 2021 02:34:56 +0000 Message-ID: <20210223023428.757694-3-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: 530c420b-0734-458a-0fc7-08d8d7a39b87 x-ms-traffictypediagnostic: AM0PR03MB4082: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gOjGmr3nTs3YIiyXWb754h5mEeOBl9QERsthwQ9+b/CeNCkWiN0Az3U2dOwI2jFUqnGy2p23O31FYOR4HMemPafc5QTpnSGDNn4WuouxwPLxQI0i1goNfaAdxAstiHM/0Snvp+kGUwYTHS495sRPZORFp5JrUvynbAz/IZ0s02+2spivclvBsMOvyDZUcrUuGHGkKrFg5K9Sf94/7K5qXhEmBKO3BqkEs2JqTYCjzCjDZVx8dq+YZ2Y1hHLbyUQMkHGJOfikaX5VBLbSDzmCRF0WmDw7yJGuxB9qTuts47jzElrumMIRkybK6d9qyMP2eJDgRRA+SqbuWYQ1/kPq/SjJkmGM9SeCIqYJOU5Od/KDmJ6gT8jV+RjH1ZHnrHYBAbVFnYMDSDthEOED5+UfNeXErP8TuW3XUPdMCbccWItp/74XX/jpJMRZrDrl8oulhYmOTPZw6Yt/la3HGJUPPZZcflyUexZKCkgSFtmoMSxEM0s29WEkzwZHWxvbZxo8jAeXY9kyn+6yDEJZSh6hSg== 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)(39860400002)(346002)(366004)(136003)(376002)(1076003)(8676002)(186003)(66446008)(76116006)(2906002)(71200400001)(55236004)(4326008)(6486002)(478600001)(36756003)(26005)(66556008)(54906003)(64756008)(83380400001)(6916009)(2616005)(66476007)(86362001)(6512007)(316002)(6506007)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?137VOklkTfRbwkSDaRFMcM7Jy?= =?iso-8859-1?q?10u0SeDZeEbCAqkKFzvaTTjQZGJjdTpNLSR4VPTxgbHXPRiWnTE3vjrbR5gR?= =?iso-8859-1?q?3YfAv2gpPzkbLNb9CqaqDrQ2FBT9N5U0aUe0PK/flvfFwk+bNz/9q6k7yC3v?= =?iso-8859-1?q?NVPraj790eYZznARsuBLiyfN8wTCStSk3yPzLLjo+tIVCtoTMJEYPk1iscYt?= =?iso-8859-1?q?RxjNjFDsPPfS3Ai2oXf85AazYem17FrZ1SORbMWGOsjHk4aRKQguPWokAaT9?= =?iso-8859-1?q?1fh3cHde5hBwTFS3CBtfog8AU4HNDWpmd/Ha/qRETvayu8w6FLTy6Rcif+b4?= =?iso-8859-1?q?zpK0QTVdjptrgXePzbDJnTx/aLYTnaC7YmcGOocBHv3XxkFMzKXv15SXbYnd?= =?iso-8859-1?q?ca4QIUvIGGi2HYnzCr3UHIXhcEz3HzWyG7w9Y/+OKJyE06T1bFZNmv6ApLnw?= =?iso-8859-1?q?gW9ADsa0tWNUvJh1LdsKmCyFkeg2aYsLLAFQsnWg+Y/0ymjr2B9W1J5K/dWq?= =?iso-8859-1?q?6bJt1RTZZav8Vbo4s9qYXb4rrwwSl3XzxaDfZp0FsBPgWPDBKq8j0TJM0s/P?= =?iso-8859-1?q?2Q9uVG2KFZrB8LXm09HRIyBjnhvA8mrR8WRKUvrK9Wdxh3+VsqCjurGJBCMG?= =?iso-8859-1?q?y5xlcLHcYKhoMvDuhzu8r457UsmECIyjM0kHk/gWClFJUI9RFt3dFEjzV9M5?= =?iso-8859-1?q?3EB/Fbc2w3JBuE8bbPM3RFuIsgyNBPKVLnNRIqLzg/FAMKNGEqkM5aZF+giT?= =?iso-8859-1?q?Rsfrgi21RdEhfzeIM3zpmukwPAhCHCM1w/ypdIfVcv457ml6kfd/m5reitbA?= =?iso-8859-1?q?lVxr0NT+pf0GtHCV06iEQhybFXibrSIro3sFVf9nSieeHUAV4d8fawoxwXuk?= =?iso-8859-1?q?G1q15rrByiNIDs06ELlMONXo2ELdfDsZ7Bu7Tt43nFnSnPgsjoFYU3DA+Dvj?= =?iso-8859-1?q?3YDIA6Qir6fxvZLXbBcl2Vt419MPWOL4U4KIS412xZMp4qyPluThP8wjG+EI?= =?iso-8859-1?q?mhQZIcxV6epiJuPndN1guf3OVpEj9f4LFcI4xv7robiET90hFlHBlPDKapGi?= =?iso-8859-1?q?R11oy7sN96HAi3CDmMkuY5vmK2Xb246EHOiB4Sm96mI32YpGbcn8gNRx+Igj?= =?iso-8859-1?q?YF/nVws+o7gDap2C/lB+eGLau/F6Y2/R5pLbK/SQZYAUrfY3aK9F6EFOThla?= =?iso-8859-1?q?05YFYT3mWUe5ZpZZlilVCbNae22VaS1112dmPNVSD3Q9UTzvWXEbpAPs01IJ?= =?iso-8859-1?q?if0nvMsp196pSc6eAMvrcCG00UoU1TB+Fl0aECgMal32DY6i3fIXy+QweQfu?= =?iso-8859-1?q?grOGdVFmzAHJtqMsdsGRoGtl4AJyeRnvnuiMNPZNsgeWy6BmgzZ1JyUWyyC?= 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: 530c420b-0734-458a-0fc7-08d8d7a39b87 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:56.0786 (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: 6inaaIkdhXiQ3tVQfPw5qfIT4X4kMnQDQ3aLZFiFjYnD3Tjo0rj/VnJwOMAdf+xjoGSuaHxTenKyeYv1vSsC+fh0vlVWQD6KnJsbJKKMGLo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB4082 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 impostorscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=864 clxscore=1015 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 With XEN preemption enabled, scheduler functions can be called with IRQs disabled (for example, at end of IRQ handler), so we should save and restore IRQ state in schedulers code. Signed-off-by: Volodymyr Babchuk --- xen/common/sched/rt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c index c24cd2ac32..e1711a8edc 100644 --- a/xen/common/sched/rt.c +++ b/xen/common/sched/rt.c @@ -1318,7 +1318,8 @@ static void rt_context_saved(const struct scheduler *ops, struct sched_unit *unit) { struct rt_unit *svc = rt_unit(unit); - spinlock_t *lock = unit_schedule_lock_irq(unit); + unsigned long flags; + spinlock_t *lock = unit_schedule_lock_irqsave(unit, &flags); __clear_bit(__RTDS_scheduled, &svc->flags); /* not insert idle unit to runq */ @@ -1335,7 +1336,7 @@ rt_context_saved(const struct scheduler *ops, struct sched_unit *unit) replq_remove(ops, svc); out: - unit_schedule_unlock_irq(lock, unit); + unit_schedule_unlock_irqrestore(lock, flags, unit); } /* @@ -1460,9 +1461,10 @@ static void repl_timer_handler(void *data){ struct list_head *runq = rt_runq(ops); struct list_head *iter, *tmp; struct rt_unit *svc; + unsigned long flags; LIST_HEAD(tmp_replq); - spin_lock_irq(&prv->lock); + spin_lock_irqsave(&prv->lock, flags); now = NOW(); @@ -1525,7 +1527,7 @@ static void repl_timer_handler(void *data){ if ( !list_empty(replq) ) set_timer(&prv->repl_timer, replq_elem(replq->next)->cur_deadline); - spin_unlock_irq(&prv->lock); + spin_unlock_irqrestore(&prv->lock, flags); } static const struct scheduler sched_rtds_def = { From patchwork Tue Feb 23 02:34:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099771 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 4B7E7C43381 for ; Tue, 23 Feb 2021 02:35:27 +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 0E775614A7 for ; Tue, 23 Feb 2021 02:35:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E775614A7 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.88515.166412 (Exim 4.92) (envelope-from ) id 1lENXU-00047X-MB; Tue, 23 Feb 2021 02:35:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88515.166412; Tue, 23 Feb 2021 02:35:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXU-00047L-HE; Tue, 23 Feb 2021 02:35:04 +0000 Received: by outflank-mailman (input) for mailman id 88515; Tue, 23 Feb 2021 02:35:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXT-00046u-W7 for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:04 +0000 Received: from mx0a-0039f301.pphosted.com (unknown [148.163.133.242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 68b0f640-32de-4aa0-85b5-e53c587577d8; Tue, 23 Feb 2021 02:35:02 +0000 (UTC) Received: from pps.filterd (m0174677.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11N2PMaT026304; Tue, 23 Feb 2021 02:35:01 GMT Received: from eur01-ve1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2050.outbound.protection.outlook.com [104.47.1.50]) by mx0a-0039f301.pphosted.com with ESMTP id 36vq3kr64x-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:01 +0000 Received: from AM0PR03MB3508.eurprd03.prod.outlook.com (2603:10a6:208:4f::23) by AM0PR03MB4082.eurprd03.prod.outlook.com (2603:10a6:208:70::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Tue, 23 Feb 2021 02:34:56 +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:56 +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: 68b0f640-32de-4aa0-85b5-e53c587577d8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/0LdzXELduml+jUaLJtNvT+Wx2FNmyZTe49zUVTc283TNgbc+Kc7DBmx1uV9R3sJ2YlVjl7duoCoOQIPlvwvoDssF2o1HrlfcTgoHelS/A1QyupTfCHM4ZlMMmuICNNWxNYHZx4WM+bO5cmUkM0bCVRJ56Kp6uE4cHCjOoFbMAJBwxyiOFaT8mjHt74l1zAvjNiRCN4HgF6/BMxDHyZ4MWlSbwjcJWnusAVRgPREN1oa7lf9kMkH0ddXnL9Ccziz3btUcS4WKi/rNLaek0i0uWMVP2AhckZ8g/HzeOc7rOJW4Vfz0C+AD/nxk3uKzc4UF7cLm+zqDOK3M2gT7B3Bg== 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=Fn4xI64B+KozaWUtPjUMMalIz9nsigT141zdrSuovfQ=; b=dnJ6JWrECpTgYrkflvlaqJwEjXebtzyNyQxPPl356g+Vr1vNrGG0UKHj8uUtQ5CXSVrAG9BidHev7KHyfwFWxkm1ZlZ65XLSTMht1U//8j8B+G+LjcKdLg5ax9oZADCD+pIEmc2/WnEg8IB8OiTR1vPY8bSnnuFGAorTMPbQ2Gj54R3ilLAvVbtlKyfI/4915iDLTKK2bl207KLt6Kyc3OCM96eHgAmjHAK6z8o68l1AsO/hj54RTn0zcMHqMnn6vIUzJdad9LTT+vUtF4LhhwzQ2KWsJfOcEVOiZq9pN4MULnJbWGKfTksncT1R+/tc4k3MqQfvpKrRRNxJDWrQxQ== 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=Fn4xI64B+KozaWUtPjUMMalIz9nsigT141zdrSuovfQ=; b=Xe0hc7GWVavvNZAN0q4rZt8nrTovi7xQOS19ZeaO7Cv/xqHhmWAtLdy9osZzGdjfaPBh1sO9WjpdZTFVVbOUGiKwkXqtbFZQKnqqd70SY7xJj3fVwZUBHnuE6fj+dQieEbEYmUBMH5NWm/BTMVEmfB2u8qfCCicTqGxshNRVT+dnDgbe6Alp+fMPNaNFTkqK3oGR6FIkqhWHWu53Qn9mIEMizqFpTJMiIg/f5BSy+oAOo0H5dTP88CsZfrrDBkcA8TtyQRflQlVX+KFclJ7vxM5CduR3LrkfgufBgWENFIEPERoXWcV4VBDtKqwOfVkUINzoKfKVFlmPBjvzImKHYA== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , George Dunlap , Dario Faggioli Subject: [RFC PATCH 03/10] sched: credit2: save IRQ state during locking Thread-Topic: [RFC PATCH 03/10] sched: credit2: save IRQ state during locking Thread-Index: AQHXCYx5L/8BTjhE1kmjLesetNwagA== Date: Tue, 23 Feb 2021 02:34:56 +0000 Message-ID: <20210223023428.757694-4-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: eb228de5-cf0a-4d52-a8d7-08d8d7a39bb4 x-ms-traffictypediagnostic: AM0PR03MB4082: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GY8GrZ5vRzAffAw8dMb3KHeLz56TgIJpsNsAt0QryFuysYxwuSii9DH6dMgRkW/c7tlLVp3h/Lco4RnORbXbh1ECNyYnJHyAVPe0Bpr5lYsm7uIrRD5J0vpf667lezp18ZIKI2Yb2U3WEfbM/yoHo3ATiqukchV549MI3i+D/58rhSck20HOEP9AIjtp4V04/XCN4ZzKlieWIqPUd97ek26FbylrU4r0QWmDY+14YBoeluN+O17IjG8O49d9j6R2t3TBY0GKL8AP7KNqEU+J1Ix0XE1kvcfqfUj9b+TR7RkXvdPGFLN5R5ge4qUyPIgdJG41hvTpxnKKnufAXwNz3CR8y8Ta9aFyomxkz2FrZKkar0r463tgUFiL0/Hohy7iY9ymSJrCfv4g0tIVoG6Lc5jIY38hOchyLkKq+K8SwYmRon1Wdayle5aIYN0fPSdeHiD+pTfmnQeRlPdZj3aTiGCffivCuhpebkB4mbIwdbjhk5FqWuH6OuN2v2mKJ4cE2L2UkWhlsqt+KOiIyzm5/g== 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)(39860400002)(346002)(366004)(136003)(376002)(1076003)(8676002)(186003)(66446008)(76116006)(2906002)(71200400001)(55236004)(4326008)(6486002)(478600001)(36756003)(26005)(66556008)(54906003)(64756008)(83380400001)(6916009)(2616005)(66476007)(86362001)(6512007)(316002)(6506007)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?Odef/KZUAh2CdLP33DX7YhCl8?= =?iso-8859-1?q?YG6UdI8z7CCRRmNd4ksZi+DH6H/5I1+w3+3APbF9DiWuYJc2/LTKDDPtkMoX?= =?iso-8859-1?q?kLxaELKF/ztO1MMVdgVbKiyvtC8R5eQO5tpmMko7WsjVjpzQklaD/mjTqMPi?= =?iso-8859-1?q?BmYDRaFd0ByFJcGhqr51roA3CcArtMrnxFuaxvrlB0E30IuDosDrhcXs6D7h?= =?iso-8859-1?q?hL74iEaVMVUzJEZslzIE7GI8hxq7mCtK9w9/lZL/SzqwoyPVRMPvoxrS91JT?= =?iso-8859-1?q?ymn9VYnR3vsCNk+6uYgnNowQ9r/srReAve96lfJA8kVDUkepnszFJtE7ZUZR?= =?iso-8859-1?q?w9pSeiTcwzz60fsc2nEDlIgqyIpMikc2/F21G8kHOe4Iy/5xbk2wml5RCmx7?= =?iso-8859-1?q?SqyvPs2Lzi7aSm/RIOdb4rhsX+gRrlA2vfzfNwbKujTkJwcma6VChY7BTc6z?= =?iso-8859-1?q?z31F85qhuCSXXQQAneaS5RcN8X9KWaUJJiRZBUaLWG2NWdP0y+TcbZtg+I/R?= =?iso-8859-1?q?4MPH4z6EF13HpP9OcYbtQRon9g/S3JwKNKesdbzcJ3lR0mIeE4gFdAO7+GDJ?= =?iso-8859-1?q?gm1/ihynIdQ2y3fvfd0Y2vlu+DDsSWn9Op0aNymMvrJI/8cuoNc57ZFHNzob?= =?iso-8859-1?q?E9uZ2y1yMTGBD6NgnrSDHOJH1lo1B9fTJFSHmqOXMy5g8t2fDPLIy7vho2ri?= =?iso-8859-1?q?yiiMaFKFfAE5iGgL21S456jMzZ1o2n6U65ECTuY1m+o/IvYn7S6t7UV+Z3JD?= =?iso-8859-1?q?ceg2Odq8ASSVTJg6TrVpOXmTSnOYXlE0hYT07Cvvr6VS/SbimND5bt9ET7Os?= =?iso-8859-1?q?BYdq3Mov35LxNX5VpHaQWnWn9AOm8XfeSsBfx41kTb1WR0/v/SQGANk1n9YO?= =?iso-8859-1?q?JCBj1x+CZurLQmtP6ht+0lctaIU5X+oxp2O5msX25pEj2bX9AIvEhopNqZeu?= =?iso-8859-1?q?9noFWOGVE2AGWCMIAYFsJvLf6bglDIVxnqTzTB8Kh0RmRi0xsQ9LjCP8dvm4?= =?iso-8859-1?q?xg/CGeRpf+NGnqhkclx94TS3nEAph8AqLrkzn9WoWslZlp70f9G22t2oh7tX?= =?iso-8859-1?q?JJaN499tpfKlGR3Gcw30XTdEQgyX/OAvB4v24uy4bb+W8OC9Pctev7fjyLUI?= =?iso-8859-1?q?hEPwwquVkUD0rqCOnuz7DzegNpseqPYuu0PxkPawo/m9YncZci1UO+ATajxa?= =?iso-8859-1?q?zRep9HZ1tyH34jESUAaRDTwLX3lEOPDQD1AShUHq2Y/QBVcBD4p730PSTCEr?= =?iso-8859-1?q?XyD5M+RMQzne14PZMGEgohFKg7O12LqmsOiMyKAb9NFZaKw/04qV9KYPblBc?= =?iso-8859-1?q?vLWxey4XAuvNmfM8tRL+aLfWtw8Ix91ZGNbqUuclUtEaYGnBJVCfG8+h1CL?= 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: eb228de5-cf0a-4d52-a8d7-08d8d7a39bb4 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:56.3895 (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: +adPgn6nAGWGBXgAkinbxzNqAC9hVqx4ES6xcjdxn+lFnh2aCCO5sCosH4IqQUjxLp0GAvyEldl6K3e5+4fscElAIySHnRcVgto14N9q8i8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB4082 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 impostorscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=912 clxscore=1015 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 With XEN preemption enabled, scheduler functions can be called with IRQs disabled (for example, at end of IRQ handler), so we should save and restore IRQ state in schedulers code. Signed-off-by: Volodymyr Babchuk --- xen/common/sched/credit2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index eb5e5a78c5..b3a9786425 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -2297,7 +2297,8 @@ static void csched2_context_saved(const struct scheduler *ops, struct sched_unit *unit) { struct csched2_unit * const svc = csched2_unit(unit); - spinlock_t *lock = unit_schedule_lock_irq(unit); + unsigned long flags; + spinlock_t *lock = unit_schedule_lock_irqsave(unit, &flags); s_time_t now = NOW(); LIST_HEAD(were_parked); @@ -2329,7 +2330,7 @@ csched2_context_saved(const struct scheduler *ops, struct sched_unit *unit) else if ( !is_idle_unit(unit) ) update_load(ops, svc->rqd, svc, -1, now); - unit_schedule_unlock_irq(lock, unit); + unit_schedule_unlock_irqrestore(lock, flags, unit); unpark_parked_units(ops, &were_parked); } From patchwork Tue Feb 23 02:34:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099767 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 EBB78C433E6 for ; Tue, 23 Feb 2021 02:35:25 +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 A05A5614A7 for ; Tue, 23 Feb 2021 02:35:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A05A5614A7 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.88517.166443 (Exim 4.92) (envelope-from ) id 1lENXa-0004Bt-E4; Tue, 23 Feb 2021 02:35:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88517.166443; Tue, 23 Feb 2021 02:35:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXa-0004Bi-9r; Tue, 23 Feb 2021 02:35:10 +0000 Received: by outflank-mailman (input) for mailman id 88517; Tue, 23 Feb 2021 02:35:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXY-00046u-V5 for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:08 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8a683b22-87a2-4aba-b212-f23bca93a2d3; Tue, 23 Feb 2021 02:35:04 +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 11N2QQxj004083; Tue, 23 Feb 2021 02:35:01 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-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:01 +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:56 +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:56 +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: 8a683b22-87a2-4aba-b212-f23bca93a2d3 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SVd+3NStcB6wNxCQ0IH0EwlhcAgzILiv20hUtyCk2+R9ofOqYwZrGr9SU8d4fQhVSnZS3Kz3xuQfa2b7cgQEGWZmioNsBkW3ZXT0g3Alk+FO+yO3FB+2+jfcAoZZ/KPv8mC4zIx4dL0rCzUjqiQ2WinKheKOHzlQIeEX/8NDCobTBL+RT0juOXHHdD3AKr9N011+WWyXX3Y987QJHTMZxnNWwERliYQjk0NOCDmYuwdLEmz38mw3kVEB0ixl5hkXHvopXvkyXcnRlShMIamFVmOsVYDZUVpfEi0zjmP4LFN5/cDT/V/jwKqwICvx8toVQvPcznKi4WwrkR3Fd6iUwg== 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=kphJiUy2kLhF2NKPvP/qP8YU2nqCVKOjptsGkk/vL84=; b=XW+boCnlFJzSuQpKzcrNOYYLys/jCIuqGUgaZy4WW+zx1AdojBFEenV5kiYsP0N5RbBbbWKWL40inH5ycgSMLVE/k/lnj+rLC5Y8BzBj1cOsj/a7zPkmG8mAATOX/bvN0LpRT1h2f03R167ZBcNns29KTzCUWJLh7p1So4KmqAfsq/Uu6euJcWU2Mzw5NHYPs9vEztkf6pKpM6LJuXjbv2lTKtMQ0VqvwidW917BRbCb3K7aQ5jCvbYv58525gh8JKvG4rQsAepjfDwRtkjGDfNyOh3//VMaX6h1QnwKumH3dEoJtGuVgNoTrJDO0L5+7b8U5y94OL3+daqFzpvjPg== 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=kphJiUy2kLhF2NKPvP/qP8YU2nqCVKOjptsGkk/vL84=; b=cS7iAANsZBsM5KfGWi9tBf0WaghKY1l69+bd9AwzqOFZC8/mjxI4eLb6qAAlCAtQOl9cUDqtXcK/jIHSlAEyOraBA4CTdD9UY3dUqOgTaZkvojaI5luFl5Fu8XAN0q8EaHbVSPNyffQbNe1++j5pz9pwNoxFKNWxqItigtbgbMOwpTdPRiESHL1KZCd3joBGe9BuhlDhKfXCdm/NS9vfyxqKZrVsN/2o4ECqj7y8cJu0nkN0ifqLbfaBPS26VmZbBjoX/f/R19/aWso1tqXTLncU826Vj+cjjC3E1ni92f0LLHL5533RzJAa7s3twZ1ttLvNx+R7ErhL8k/SrJOvUA== 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 04/10] preempt: use atomic_t to for preempt_count Thread-Topic: [RFC PATCH 04/10] preempt: use atomic_t to for preempt_count Thread-Index: AQHXCYx5c7ga2XxajUiE7SdBv/dfFA== Date: Tue, 23 Feb 2021 02:34:56 +0000 Message-ID: <20210223023428.757694-5-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: cf007190-437a-4c26-e6ff-08d8d7a39bde x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1775; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: i97tdpblv3xqToaxF4CiMxMl92IE6SDpDlUbnNlP0+3TClGIpkZHgucRTZzzvsp5q9WVvCSxyQg1TH3CFNnmLDi7H/CdQttVLj8yCG5kHnQeYF5YIMK8Ci+6DNdUQu48PCALYMKpx2q4Qx/rX2nFh8bmv6SxLc4+7dLAy5ju8163nDqDsZSsW/riLPEQdp1Xet24SdKUBweSWFZsBVtSl1GyQh0eqd6/AUDPbusq9lxXiQaKSglgMUO3VkbekY5jT9UM5TrhqjcP9jV/2+dd2ndzKpz+bZDol+ShSHvmX8sh6b5pRfS/wI4hbbBbFeO62iSkAg/8gwm13SMPXHmXtAB0S2CysseMuOYt55WA8rMQLhP1rg7wb8BPEXJlhpW98d+CyJt8bEmRPiZ3/eTGcQSeC7GGfqF/wJI7gRX+Y7ADe3lgy5mjjYPpBipiZQeZRT25Mb/N4ai/GJdAXBHD28gMDUJafqVu4JUrkIJIZujiztnq9J1lFkEwPZ744yRQs5uTdnXxz/KkmyLQX9L1Cg== 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?mXs0iPRk3o5ZuDGxCOtGxNS0O?= =?iso-8859-1?q?tlKJFdIKJUWPc9YMSuW+tmXP3Gd6T8ht+Xi1aKvFLC4JwL/Ay6GSMtH3GT+h?= =?iso-8859-1?q?CVamxgXhL2oKhkOey5akZZqoQQlBq7/oQQU2rUKNsPYKFZWoku0WFEFDQ3P4?= =?iso-8859-1?q?YUDrU2fQhRubw5Vt5MWNARIknrNjPkjcrzPd8Kd/5kd4PUfJv7LXlEuFMW3H?= =?iso-8859-1?q?sACRTv4NETei3DPbtH42WTapidpv/7hGxbq5fNkd9cMdHlPChcEacrdd1SYF?= =?iso-8859-1?q?+QM5lk5mhpAhXdJSTyOzZrr3NeR/8gHnfvR5aA6+/RZE+TKkEszOyeefZEkk?= =?iso-8859-1?q?1mpo9rYN4yLLh2ZdFVIFZ2OsSsXgvDai6jEWBkfAsAKMo2s3RSya1443g4GD?= =?iso-8859-1?q?Ul0xecB9tq4ShrQ2u/QERXKGVs2qilD74/ADumANBKytIyQMRonhPrNfHqDy?= =?iso-8859-1?q?Qb/lkFrMZCJN5RH7ldL37H7cgLCe09zcFL6mHbQXH+F/bfxJOJFTXcR3E54g?= =?iso-8859-1?q?P2GLxY++fnMInCrUo6LYrEvlJGNK25nfeQKPI9LY1cLUCg0aJddX7U9K0B6a?= =?iso-8859-1?q?+BS5ip+hoEzEqshWygqS3mr7uodOvWLHo4b2b86BkSn6hXu+Rw3fvh6X2hv2?= =?iso-8859-1?q?B3bt7BMOSh/iK0KY/vO4ujQbYyU/J8icywAhdzPK3U6t3I1K2d2sgs/p6gUx?= =?iso-8859-1?q?OPXRTshyxPD1/yh04YtmX4MiXJhRH7fRlC/ZhjDt5tmq5I99CbsAYoQpYGe5?= =?iso-8859-1?q?FStgB/3Kd+DpZq0T5DsrZFiG8NFUjGCq51HpweKa7HWXGotVpQ7QUAg1FHyV?= =?iso-8859-1?q?djyl3VuhTyonkDlAsgINfOiVastHvrpBHaxQeGBdcPgijVc9pVtHsoaIUeFr?= =?iso-8859-1?q?iBrtv7d3TnKR+EuVmHG1BzhXyPZNmr9Wkz5ZsAgUr2Oq/9NeqY9IpaZk5h/p?= =?iso-8859-1?q?Rf7SoLiIsBQKqbMb0L8q5gJOlxDObc3uJiM4g8+7sVdWHMD9NwC9f2QahCvO?= =?iso-8859-1?q?zkA277mrqI+zQafvI6Vz6yl0hUeEOOnHKdywH9JEeJOzz2RPxwUBa3ETpI18?= =?iso-8859-1?q?oNJ4DVy2T86hbnjwKB60qEqCcztDXZq7djeBzE3JNZ44UlxyPfLo6wMBZHgg?= =?iso-8859-1?q?WRe4oK3ao48ddRzA/1SB7hw0kDHwgzkH66Y3BNSdDkOlnqv3TSXd6mpOU9pG?= =?iso-8859-1?q?iZ3hrZDtilIw0hXRzRh0+JRY42q2urNYwK5C+roeRjxMx+Pwo/QTJQ5RwAc2?= =?iso-8859-1?q?AxYhgjCigw6Qv3LtF/8jxNPlmSd4iPdrApxPK7BV2Vu3RRc3L/iF2fDb+BIP?= =?iso-8859-1?q?dgaSCYaeahkTVmRmTHY86b0fG+jbkQWlqJ+/ko61FwZRzOyK9qKFImEG0Uf?= 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: cf007190-437a-4c26-e6ff-08d8d7a39bde X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:56.6783 (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: EorqOHZR/msedpiNMbRu3jdJd0YOAMW6NjB1dbgqrSDqWRJrnlgzFlxdRSh3FmOslK1Tozvs/KQsQaiuoyv3X8Cz6RMih9HsSVZpVvMyk3g= 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=775 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 This ensures that preempt_count will be accounted correctly during in-hypevisor context switches. Signed-off-by: Volodymyr Babchuk --- xen/common/preempt.c | 6 +++--- xen/include/xen/preempt.h | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/common/preempt.c b/xen/common/preempt.c index 3b4178fd44..ad61c8419a 100644 --- a/xen/common/preempt.c +++ b/xen/common/preempt.c @@ -23,17 +23,17 @@ #include #include -DEFINE_PER_CPU(unsigned int, __preempt_count); +DEFINE_PER_CPU(atomic_t, __preempt_count); bool_t in_atomic(void) { - return preempt_count() || in_irq() || !local_irq_is_enabled(); + return atomic_read(&preempt_count()) || in_irq() || local_irq_is_enabled(); } #ifndef NDEBUG void ASSERT_NOT_IN_ATOMIC(void) { - ASSERT(!preempt_count()); + ASSERT(!atomic_read(&preempt_count())); ASSERT(!in_irq()); ASSERT(local_irq_is_enabled()); } diff --git a/xen/include/xen/preempt.h b/xen/include/xen/preempt.h index bef83135a1..e217900d6e 100644 --- a/xen/include/xen/preempt.h +++ b/xen/include/xen/preempt.h @@ -9,21 +9,20 @@ #ifndef __XEN_PREEMPT_H__ #define __XEN_PREEMPT_H__ +#include #include #include -DECLARE_PER_CPU(unsigned int, __preempt_count); +DECLARE_PER_CPU(atomic_t, __preempt_count); #define preempt_count() (this_cpu(__preempt_count)) #define preempt_disable() do { \ - preempt_count()++; \ - barrier(); \ + atomic_inc(&preempt_count()); \ } while (0) #define preempt_enable() do { \ - barrier(); \ - preempt_count()--; \ + atomic_dec(&preempt_count()); \ } while (0) bool_t in_atomic(void); From patchwork Tue Feb 23 02:34:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099775 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 4E8EAC4332E for ; Tue, 23 Feb 2021 02:35:28 +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 0E31464E41 for ; Tue, 23 Feb 2021 02:35:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E31464E41 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.88519.166467 (Exim 4.92) (envelope-from ) id 1lENXf-0004IF-75; Tue, 23 Feb 2021 02:35:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88519.166467; Tue, 23 Feb 2021 02:35:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXf-0004I4-1Y; Tue, 23 Feb 2021 02:35:15 +0000 Received: by outflank-mailman (input) for mailman id 88519; Tue, 23 Feb 2021 02:35:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXd-00046u-V9 for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:13 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 721913e0-99e5-4f4c-9933-dbdb10ca54f0; Tue, 23 Feb 2021 02:35:04 +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 11N2QQxk004083; Tue, 23 Feb 2021 02:35:01 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-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:01 +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:57 +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:57 +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: 721913e0-99e5-4f4c-9933-dbdb10ca54f0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8UsQ/zNRlGvj/CMCAtMQlV8xoeGe/qY82ASPb8bsv1EJdfCD5A166Brx+0DHQCkbAvOD1j0OJ7Rury/pO+pMG69Q/YnB0J4EimaaZTI77s1IgEpb5JMteMdHZxmAd3/fcXj8hcFvvZRcIGP8pKEw691wnOqPbCHPzi1y+rFYFCe7dafaFJOy1ewuh04VM4e5PmlkjjRuWqsmOCYtuXQ7XdgDKEKawldJ28zOD/M2QkCa4xC9uFKERuBr1193ecVyrBJ36iqOouoStzvs5ZUhysNObYjnBrSzNwAQx6pXyFMnQxtpn8PsAXILqS3kEDPb/L3LGD3JgM9JKJMgVl+ZA== 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=Z7bkZJeAVBuSp9Gyc797wEvVdAIwSUhCtPUTvuKcVEE=; b=CYpIuVSxRvIsnDd2YCEd7pN6Q2wWhZkEbUaFx1JQjeRvPZMICDtYtdkrltjVN2DVPhhiVnZIi8XIZgD66iqoAQxRa0OIevf6+98UwhOkgJnMKEcR4M0DeP8JqnTaBJ5ZCCmRqtj7aWvozqUrzlFzy2/jHz7mLGdtotJE8iDlNmSL6lVsTVrotp7CO7IYSlocaAJGuXH+DDRX35mzl3tWxTPICziYo273iHLH94nocdeZE6XarCAN/VlClsVDF3kMAN/ej0AsGgp/xrtN4z1WIo3pC7vcR7KsBLcap9yYpc/UwOpHxpm4ZkcPflDVVejpyNHP4hlAZArV8Zs+Jr8xZQ== 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=Z7bkZJeAVBuSp9Gyc797wEvVdAIwSUhCtPUTvuKcVEE=; b=fugEaoUmhgNcWbKy3Jbn87JBECOIM+DBEd6OK4KY7VQk/TriVRWxJk6qYa7HtezQvBznJSNn+ZTLSAgIcJnaIkFaLpNavDiz0NF1XaIVdryoRNv9EQ5AY0OVPVLQB+eEQOR6BuZR6rf6aTnoNr7qVFa3c5HON/7uS1hZ2Ymc57BwP1WOwD7rRZur3oh/ld2uDMH6fYdLCuQv+7p+3am8SWVwVLfv1D/gcWzaN77wVi5MYadAMGYDzavi2Wn74YFXwUmiGvt52nM2qpcWuE7snspokLwC5qfXGGxIg06VXhiJJkmXXSLjw8pMS05qZtKGrs8nqu1JhtoSUKdjhjYPgQ== 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 05/10] preempt: add try_preempt() function Thread-Topic: [RFC PATCH 05/10] preempt: add try_preempt() function Thread-Index: AQHXCYx5ySuVthNLHUKZmgWg9dU+LA== Date: Tue, 23 Feb 2021 02:34:57 +0000 Message-ID: <20210223023428.757694-6-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: cd8759b3-5f5f-4e1d-6730-08d8d7a39c3a x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MhrIJOptljGFO3p3aYiupiRFD8WDZIGxT2LOroitiU2FYLsNLy7sqcVLaps+dEwnuLF3/B0VeWLSmp9kMqOwUNMUwxNGBmFGb3bfU+ayslZjWk5NTxo/vcsyCSNuq4VuSrqDxh9hCoolxbKYuHdT4VhAisIJZLEKLHFN3bIx5LW6B3zD8trTDrXqaoT8LB0RmRjrgzrEYL3cD2HFGtyouUKWbcckqSHPiukVbyphSDHHzPoO5S5crIdGmq3HZ4+vHEGmFJ+yiC7tjm9b8vu+4hDdX47/oEqsshLksylKgiNtQQiqG8AVpodCEPnbbWgYfXAtpjpLG2k1ubpiV6fHK8RvywkJbj9i+jvPBqAgKDVISDp5V4yygJMAxuWGdwDdmoIfPHO3gd4y8eiZEvjGnDiI1EoLbDOr9rzOJZd7UBBtvTwhPILjAFygF4GvV2YVZLquqy56zcDiiAm/mVXdusTU1Pbeze/qvRrjh/XX5CojxnnGTc2GFcFDJ4Eg4jaZYmFdnDDZ/hNkh9X4zE/VKfxnig3dcOdwDVQSi2tCo2gTrJ1PkZY0Z3pRE9EXtYU2 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)(2004002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?C1Exbo5RCcolDWAgr5FgqW9T4?= =?iso-8859-1?q?dHuKN7wXk1WlE6QoaYMt3/QR1CBY5yMyg+2D24BJ3NSotM7zkk2mZMWCAmhn?= =?iso-8859-1?q?bLt/wWPdLJ7Y9FXTRsfHk3wp5MW2fVwAIzDfTNT1dP09xdNj8K1yimvDhXuI?= =?iso-8859-1?q?/Wt/qFAzGjIFFhH8sK2sm/Mzy+tD8+o1wi/WFMoPwDe1kdTl+Fx+AUvOEJOc?= =?iso-8859-1?q?XelS1/IFBqKNhw5SsvyAsiDu5Hi0oCObvbQxjZVj6uSBFaRzVCHwHc2Hts/a?= =?iso-8859-1?q?tlvdpkrKFRNaMGzIxnXySxacjEl/2Xbtd0LW6pOBtD7D+k2QiD+AbMnbO8Hg?= =?iso-8859-1?q?zRGhXfReETtTyRX+8DBTGKHOTGGZUgk4gD4UHMjL82XaDidijtKV/kL82bFG?= =?iso-8859-1?q?iCOrG3Oa6vQYh0hgNzN3E9LZgCKdF3J2JqPfZsQbtDooM62A8HvfntxEEsF8?= =?iso-8859-1?q?i7KBgsvFbL0s3vPx9oTIGaWcIfYH2OlXjHOgZEXq4pf0MlVwOt3+PP5dykDL?= =?iso-8859-1?q?/YjAQ6hibiTraP6BUtaRzPycX4oh0khilItJFU0RjafR5CN+pufeBKBBtNC5?= =?iso-8859-1?q?is2ebEZPKF5cW+58GNmC2Ei4XyMh5fOlQtqZVwhIIegbiniPPM2tbqv/IxLy?= =?iso-8859-1?q?VTvvJu4ruzA2MFRIQkudW9ml837l+lipmZ2oq3vUuagg3uTKgJynF4tHjnEi?= =?iso-8859-1?q?UwIhfLfoL/ijxZ37CYHejZ6hqLrbxriYWVzNoy1f3YoEJxCuBFQ9bHXGc9lK?= =?iso-8859-1?q?d6pTct07FMbRkAI0ujDIqIVpW8zNFpdJzD+uIBNmkrpogCnhmCeQDaF2N18x?= =?iso-8859-1?q?Z6a1MeGvEJgX8eCSpwoyTznVHZnZ3T4AycK1yXN93jcShE3QNY22aHpshMt9?= =?iso-8859-1?q?xss1yBFbmArwxBXGampv6cCzKeq8EqMbVztDjdyGK8o3asYWAGNXcFbQFDTt?= =?iso-8859-1?q?Rf8JLqN5ImzLEq120yznvmt8PARzJmWbPvZ0EkVKrEB1D2ymyvNFy4t1BZaS?= =?iso-8859-1?q?0araHVAEuGIAY6lsNOHGILwlrHAXM5q4+8rfpAv/XyYCy4QOZxPfo/xeZuqj?= =?iso-8859-1?q?gZf2ZfPBcFAbf01NbtfQ8rcUwAMELEAHqwdSt4+GfUIlCjR2VIGt4I581ILE?= =?iso-8859-1?q?y0VOMh9H4EK5abNhUj9saOQ7DN7KUXsOov0MAVN5Ul1lO69jWSlTr9TkjaTw?= =?iso-8859-1?q?T+V+1h5yudbJB1ovkxGDLGQQWoFs4dt2/R3DKQsW84qrNyrYShvI+NzG6FRc?= =?iso-8859-1?q?fLp9CJ2RxX2oABKj8zZvp43q96J28zlUNGEIQtZKlbNTHclhzkQIm6Ydko9v?= =?iso-8859-1?q?pXeFc4rCkvIY07ZzE9BWGnog9LwTVSU3MLdDXy/1DqfysZpf1nMMKs8dnfu?= 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: cd8759b3-5f5f-4e1d-6730-08d8d7a39c3a X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:57.0931 (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: qcl/SXjF/ndaYdz1kJRPCFAz+NiQgEIuok3cm7vSoPoHTV2w2VNmvDV06qtTrEUkCfmcB2esxfpMFdKF46OwRDcnBE1H6bpwUqNf/cj+3bo= 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=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 This function can be used to preempt code running in hypervisor mode. Generally, there are two reasons to preempt while in HYP mode: 1. IRQ arrived. This may woke vCPU with higher scheduling priority. 2. Exit from atomic context. While we were in atomic context, state of the system may changed and we need to reschedule. It is very inefficient to call scheduler each time we leave atomic context, so very simple optimists is used. There are cases when we *know* that there might be reasons for preemption. One example - is IRQ. In this case we call try_preempt(true). This will force rescheduling if we are outside atomic context or it will ensure that scheduler will be called right after leaving atomic context. This is done by calling try_preempt(false) when we are leaving atomic context. try_preempt(false) will check if there was call to try_preempt(true) in atomic context and call scheduler only in this case. Also macro preempt_enable_no_sched() is introduced. It is meant to be used by scheduler itself, because we don't want to initiate rescheduling inside scheduler code. Signed-off-by: Volodymyr Babchuk --- xen/common/preempt.c | 32 +++++++++++++++++++++++++++++++- xen/include/xen/preempt.h | 8 ++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/xen/common/preempt.c b/xen/common/preempt.c index ad61c8419a..98699aaa1f 100644 --- a/xen/common/preempt.c +++ b/xen/common/preempt.c @@ -4,6 +4,7 @@ * Track atomic regions in the hypervisor which disallow sleeping. * * Copyright (c) 2010, Keir Fraser + * Copyright (c) 2021, EPAM Systems * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,13 +22,42 @@ #include #include +#include +#include #include DEFINE_PER_CPU(atomic_t, __preempt_count); +DEFINE_PER_CPU(unsigned int, need_reschedule); bool_t in_atomic(void) { - return atomic_read(&preempt_count()) || in_irq() || local_irq_is_enabled(); + return atomic_read(&preempt_count()) || in_irq(); +} + +void try_preempt(bool force) +{ + /* + * If caller wants us to call the scheduler, but we are in atomic + * context - update the flag. We will try preemption upon exit + * from atomic context. + */ + if ( force && in_atomic() ) + { + this_cpu(need_reschedule) = 1; + return; + } + + /* idle vCPU schedules via soft IRQs */ + if ( unlikely(system_state != SYS_STATE_active) || + in_atomic() || + is_idle_vcpu(current) ) + return; + + if ( force || this_cpu(need_reschedule) ) + { + this_cpu(need_reschedule) = 0; + wait(); + } } #ifndef NDEBUG diff --git a/xen/include/xen/preempt.h b/xen/include/xen/preempt.h index e217900d6e..df7352a75e 100644 --- a/xen/include/xen/preempt.h +++ b/xen/include/xen/preempt.h @@ -4,6 +4,7 @@ * Track atomic regions in the hypervisor which disallow sleeping. * * Copyright (c) 2010, Keir Fraser + * Copyright (c) 2021, EPAM Systems */ #ifndef __XEN_PREEMPT_H__ @@ -15,6 +16,8 @@ DECLARE_PER_CPU(atomic_t, __preempt_count); +void try_preempt(bool force); + #define preempt_count() (this_cpu(__preempt_count)) #define preempt_disable() do { \ @@ -23,6 +26,11 @@ DECLARE_PER_CPU(atomic_t, __preempt_count); #define preempt_enable() do { \ atomic_dec(&preempt_count()); \ + try_preempt(false); \ +} while (0) + +#define preempt_enable_no_sched() do { \ + atomic_dec(&preempt_count()); \ } while (0) bool_t in_atomic(void); From patchwork Tue Feb 23 02:34:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099783 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 A0521C433DB for ; Tue, 23 Feb 2021 02:35:32 +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 6668E64E3F for ; Tue, 23 Feb 2021 02:35:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6668E64E3F 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.88522.166503 (Exim 4.92) (envelope-from ) id 1lENXn-0004YE-T0; Tue, 23 Feb 2021 02:35:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88522.166503; Tue, 23 Feb 2021 02:35:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXn-0004Y4-O7; Tue, 23 Feb 2021 02:35:23 +0000 Received: by outflank-mailman (input) for mailman id 88522; Tue, 23 Feb 2021 02:35:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXm-00046p-7Z for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:22 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f8d010ed-a512-4352-a189-d6758d431a56; Tue, 23 Feb 2021 02:35:03 +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 11N2QQxl004083; Tue, 23 Feb 2021 02:35:02 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-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:02 +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:57 +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:57 +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: f8d010ed-a512-4352-a189-d6758d431a56 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTYi1KQbJDEeKaNrH+9ZtzE8sQo9fUaORjGHgdOBdARb2sqabg1zjHLer1dQcSoG3XRHIKE78LuNikZfsJROfhzRpToPesYTfDXQFX+drh7OXUGViT09G5HFGQa18UhGQAc7FYvsGfj+NB58B9WdTyIuwYMj+XFRVhyrv6ICTz60AmZcfTDHqO/zdez3sCzNP2M+y5ODBO+JlYDIiMrZoIFTBoCPtMV2teHLn82l4a6bzumgFgBkbF0zqEGV7sASrNYQnUPLcu6wV7YwokkYY56x5g4n3NoVfh9vPbzc1i7FvjdiGxrYZRQdkIBOTdlfQr4iqOhKjexy/B5FL23Bfg== 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=ZXx2B0ALYb183P5HVU3xyAVbUZAXMNspxc3XMEA+DN0=; b=MWpOqoNz4KU/wu/bP6KfsIS0TEsUSMSClO3p4gBuITAXlXsZw0YgreYE51mefXNtx/vrv+Ex/XywPqTCEJhXF6pe/LuMC6hz/peNpkFw7vIKTzelCCo0czVUbSn1Xzr14NZ4Q7HAqWmqlWYswaSvhnsfZ7lx6/GqLr9wugtdMUpwHLtD8JdmSdA9Hwt0QO3Lb6W0J64nKOpVVBhjzLwQk+9MH+ncBLdGLieDRUiOTflKLHwO+VemP7MQW8skIv+tdV7LH9YYY9tprp89M4P91UMu3d5uLBvya4A6PiRfL4EOM7tmOSQx/g1yC/uxPczmXc8AscFs00O1Q4s43L+zfw== 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=ZXx2B0ALYb183P5HVU3xyAVbUZAXMNspxc3XMEA+DN0=; b=Oa1Kttm1BZZLoZhU2dHDs6moFOM8D7ZPERcj6v8svvPn0H2TmmLcMt6gTS9MgttWiKCCd5BOL3EP1EWFjW2TAb9bpG/5M4C95wWDg0HJVqpdUGLCG3RF/tvxDzOYWMQVxigEN+R4cQvOCUp4FdSMzyHQdtj9dF7XWCfNHKB1X8353T6iUA643LlVG8qre6azxFd8stdTEk/WuXO39EefurxWx/IdzQkzhXrxeYP+0od9aO8eNWRcJYktou7rbAmFZzFuTIUpcU6MXt0AP08JVH8F1iqkZ37tDk8cb/rriqqaGeLT0jrl7fs/Ci6O43Ftv92rv3HDiJf7u/EZs5itOg== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [RFC PATCH 06/10] arm: setup: disable preemption during startup Thread-Topic: [RFC PATCH 06/10] arm: setup: disable preemption during startup Thread-Index: AQHXCYx5K2kzQwNs80ySE93i7jtdRg== Date: Tue, 23 Feb 2021 02:34:57 +0000 Message-ID: <20210223023428.757694-7-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: ce111a5f-bbea-45ee-3d0e-08d8d7a39c67 x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4714; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cSdecW6WPoe9LB+WlAGvJQ84X3CaS7/RSWKbEWrTpW7SSRqU9UVo79qjl9b7oJTvmeK5cV8LdlqLN/l0JuDR4TvZugxgSmU57Nzn+cDyoBrpkAsC1py4+k28u5qx5I9S84eqE2RF769ZcCVaPYP+sDqisx2RnUxYLWEfwtCCnvbAASB4FokEd/wvZoKm6WNcIWxUiuOt3fSj4PE5NnfxYnxbpNl7DC6XpIwxsRoQgb38xlpSjJ+NdlVQWYRXdbnewBCXa7yXhTBPW3+d/PfhE/9K1XxXdjCcSk8T9cyPI8/YeypJxj4RzjrrWz4nUstpIYheTzHxr+qyCbw0CGDW8SWHZvfG6dKrf1heJYlTLgMb+lDLfELEDap5Gf35QqNz4ECHFDcfHSmVHI03SsDRECgbC2yULM2r5MnyybHouFbVWBYpl3LhGeQGeglofHg154Sj8mArdNEDxnLxnmMj0fTz7XDXSpVY5m32dTJAgl9dDQrREOQQq5isWOslmgg7+koL8phO5pORJAkzCRiT0w== 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)(4744005)(8936002)(8676002)(86362001)(2906002)(4326008)(478600001)(6486002)(186003)(107886003)(54906003)(66556008)(55236004)(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?ppOJi/8P8oq+XZHJ+oFQMSc+h?= =?iso-8859-1?q?/swovuz7JkKwn0FF7Jsll5+ZY7hfsg/0qHf392GJdsE+U2asyKtQpzj6LE5K?= =?iso-8859-1?q?sqKcfQYwAw57dZx9z+3SNAvgHHwKeBCsSHrg9ChWmPDFr8QlmWT7GeKvXnpL?= =?iso-8859-1?q?r6T8LJABevFh83RTyBcBfEqsLmjKnqzax37jMUuM4oUwzdrKUHLNlJafDRSL?= =?iso-8859-1?q?6CGOk8tjAeA0ZFXyDvztiAoCzNho8yz4yApKhdpvspiqAO1LvGqQUTTPnRjH?= =?iso-8859-1?q?DoH1YmzcS4dGnBYtfDP5y69G2CCxrmpAzdJwihstsvR3e28HrnbGUREjZKbz?= =?iso-8859-1?q?f8D6ZBnIgRvACYdJecyMP9TIBSrSLU20VSnmfpm8/6yIeIWIUX3yPiWepp/Z?= =?iso-8859-1?q?cRVKdmM/Xy3I+tkk/aCt/neEDPmoeSHfWuOwVubykgmSUe/kzQ7Yo1mNUZ5F?= =?iso-8859-1?q?z2v5516n5dbGIuKznatLa5tsLmGZzsZefrh9XTGKt/eBuK7ERpQQ6ATxgOnY?= =?iso-8859-1?q?u241wkuAJYzrFrSHTWQ8LFcK1yii/rO4OI/xve/Z91yN3hndezWjtv7Aeax6?= =?iso-8859-1?q?9wepxYy+v+Ww53TdUu92PQzVmiAsIiIK1b+RcX3JKZFe4YQuBFErdyxwmBEm?= =?iso-8859-1?q?M/YNtlH424BizHPA9mvMuHkt+y6hYn0EFaCwGc5Yw0nK2J/0GWrcXMT+oo4B?= =?iso-8859-1?q?m0RwLa/SMtRMAZfGQ5opzvJTIsQ0exx2qy5NZqeeW23eYvFBL7ImbprFvSG4?= =?iso-8859-1?q?b6MYDo8PyHFUiI/91fV8C8CxFhlh6t7pkCVsiX3Z2dCWowpe0nizDCzEeJMF?= =?iso-8859-1?q?cZYM/ezxEGedH1O0iPmx0jXIj7ft6M8lMbprpJ3R26vuOxajr3WymRRrx63u?= =?iso-8859-1?q?9lJv5RRDAc9c+QxxzEC4zd9sD1/DlJOxjJLYWXHmJV2HUEQcQ3VBPrj2t12q?= =?iso-8859-1?q?yn2R9tqwWodb0eYLNJYZvgxm5Z1hTi8o6PAvrByi7TPzEo/wQO6My5Is++Ha?= =?iso-8859-1?q?8Az88KfE2Ix820Z/xTn5RKwSJ9UHifArbjykASAxQ6NgDUiD0ySA4ev+LpgL?= =?iso-8859-1?q?YiOJZXDypoP5XA5YbCYK8asnQqQct+92CuYsWSsIVoOkoKwvi3RZQqzFIl/U?= =?iso-8859-1?q?bCjM20JIv4V+V4xEhcY89nrSqbU/qrBpuBRTbG/wacVXwhihFdaeoYzFXj0/?= =?iso-8859-1?q?SrGkup0/ae/RO55/UrqGAXThDSWR8KhwTeYEkfnEyom533fyjez3ZpEAxDQc?= =?iso-8859-1?q?8VZuOyumyLeZL49hmkmVpkFMXVOv6kVZ/CPi1bnitWJWZTSe692FsKiot3nj?= =?iso-8859-1?q?Z/+4U+IITnm+BW/saswZ6ypRlOmU4ARAhrtdEiGTilYsLChEgVHjFqNX+9P?= 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: ce111a5f-bbea-45ee-3d0e-08d8d7a39c67 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:57.4389 (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: OkQcUQgbc8b2ynvWj4QyAsST9R3nPGDvp11O5xsLzt51L6BvKTjzPyMVejIzbWkmvppAB00my1Dt+KU3NcY87TcpaHPRUXJ1HTF2BGSwLas= 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=697 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 In the subsequent patches we will enable preemption in the hypervisor mode. But we don't want any preemption attempts while system is still not ready to call scheduler. So we should disable preemption during early boot stages and enable it only when we switched to idle vCPU stack. Signed-off-by: Volodymyr Babchuk --- xen/arch/arm/setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 2532ec9739..15a618b87c 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -78,6 +78,9 @@ static __used void init_done(void) unregister_init_virtual_region(); free_init_memory(); + + preempt_enable(); + startup_cpu_idle_loop(); } @@ -920,6 +923,7 @@ void __init start_xen(unsigned long boot_phys_offset, setup_system_domains(); + preempt_disable(); local_irq_enable(); local_abort_enable(); From patchwork Tue Feb 23 02:34:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12099779 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 7285EC433E0 for ; Tue, 23 Feb 2021 02:35:29 +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 2F7D164E3F for ; Tue, 23 Feb 2021 02:35:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F7D164E3F 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.88521.166491 (Exim 4.92) (envelope-from ) id 1lENXk-0004S6-E3; Tue, 23 Feb 2021 02:35:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88521.166491; Tue, 23 Feb 2021 02:35:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXk-0004Rr-9P; Tue, 23 Feb 2021 02:35:20 +0000 Received: by outflank-mailman (input) for mailman id 88521; Tue, 23 Feb 2021 02:35:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXi-00046u-VJ for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:18 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6ea283e0-94ff-4ea6-bb64-eeaed80d9b46; Tue, 23 Feb 2021 02:35:05 +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 11N2QQxm004083; Tue, 23 Feb 2021 02:35:02 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-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:02 +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:57 +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:57 +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: 6ea283e0-94ff-4ea6-bb64-eeaed80d9b46 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJ/RULMdgalRbvZotrK5nfc7rXQK1j/F446yQM56m7iTrFl7wQDqOqnUfVP4cRNqd6CU9f6OQ4ueYtxBXEgHYA03VueY2wPKHHQ2Mqlz7Z4rvD01DUgmy0sAtPGKFIs4pPS1ABJSWwWo1YKi96vTuDT8s1eRFELE8IQ0V36Owz9PdFHpFCAvs5Bl4Ra07pvMw54phxWQz94k7oQhY9EMy0TBUE41Pxvjt9GZbR4XGrF6a1QCF7T4CYI1/zm6Ks+rPrelTZSJY3IBFo7H3NsmTP/Kk1qFppfY4HjuAaRjYZEXCL5+i43R3BTN5Dw4lFUvEVsHaUEQ410RC/Pl/lGd9g== 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=RJ3Oo6oW3QM/2RenEoHxu7guFzqOYawmzOzsPjipV9A=; b=CRQMvXLU9l5QR74h3fPdBG7DkRd7VfhVo271EAwyVa/yOlqv3n8uGjPDf1JqKXmYs/PxCbj6D+Khigar0oE80/K2ZuGDg7iz0ur4NdE48tJQU6NM0d+rbusjKQQ/DJlzPp42VwMyTuRN8roeOlXCqJasIzwFuMdvr4i29DaZ5F7dW90R3/rKKWUXZy5PhXGjbFGPor1EDdgyogyuDszaYALhLHX/paM6ZOxOXAJ7O4VyJgxvt4ye9btYGO6wjFuDfZCINKKc6/4zCi9Mt9XQbOfLd92pIjJawHiLP2RZjymZVzs5ntmuoiY1YiIGp2l8bAXdU/iadoLaARxV3Bqzpw== 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=RJ3Oo6oW3QM/2RenEoHxu7guFzqOYawmzOzsPjipV9A=; b=PA/NgIOnELMKF1eicJyP4XIVSkYfMYol+d1JCZBpxdzRl5SPwCuq6Wm/o+hio/FKiZDzGD+0e33m0oQ+jks5R5eEdfv/DPUJ9YuxqYugXehSLxBc/pmpdvnaJ0sh+zU/jG7h0Z+KGTeDpLxEK6xx6wIG8f6Cop+niXl5CDC2nq9ETn6SXceO8S2FdPEv37AeUdibcQmDt8KUbn+372+4RU3JGULaOQE58GU5vdw0iei+ko/FbIkt3LJ7NXIydEMExr89Ep1Q/NVtkg94bXYIAbrBtMCxCSDAaWty250QO1MTGm+HuqOUsh6mGtdKpCklDuYbth/4tsV8PNHY8GxGkg== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , George Dunlap , Dario Faggioli Subject: [RFC PATCH 07/10] sched: core: remove ASSERT_NOT_IN_ATOMIC and disable preemption[!] Thread-Topic: [RFC PATCH 07/10] sched: core: remove ASSERT_NOT_IN_ATOMIC and disable preemption[!] Thread-Index: AQHXCYx5ZDmFTcXHSEWdjEjbMIYFyA== Date: Tue, 23 Feb 2021 02:34:57 +0000 Message-ID: <20210223023428.757694-8-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: d6422711-5b25-4811-b388-08d8d7a39c92 x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: a+1bqIrVGzfSkrkhvCp/EBx4rw4UYEFp2oFrCpBgOfRdi3eA5DxBXJz4pt6InB7WTvDyWIwcTn+vfkK8ZupqvtooNii1+G2GMmpGCSEcZ5qSkzvFPUmATauxtUAZrCV27KRJxK4M2VHxw5ZnQJO0qC5shS6J42V3m5yTy0jCoIUBA8PNPJSXBuTj27ve7bnFjTXQLsXbR4uRg0KptKd/AX3tmpKJU9LY3LVl5XRY2ekgQTklDqSnsw9LVhD4UnkCoNoEWr6h7cs1PX5NecOpwDz0Q+dIxNE2ib/jMmC1A+JNwQwwSdnzTkzVjxXUonkpg6JI+LF+8V3tVyVZQwW+VhuEO2Ar+PCIgq3cwfb2TRMFpUxCzuxSiZnO05lJfLLHzymeQ7KDLU7SD0iG3B9rqPkpMgFRJg7zGWIVtfC5lmI3m6NqDuC8CV5HXbhbIpmksooHkCcC7hK1/LhvaYg3r0gAIls3aA9AsCFQdK9+f5HOBwYX4Xxdesrw1zXq3yujeHwpNHBUX/NxvDAdzORZ5muDIQtoXC6No+yZg0SvfUUIkcOqElNlKLF0wNBSL0Sc 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)(21314003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?LyL77pT6OA7J4vHWTKqlSDgwK?= =?iso-8859-1?q?jVqk7XTV4KAB10ixS6OyDeB+/zRELBkhDul1zKCzUpfL8ctBQ9VTV+gMT1cE?= =?iso-8859-1?q?LsFmBTYS7haQax1gwJypSUwXLo5s8sfdjn5nbWUQEeRiQ87lgJ24m8QiMye0?= =?iso-8859-1?q?y3Zi/EHWnF8dIoEWkeQpC9GnZu2ujS/bJnwkJqmk+LGp0Lv7s0XSEYJqsrqf?= =?iso-8859-1?q?E7NO4SW69oBhk7suwfJ36qEOiVf2MD8FMjuxUBA03DcUYgyB3ju3bVVILHvL?= =?iso-8859-1?q?P1yJK/XApQlpy1emHm0sCCzJyz7XHXtBCG2h+Rzvpyt1E+irql4T52gMtPtX?= =?iso-8859-1?q?hb4Ui1uPLTRfOV2eRFBzd4mILoszlHFAf8LPQvWGSuNnn8uncUFuhuqah27x?= =?iso-8859-1?q?WHeeh4W8pD+HnPcH18dgCgUfLu2slE+G2PCgr6IEmz4NZdz9FLPZKFvhhWLG?= =?iso-8859-1?q?5samGTDUSK1lL8LQTSryVsbKEL+mTkjQKvxaMiGsSAfbu3uEWmxg5NYZiCSC?= =?iso-8859-1?q?jbSpDizMcfpRVc2zsw0zC3UB3eczDUxb2chAM9KpxmV0/Sk2n4e0DWCaSz+A?= =?iso-8859-1?q?ESKJBAMbrdSTsB8+GQFzZQXaJLeM64g5Y1jCvaHi5PqR08TB++gzNJ53m9aQ?= =?iso-8859-1?q?9bp0EUHKZ6tarCRIfbcgmoZsNBrILp7CkUj3ytBD9XNrdpLwPQ3yczv4NWPF?= =?iso-8859-1?q?tcWz/N8HDYQoLt56N9MSfYknJQUWdh3hg3EOUFnNrkVuA7pZ7wL5CCio56Vb?= =?iso-8859-1?q?hGHXh9ETA9zeObfjvi3BP28INpJwveVhd02yjDnixWFDh4TROIWXNBEfjGRt?= =?iso-8859-1?q?v00NwMGTl9XN2bkOkJesd4KkCRIGG4iYNZ4jtJ3Dae3ckUpDIEHYHcu4J08r?= =?iso-8859-1?q?/dp7NOj1Rmc0eb+UnoYZSOct8ZmbATE5R+w3Djbqvn+tJ9tWc3Vw9iueGT8H?= =?iso-8859-1?q?LQ8ZvuOrQW6MiqYOVSAeE25bHmm5Xd29q7fgY3VYCTQXxbgZoa+KFl8qd/Wt?= =?iso-8859-1?q?MIGwDBNnXiMYSq9/2IkszYv2R3Q6DZtnLkLPHYOVC7RkuL9IDBxqY6nZqdLd?= =?iso-8859-1?q?xXdB15DV2EeryUjPTwkoWdyukS6sfuKa4RHhG0ZmLgqhAyJTEUE1DdMuR6yd?= =?iso-8859-1?q?VNObkHJr7/gbYMkbyROwvbfycNOjxBwPDtLxqt20tAaFWemusAfHGrFWqdmR?= =?iso-8859-1?q?DkLIhK83o7BPfJyhp3mz6MEp1rORLpnZJx2GJxv+HNUyTmcFAnpastZ0nHXa?= =?iso-8859-1?q?NyZS+8As2AIeq1qFyNqc/PM2HJe78pDK20yjmmWQxl0yNda60N+uxJD4+SZn?= =?iso-8859-1?q?sNFFiPM06KzbsW850sWaKMLvJc6aDvVQg29hZN5BPMPkcuRuXcLZ+3qhpy6?= 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: d6422711-5b25-4811-b388-08d8d7a39c92 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:57.6927 (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: m9QhMp75F3EOHtlT/s8/uzUSCd6VqiDIiNrIDY6FOKZKMWYdtpA3VhLKl7zjCkGrG8GqJ1hqUC9r8mrbAfT3ztaXBputB9GiqfXZr+XgzdE= 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=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 ASSERT_NOT_IN_ATOMIC() is very strict, because it checks that local IRQs are disabled. But there is a case when this is okay: when we finished handling IRQ in hypervisor mode we might want to preempt current vCPU. In this case scheduler will be called with local IRQs disabled. On other hand, we want to ensure that scheduler code is not preempted itself. So we need to disable preemption while doing scheduling. WARNING! This patch works only for ARM code, because ARM code returns after call to sched_context_switch() and it is able to enable preemption back. In case of x86 further investigation required. Signed-off-by: Volodymyr Babchuk --- xen/arch/arm/domain.c | 3 +++ xen/common/sched/core.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index bdd3d3e5b5..2ccf4449ea 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -335,6 +335,9 @@ static void continue_new_vcpu(struct vcpu *prev) schedule_tail(prev); + /* This matches preempt_disable() in schedule() */ + preempt_enable_no_sched(); + if ( is_idle_vcpu(current) ) reset_stack_and_jump(idle_loop); else if ( is_32bit_domain(current->domain) ) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 7e075613d5..057b558367 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2577,8 +2577,6 @@ static void sched_slave(void) unsigned int cpu = smp_processor_id(); unsigned long flags; - ASSERT_NOT_IN_ATOMIC(); - rcu_read_lock(&sched_res_rculock); lock = pcpu_schedule_lock_irqsave(cpu, &flags); @@ -2643,7 +2641,7 @@ static void schedule(void) int cpu = smp_processor_id(); unsigned int gran; - ASSERT_NOT_IN_ATOMIC(); + preempt_disable(); SCHED_STAT_CRANK(sched_run); @@ -2665,6 +2663,9 @@ static void schedule(void) rcu_read_unlock(&sched_res_rculock); raise_softirq(SCHEDULE_SOFTIRQ); + + preempt_enable_no_sched(); + return sched_slave(); } @@ -2681,7 +2682,10 @@ static void schedule(void) cpumask_raise_softirq(mask, SCHED_SLAVE_SOFTIRQ); next = sched_wait_rendezvous_in(prev, &lock, &flags, cpu, now); if ( !next ) + { + preempt_enable_no_sched(); return; + } } else { @@ -2695,6 +2699,9 @@ static void schedule(void) vnext = sched_unit2vcpu_cpu(next, cpu); sched_context_switch(vprev, vnext, !is_idle_unit(prev) && is_idle_unit(next), now); + + /* XXX: Move me */ + preempt_enable_no_sched(); } /* The scheduler timer: force a run through the scheduler */ 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: 12099773 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 30869C433E9 for ; Tue, 23 Feb 2021 02:35:27 +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 E867064E41 for ; Tue, 23 Feb 2021 02:35:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E867064E41 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.88520.166479 (Exim 4.92) (envelope-from ) id 1lENXi-0004Oa-Qv; Tue, 23 Feb 2021 02:35:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88520.166479; Tue, 23 Feb 2021 02:35:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXi-0004OL-Kq; Tue, 23 Feb 2021 02:35:18 +0000 Received: by outflank-mailman (input) for mailman id 88520; Tue, 23 Feb 2021 02:35:17 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXh-00046p-7O for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:17 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d276e0e6-dacc-4b09-8b8b-b647f20e8e58; Tue, 23 Feb 2021 02:35:04 +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 11N2QQxn004083; Tue, 23 Feb 2021 02:35:03 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-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:03 +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:58 +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:58 +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: d276e0e6-dacc-4b09-8b8b-b647f20e8e58 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fnsoOYeaZ5ap723wZNcX5IBljYGd+jOoU5tg7D29IJwkoifiWlQ29yEkQiI8det8eYG/walXrTRJaZunRIUKKe0Bd/7fH4yHvsMgJRkL3DVPW4If/ciKu5l60yOozxyg+BzaePt+nhASfCNSynePIhSdxXXvBLDPisGHfiJDx8+suA9ZzYWcFnnfm3zXx+Sp9PDGjHlN+NHGp5XEQgO6kPFwoJm1dQVDmYOCCjNLce5cPG6JgsgzJQpctQtr6pBOEGHJw5erGcc0FG6H2pOg9qq1UPpFjaRZSMbky0z4E+zjtkT4Bw8DZ1rDLvfoeucJr7QBhzqTvjzJR/baKYaxZw== 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=hLZbFCdGG+G9vwfGEiWEMpY27lBaZZM8a/Rntb3OeZ8=; b=XqiDlF5qgZCsTMuVSdUW8Hdg2NKXBhCKIyUORsD7cXbl6M67tEHTLL3zeCHiRTppAhFCAZFM8R1VWgAmlo5Q6hMX8CQt9HdGAoucy6LOaa9+z7XShl2z2tmWdLOiQxSjtjvNRM73OxJYmH2Q3DMf5q6ae2hcakNiU+Mud+4mRFAAvCbNWaA7q/CHzIF/ExtnMKATPuE6OLH2kEM8BDXWjF9TY+wZ1zDiuXntkBQ4rOTVEZ2TASIaxObDlVSMkdm/rLqoTnfd82Pl5CjoE/LIkl5LkdYz0xyIxcWOWqL5BzMTxEfVKtwTD/0xVKW2QPjgKBU8ThTfFwYHoVGQmmb5DQ== 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=hLZbFCdGG+G9vwfGEiWEMpY27lBaZZM8a/Rntb3OeZ8=; b=Do3kY2ktfT4pYTe7de5Zbtc88uic2L7hP81FVFySkF7qxPtAh29/ZPU1KdwcDTJjFKwnztvJgCyqK5oD+3eAXyEOsN5OQBGmQgTYOtsTqF8nPwf/D8ZyBJefnzLDFZ3rU94UjLooLPg544Dc+mFWifGqzo0gaSSX6AZmdImWfIIPbcePrIRmIybL7qKzSCmF0La6Y8+b2k3ABye/a/3uRetkNl0t67+4T3mryyXPzcwh1G3e84qDSTTZ84uGBfv1/RFngz0JvfKe0ewOT/R5ATI8sqwy8A2W0Te9TdxSKneqwaUG0DwMPnfkgVWaLHiuDveKZeXbP14J24hPlgzJoQ== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [RFC PATCH 08/10] arm: context_switch: allow to run with IRQs already disabled Thread-Topic: [RFC PATCH 08/10] arm: context_switch: allow to run with IRQs already disabled Thread-Index: AQHXCYx6+wvu0Xd3nESKdamktRGE6w== Date: Tue, 23 Feb 2021 02:34:58 +0000 Message-ID: <20210223023428.757694-9-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: b928eb8a-9ac4-4d70-8ac4-08d8d7a39cea x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1265; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2mKXp8dQBrHgSaT64CcaGyXnuiyAm1iqTb/jAO/x28VCqUJabnDfdicEbaIGm2yAYr+wMt4rQ/mUWFGfpmXUVgl6n+hqDssf7RGZD5fgWGK2CmY2UCT4HkDtJSZfcZq05z2cB/suy9ZVqOAYa2t9viH1mWMUEGBdECs/DlZOWCK2m8CZsVuQBkZRptSclPjeAyOt9cC6c4+FqBKbROSIv9gtwQ6DWlHr0eXYjiSYeVWtKpLghbjchuEuOQcFcYa/5UXwow9Tfd6EMYqo7s7tQlOhD1IY0BM3/Wlut1j4IjH6FNP/Dl91ZVLhC/3IaJUva45zbBY917I5rWbCquAkWMZBZEGHykZfcIkXSih5NWlh/LsQBW5bn1x5PM+qseBj4N+V+9pvWo430m8SxvpqQPAblNEEZNjDlAqerBOIL8IUHCBbcRdrjHEkuWzh8wQcAOiXfWo0TEfaai018P545DAzg66y2ng/FIGtGJvfYSuJBvllXMmtojLAKtTuBhxpxef86+1X0QCKCCgLJV2g7A== 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)(107886003)(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?XIwzGB8T8dRu9iJXV/cfOciAG?= =?iso-8859-1?q?eAWAE9JZvdCkymrYp8/zX4ustw16rwWALVHu2XSFShArGlMJuDaAtQImueOJ?= =?iso-8859-1?q?ke+l94pzfJGmwLEC3pFde+0oPrv0uZ/4F4WKg169Y4vVz/PhxQ0zYRvVj6je?= =?iso-8859-1?q?rCKQ3GUCaGweU5HbxDQGYxNDiBAZwdjP2pzlROgcEcIImZur4XKVWCUsc+MK?= =?iso-8859-1?q?7atMXi7TrgR488XlXyke5FIyb6xiUTQSx29yZSiBljFmvUUMrHsxJDq0z6Ay?= =?iso-8859-1?q?iL3Lc41ooAiFOSPoVOZSUo/nk05Iug5NXiJLfrM5Fz8hRLS0fh7XYbHNYg1S?= =?iso-8859-1?q?GTHvWkHNyz1EUSfPuLm3Y9DY4LoJtfhGxl+wJKQS7upuLVvCjzEg8vN1aU97?= =?iso-8859-1?q?Hjkh5p9w8JuA7bpRjXvOCCQy+rr4ln8nsgGTgRDVvaL5hrcEuAq9kVgsglnB?= =?iso-8859-1?q?DOdZVgQxom5NThpQ3BzufCKwFIOxxDw2rQQk0/Wn7gVrk1Kw1o7eSKRdKdIp?= =?iso-8859-1?q?4Hiv9q0pkuPrBHo0ibcKIS+O0f8QlNJ/PxurHKXTgaVp07Jez3ZEWOJ+qBdy?= =?iso-8859-1?q?00NZGcXeLpXMhpuH/lbxMQeiMo0mdEefTfNXYwQs8xVFmAZ7dWoqjnV2ZkJL?= =?iso-8859-1?q?osRKxRG3AIPYIdRC+Gwt7J5ylEPJDQWfdYB4FbSgsRupRlNkBlUBKopLVYPS?= =?iso-8859-1?q?8QePIuj0G8no5mRaAlr+ho78ruuyldDsvGRUxcZNSh/tvhBshC5fm/YEBqQm?= =?iso-8859-1?q?q7BtzSUvI0IGMF0oUwD/x2GXxNH5gdQ5OrgulHjMjUzsFdR1wFFo51000WSG?= =?iso-8859-1?q?uR4vWQXt4nSRG6CzsnxSbaWDXgchzqV5tF5ObiadspAUzpU7eaSsCtfpCyYr?= =?iso-8859-1?q?83YJoyvGRiSzkFQmyFT+erJhCs0CgL+1ASB2txyR9SOGZICoXcC0xfqXPFTb?= =?iso-8859-1?q?/HQwLt/PrtfXGPmnqxcEtx8YolRS2t8mBaT3lCoV8wP9rcv0dF9pRIjkc/26?= =?iso-8859-1?q?4f9AjWSbszdVOPeO60YVlpG/Vu9f1od85fO2H4oFDpVTpnDccVqfyRdH3ign?= =?iso-8859-1?q?sUmWAYHP3mopCCS1f8Xm4KNv0ovAySU3TmM7QjUYbLsZV1BoYOjRIwCob49U?= =?iso-8859-1?q?8HThF5VdWVORMZzD5A7uPC8Nl4N+fIuFkmESwKg+huZD5P07q5WeMIQePlJ1?= =?iso-8859-1?q?FT01eQQAUCvowAJdf+zLQs8wPpk2+nLd8QsO1vYPftQn0UYVvgT1PaN7k+Wt?= =?iso-8859-1?q?MRLCVubJvqXgebnks1dXWb6op3hynDdtEMfEl75Fwxpu+XO9G7i+aAb9uMar?= =?iso-8859-1?q?awMXkYNRZqnmFLLx3WG3Hpl5RpKir/EhQOn8yUBWA/0AIG0LCzT2CNOVJLC?= 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: b928eb8a-9ac4-4d70-8ac4-08d8d7a39cea X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:58.1025 (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: F6FQv6X463hVt9hhQ8WuBquVF9RFWSVcl0plmS2r0D1U37EcJ7elOmoegGYxCNV11Ah3X16KLsT6ujYxzD+cFgO4AV+FRRMka6PkmkDty2o= 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=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 With upcoming full hypervisor preemption it is possible that context switching code will be called with IRQs already disabled. In this case we don't want to enable them back. So we need to add logic that tracks if IRQs are already disabled. Signed-off-by: Volodymyr Babchuk --- xen/arch/arm/domain.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 2ccf4449ea..3d4a1df4a4 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -310,7 +310,7 @@ static void update_runstate_area(struct vcpu *v) } } -static void schedule_tail(struct vcpu *prev) +static void schedule_tail(struct vcpu *prev, bool enable_irqs) { ASSERT(prev != current); @@ -318,7 +318,8 @@ static void schedule_tail(struct vcpu *prev) ctxt_switch_to(current); - local_irq_enable(); + if (enable_irqs) + local_irq_enable(); sched_context_switched(prev, current); @@ -333,7 +334,7 @@ static void continue_new_vcpu(struct vcpu *prev) current->arch.actlr = READ_SYSREG32(ACTLR_EL1); processor_vcpu_initialise(current); - schedule_tail(prev); + schedule_tail(prev, true); /* This matches preempt_disable() in schedule() */ preempt_enable_no_sched(); @@ -350,19 +351,21 @@ static void continue_new_vcpu(struct vcpu *prev) void context_switch(struct vcpu *prev, struct vcpu *next) { - ASSERT(local_irq_is_enabled()); + bool need_to_disable_irqs = local_irq_is_enabled(); + ASSERT(prev != next); ASSERT(!vcpu_cpu_dirty(next)); update_runstate_area(prev); - local_irq_disable(); + if (need_to_disable_irqs) + local_irq_disable(); set_current(next); prev = __context_switch(prev, next); - schedule_tail(prev); + schedule_tail(prev, need_to_disable_irqs); } void continue_running(struct vcpu *same) 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: 12099787 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 71481C433DB for ; Tue, 23 Feb 2021 02:35:37 +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 36F1F614A7 for ; Tue, 23 Feb 2021 02:35:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36F1F614A7 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.88524.166527 (Exim 4.92) (envelope-from ) id 1lENXt-0004il-5z; Tue, 23 Feb 2021 02:35:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 88524.166527; Tue, 23 Feb 2021 02:35:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXs-0004iV-VK; Tue, 23 Feb 2021 02:35:28 +0000 Received: by outflank-mailman (input) for mailman id 88524; Tue, 23 Feb 2021 02:35:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lENXr-00046p-7i for xen-devel@lists.xenproject.org; Tue, 23 Feb 2021 02:35:27 +0000 Received: from mx0b-0039f301.pphosted.com (unknown [148.163.137.242]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f95cf823-5a6f-4cae-aced-a78d80284f96; Tue, 23 Feb 2021 02:35:05 +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 11N2QQxo004083; Tue, 23 Feb 2021 02:35:03 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-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 02:35:03 +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:58 +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:58 +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: f95cf823-5a6f-4cae-aced-a78d80284f96 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Box0ZW6cJts97vL+MA7FHGhTExkrOv+H0xYvOoLWoSAex+3v4NDWEvoaOGDmzmYtNlOmg/NUnpdBiDqKPBYeOUWcpQ/I0c0VlqMmtg3jg2MPTaIYi/26drW6h3/7UEcP+Vyvapdji3kNNbUty4rrcVgsm36UZ8gKvy4Lx2ZFLyj/gr7+4TAANZ5szhH6DKG1e3ciDXUN6zmh8paJrWBFSjM26CChOarY2WeE4ehbr21Uh0RJMjf8dIbjDGq6kOtc3+Iv288cRGxAyGsVprLYDGqk4sTTJ8O70yKAnXrNdXiHjEJIZbJCK0c1o0QRW/Zgo9LcZDA97nUn6rCtHcpH5w== 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=77HrcIok9Ev7108K/qUYq6X0RM0POs+crZXjM8Ysf2c=; b=JXX58xLnl8fV4rPTTgIAgoZIAfRLCD6wBHiETxq5Ox6dRdwRpFg2xSEGSTKE01Ot9kjtMlCxBqiI0sy8r54/RCLEIO5rr+iYfbU0gRJwVdU+rKAQ8OZwrknDOXRmR8WKv3VyOntez6MQiGdGzZC+mTKYnyFQngeEl5nJHLf3lNc3zMXa+cyjDeR1EgalQvKLfk9cqsIQak4ZV2sIRLgvjn9rPna1J9dXyza2n3b0v3ElMoJkv74O+7+0nbsl/qxioORoR3UknCVUsftCjwv4sjYvZvPJdKb/tXSECe/9thod3op/Xhkh1uxZP0AkCVvLVasqHu4AN3qiNmbq2BEG2w== 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=77HrcIok9Ev7108K/qUYq6X0RM0POs+crZXjM8Ysf2c=; b=IF0hKvbI5CNPPsygUhpYpltnYRwGQbrvAa+erWdPtZvlZ6t1GkdVVBW8eO1T++ZtSWT3a4SwwYPWsyPamc71Da7iscM4C4+FZU/ofs6hHy1IiQU3TlYxHK6r97GL9Aoq64YQ+cEXtId9Y9/O/FtbnV6LpQfdsxMLPkDwQu2pf1g7Oorzm7y+n1uo+puZ+YLmFkCqoEJXw1N55t/F4mn6AS+e2xHu9L+XKBuLvO/M/OdJXM0zM5vf4vHCtxUIXIDxT1+/BGqwCvfnDO8LrcSdkWAQ7Uo8K3pzYUzXILciz6sFWhVWNkNjxGW71Z6kYUb4f3qMnZipnn2YY71lHf5RaA== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [RFC PATCH 09/10] arm: traps: try to preempt before leaving IRQ handler Thread-Topic: [RFC PATCH 09/10] arm: traps: try to preempt before leaving IRQ handler Thread-Index: AQHXCYx6aQhBTjfpeUOOmxfCufx61A== Date: Tue, 23 Feb 2021 02:34:58 +0000 Message-ID: <20210223023428.757694-10-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: 5acda12d-2f42-4779-aa3c-08d8d7a39d19 x-ms-traffictypediagnostic: AM0PR0302MB3235: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YUQaa/FnT3MvD/24iWZzbvd71oeHj86lSWMrFzCZUZKFMc+WkFxbz5LiHZWwwXJZ/ZWMmuv90yeEVuxYMPpXgw2yPME+CK2SV37fvtvr3vlXZ/+SztoFbzLHR027WjhT7lJpz/fLmH4ocWEOQd7+6gQg8PEEqiKUfF9l58Q9rb5Mwithg03V3vSGeULKwQHCkeOY6CF/V3JEy1owHmfgRlODPr9zdte2yUFGBwljTB2lUhC23JHwMwHPMQEhvSi2+ZJkWtbBvhgRIELR+mrtp7iSuyL9pKcDz7DG8MkAflYpIbpShbpyMTjHIkJah1yAH8chcDYMR9XxCPujDNzwb/fPANAkmM8lv08arCPQztNOoLw4R91f6y4/URsl/EGRLnhuTtTN1LVumzlrY88ydKTXTS8uSXW2loKlwEy1KRXSAYmE/jJYiUucwP/Uww0aMa6/pvJURuxjh9NFi2T7HTpAdBw5fXPA5D3j1B3LwjYIAqzW05BzlWQmHyXkewdrtowjkCk3aQay+Bf+Tc17EA== 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)(4744005)(8936002)(8676002)(86362001)(2906002)(4326008)(478600001)(6486002)(186003)(107886003)(54906003)(66556008)(55236004)(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?dQHEm3IGAN922H5DYg775cTiC?= =?iso-8859-1?q?xL8zP+0cWNFPD/H/NR8hwbpTjdYY56BHa3j8Rw1UsY6lMjPThHc/hnOSw8Ka?= =?iso-8859-1?q?9Kf0V6Lq2KLDXsrXNRwAdQghVcvkYLUPMfekSKH2zzPVhl2yZCm9APKxekkF?= =?iso-8859-1?q?qfo2edz8Is7pG/hQraNm3VEy+xtLgUIGuqVfcHaoql5wxNzPL3GbRRiEfG6c?= =?iso-8859-1?q?8e6cTNrNgRkYErnG5he3X9trDwQmEVtIwPfKExEWqk1szSDUNKWvwevy/Dx3?= =?iso-8859-1?q?ieRXHp+TK9r3AVnjx8Eo87vVy3Ab5+8gdqjhRGlED69mqxgCuTC6HLBMfcW9?= =?iso-8859-1?q?9BAYm3zC7BShYsgqqexPmhVPN9TZ/Ona51NwkQQVsq9+7YJYEwJlVs9jsqPF?= =?iso-8859-1?q?ZZl9FtCrMykO/EaFj5n5f7qaypnU8IwnxxvrUmJOaxD2ElVNgInewvLYfqLf?= =?iso-8859-1?q?X/FO/Taj9WtA7mQtDvTwY0X66jGjh4Qv+p7hZDGkY2WMLMFYIT+vlBwEBdWd?= =?iso-8859-1?q?nEEMK3/4JLq0YplAfALnNYpnwdBsdvNMhbv5T1oJro4kF4i0NDPJL+su5SJk?= =?iso-8859-1?q?62DDSr8yv9oiXS0NGqafX+rggLGGRYhIftdIH82zl6EpjxM80bzBYnndPlh7?= =?iso-8859-1?q?FRbwYpMoQ4+K9crJvlHNDpCCzHMvUvqUCXd+h9WnzlyhDhYN2kTr5akSFG7c?= =?iso-8859-1?q?PeGkCUT/NmQup6lgiQZfR63Q09flMC0E/5MNVvelkQ5A8en6YR67k8QlLvYs?= =?iso-8859-1?q?n80YY/2ywp+Hi3uYxgK7GgcU049TyNVWZU/aPP+JZmckqUBf+S/AOzkRkoIc?= =?iso-8859-1?q?lq2mzlTNY1PunTy9qEyTwc5NJiiKQYeBXgtKqmg9jzO5ZBMJ/JRsNBzrjI0g?= =?iso-8859-1?q?6ch89Knwb9gxPfLBwIG1/QHn7EeAUoNXDE6yVKIf1yBglA+TxriaObqxxm8g?= =?iso-8859-1?q?mnmJiBuNcVpGgq+ucrdvh1n7UCzQrD5+QhuwzmKJIKYCtHjqKa087O5ke/vF?= =?iso-8859-1?q?he8lKvDy8SEy0/lFtnqfgXnegieMKcJUQWKLfTJuXoZZxVnDByMA8/kCnjPn?= =?iso-8859-1?q?fmLUYceIW9jjtj4aWbQMztv8U3m3cu8zRubWdjq0NRCizah5ybvv4U0wWTWC?= =?iso-8859-1?q?B97wdOd5owo5dW1fA3vyNBhhPVTNOepDVdp+4Y+//d32ZK0JXowM8x0adiYU?= =?iso-8859-1?q?Mb2RGqcRRR0aP9rNORZ7yLqfX2IJfyhQ6bll9IgUpBR3GdUyYIZCCsJAaMAq?= =?iso-8859-1?q?UyD3fwFwS0zE5xleNHSyWS8xb12fyNeS3MTIgr07IPQ6dApQZ7dbjjsRd+E8?= =?iso-8859-1?q?p9F5nDWoPC+N/qo1deDFooreiJ84HxpFTHsJZZHiNl4jFznAO2pACeCIQlg?= 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: 5acda12d-2f42-4779-aa3c-08d8d7a39d19 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 02:34:58.4833 (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: hjdn6W8pYOxYaazx2wU5MY23yUziY37gihP4izXveGMMtMPo2hMl1+haK9f7i/gIValS3T1h4oayqGOsUMHiYRk36P8hdD4+AOw3Jtkh9Eg= 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=730 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230018 Now we can try to preempt code that is running in hypervisor code. To do so we need to try to invoke scheduler by calling try_preempt(), while not in nested IRQ handler. Signed-off-by: Volodymyr Babchuk --- xen/arch/arm/traps.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 6fa135050b..98a4fb4904 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2260,7 +2260,14 @@ void do_trap_guest_serror(struct cpu_user_regs *regs) void do_trap_irq(struct cpu_user_regs *regs) { + static DEFINE_PER_CPU(unsigned int, irq_entry_cnt); + + this_cpu(irq_entry_cnt)++; gic_interrupt(regs, 0); + this_cpu(irq_entry_cnt)--; + + if (this_cpu(irq_entry_cnt) == 0) + try_preempt(true); } void do_trap_fiq(struct cpu_user_regs *regs) 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?q?O3GlpcR7Y6WFhbntYpIlrFWz7DdrDltZMnZ+AcUdI1oq5B6EHeT+pybyoLoc?= =?iso-8859-1?q?ZkA4dDEABGDV12GqqH4SAsM0YnQvftReMxDAfvP6OxaPxjA70kU4w72GKWin?= =?iso-8859-1?q?KFH9GrVg5or9Tcx5R5YSLQqpBqsLWEz5wpJG+IEIu+pXevVKf5XG+6mSg86B?= =?iso-8859-1?q?dpkTvrwrAH3dv/qLYhnlEnQy0HZu477CYP+LTQ5IrJlEjMId0fCG/8akU40f?= =?iso-8859-1?q?XeWigSkFzqNTzLuQcvGC/+8MUTO432+GAmtLDBAcL6qMVDNUppq51UGd46fl?= =?iso-8859-1?q?KzGtBYjmYsV+VZgYjyjVFi1yXKNI11/cc45f+1SZ7d9W1kRSkX6vP0caGBzo?= =?iso-8859-1?q?XGcdIAw17EbcogPXCWksf08pnxp2O2ztIC9rJwmommU5sdEN9ctORTDyrvI3?= =?iso-8859-1?q?mgc6pOQNSxHVycJtP/pMG6/x31/aFSUZ0qclbu26HeDE+x1pX+WKVSmm2Ij3?= =?iso-8859-1?q?ySv5Nd2Eu6EP++vGL7Bcef/Msyv/Gu+haPJQcB99YYzgcfGgvNKIX55N1O2Q?= =?iso-8859-1?q?9/m4IzAafk2B0tr9WQkw1SUTl91VsktzWo/zzixd2HUl63GbiidFecWrmif6?= =?iso-8859-1?q?RmLfxnEiOQXwbsJB2FKVnNcUGGJA1NsmF4vyH6H4KgtoEZeSrdp1ys7U3Xi7?= =?iso-8859-1?q?ou3gGoxQhmtm2jYfl4/xYDz9rGN03KNX4tPNzDC89GKn8FpvkFmsr+xaOahJ?= =?iso-8859-1?q?BfyIbsE6kPpquP6mJarSvG0SQSOFm5cIVnTrSpaz3/c8NNX9FRvfYWgqXovY?= =?iso-8859-1?q?ZsoJ34qfVkuqf/k3UH1VIVyWxZWpIslKM5VfhloCXEMHz7LDqaIRc0sr0/C0?= =?iso-8859-1?q?AIk9Z1MNVVZltHjUWIxqKkNcuSoKFs1NMt+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;