From patchwork Thu Sep 16 15:04:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 12499323 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 EEF5DC433EF for ; Thu, 16 Sep 2021 15:05:12 +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 B67C1610D1 for ; Thu, 16 Sep 2021 15:05:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B67C1610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.188538.337723 (Exim 4.92) (envelope-from ) id 1mQswi-000665-Rv; Thu, 16 Sep 2021 15:05:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 188538.337723; Thu, 16 Sep 2021 15:05: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 1mQswi-00065y-O9; Thu, 16 Sep 2021 15:05:04 +0000 Received: by outflank-mailman (input) for mailman id 188538; Thu, 16 Sep 2021 15:05: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 1mQswg-00065o-OG for xen-devel@lists.xenproject.org; Thu, 16 Sep 2021 15:05:02 +0000 Received: from mga07.intel.com (unknown [134.134.136.100]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 76241d08-16ff-11ec-b60a-12813bfff9fa; Thu, 16 Sep 2021 15:05:00 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 08:04:59 -0700 Received: from tlengyel-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.212.12.147]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 08:04:57 -0700 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: 76241d08-16ff-11ec-b60a-12813bfff9fa X-IronPort-AV: E=McAfee;i="6200,9189,10109"; a="286269361" X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="286269361" X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="700650535" From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Cc: Tamas K Lengyel , Tamas K Lengyel , Jan Beulich , Andrew Cooper , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH] x86/mem_sharing: don't lock parent during fork reset Date: Thu, 16 Sep 2021 11:04:42 -0400 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 During fork reset operation the parent domain doesn't need to be gathered using rcu_lock_live_remote_domain_by_id as the fork reset doesn't modify anything on the parent. The parent is also guaranteed to be paused while forks are active. This patch reduces lock contention when performing resets in parallel. Signed-off-by: Tamas K Lengyel --- xen/arch/x86/mm/mem_sharing.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 8d5d44bdbc..b80b978ef3 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1879,9 +1879,10 @@ static int fork(struct domain *cd, struct domain *d) * footprints the hypercall continuation should be implemented (or if this * feature needs to be become "stable"). */ -static int mem_sharing_fork_reset(struct domain *d, struct domain *pd) +static int mem_sharing_fork_reset(struct domain *d) { int rc; + struct domain *pd = d->parent; struct p2m_domain *p2m = p2m_get_hostp2m(d); struct page_info *page, *tmp; @@ -2226,8 +2227,6 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg) case XENMEM_sharing_op_fork_reset: { - struct domain *pd; - rc = -EINVAL; if ( mso.u.fork.pad || mso.u.fork.flags ) goto out; @@ -2236,13 +2235,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg) if ( !d->parent ) goto out; - rc = rcu_lock_live_remote_domain_by_id(d->parent->domain_id, &pd); - if ( rc ) - goto out; - - rc = mem_sharing_fork_reset(d, pd); - - rcu_unlock_domain(pd); + rc = mem_sharing_fork_reset(d); break; }