From patchwork Fri Dec 4 08:52:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11951133 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=-18.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,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 200D5C0018C for ; Fri, 4 Dec 2020 08:53:15 +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 A2BCE229C4 for ; Fri, 4 Dec 2020 08:53:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2BCE229C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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.44161.79239 (Exim 4.92) (envelope-from ) id 1kl6pu-0006cj-4t; Fri, 04 Dec 2020 08:53:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 44161.79239; Fri, 04 Dec 2020 08:53:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pu-0006cS-0p; Fri, 04 Dec 2020 08:53:06 +0000 Received: by outflank-mailman (input) for mailman id 44161; Fri, 04 Dec 2020 08:53:04 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6ps-0006XX-0s for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:04 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pr-00049c-N7; Fri, 04 Dec 2020 08:53:03 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pr-00081O-FS; Fri, 04 Dec 2020 08:53:03 +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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=e7E0uPlbvldsr+/Or2Usn28nGFXQXE0Lw/3OzuAS844=; b=OY+ZrhmXvDbIM5anfbTCwyHSQ7 30+17YusEJP4C/9uJmN9sKEkYQJYER1LLIyicVMa7AOrV8qTPZ/tjl1ain7osv5p4sfO3bZndXP3l e3pWnu55uxJfdyhOg+O4cqsT7pM7MSEX42tZ32I4OshPooYduemELvob5fG99ldXLvMA=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Jan Beulich , Wei Liu , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 06/11] viridian: use softirq batching in hvcall_ipi() Date: Fri, 4 Dec 2020 08:52:50 +0000 Message-Id: <20201204085255.26216-7-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 From: Paul Durrant vlapic_ipi() uses a softirq batching mechanism to improve the efficiency of sending a IPIs to large number of processors. This patch modifies send_ipi() (the worker function called by hvcall_ipi()) to also make use of the mechanism when there multiple bits set the hypercall_vpmask. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Wei Liu Cc: Andrew Cooper Cc: "Roger Pau Monné" v2: - Don't add the 'nr' field to struct hypercall_vpmask and use bitmap_weight() instead --- xen/arch/x86/hvm/viridian/viridian.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridian/viridian.c index 3e2393be4160..894946abcb72 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -571,6 +572,11 @@ static unsigned int vpmask_next(const struct hypercall_vpmask *vpmask, (vp) < HVM_MAX_VCPUS; \ (vp) = vpmask_next(vpmask, vp) ) +static unsigned int vpmask_nr(const struct hypercall_vpmask *vpmask) +{ + return bitmap_weight(vpmask->mask, HVM_MAX_VCPUS); +} + /* * Windows should not issue the hypercalls requiring this callback in the * case where vcpu_id would exceed the size of the mask. @@ -654,10 +660,17 @@ static int hvcall_flush(const union hypercall_input *input, static void send_ipi(struct hypercall_vpmask *vpmask, uint8_t vector) { struct domain *currd = current->domain; + unsigned int nr = vpmask_nr(vpmask); unsigned int vp; + if ( nr > 1 ) + cpu_raise_softirq_batch_begin(); + for_each_vp ( vpmask, vp ) vlapic_set_irq(vcpu_vlapic(currd->vcpu[vp]), vector, 0); + + if ( nr > 1 ) + cpu_raise_softirq_batch_finish(); } static int hvcall_ipi(const union hypercall_input *input,