Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp803126pxb; Wed, 8 Sep 2021 12:44:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf2OEnebsk4Tb0JfXMw7W31PXlkIXr3jJ6T0xrDlSoOs7exoGnx1vHZNZMShM8QAgRQ/0k X-Received: by 2002:a5d:8f91:: with SMTP id l17mr1257844iol.121.1631130261971; Wed, 08 Sep 2021 12:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631130261; cv=none; d=google.com; s=arc-20160816; b=ZI/UwlGT97te2UUsBHIWE9ATN3/v5AW7TUbJ+qKIKnfNAGtYcfXAZdtjLYKCWJuCer pdv8slUSduZuPkRPfw1EZ7E1/pDXOD22vH3VNMgGwyBiN9NrKbeUPbknziwTKgVBarxz B3LAMC+nAVYQYMDwyJ9RQvLqLS0ERRfb9+M9Tgz3oPbLDngiQ8+LZmnd/ihhbnvUnNZc WYCPYzUJa5atWBmQtFRkaxnyuLFApN6DoIQWaSrMhNml9zaRqlZf+98TVk2+md1aMSwn BMCJP8zVzhkiwMLOJENrnmoHmHjjxtENVfcaih7Fe2HymXpiUoNAk1TIC96Z9L7HjWLL Ft/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=f/XJiQEpE7jUl93U2dRCaSlCXjM0mPRU2w5BruXuWoQ=; b=SL0KK+FwcndcQEZLNB9KXTay7Dl8c2DS5m5XOF43OCv2PyJBDypBm0HN622hkGYYLf bMn1oJz8kS0TDNjp2GDS+ic1hrV8jUS30zov/2yqU2qqOM6EK6SN3pUlWqoxFckV7j1J 1z3OV/k8k61Ap09/1a4tPa81NbbN/1+yE0tu9hfA8xOxV5OLRAS5b4CAheB6Dw0Wa+Ma zousFG22UAdeMudw4+i06eCbdADvgQhKQgfxuMsO7a2v/4VehcDvEvjIqgVAa6OvDNhA EVXF88lrO+w7xjAR5aRCHbbuaJK27o2jxH4E4dYRXFOqbsryKAxrptYDVnYhmKSiByvx cHxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay15si45534iob.92.2021.09.08.12.44.01; Wed, 08 Sep 2021 12:44:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352075AbhIHTn6 (ORCPT + 99 others); Wed, 8 Sep 2021 15:43:58 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:44783 "EHLO mail-wr1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350940AbhIHTn5 (ORCPT ); Wed, 8 Sep 2021 15:43:57 -0400 Received: by mail-wr1-f43.google.com with SMTP id d6so4884183wrc.11; Wed, 08 Sep 2021 12:42:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f/XJiQEpE7jUl93U2dRCaSlCXjM0mPRU2w5BruXuWoQ=; b=YtJ92oK2oDs9H1n7mmTDFP+FYX0UFxOBff9JIiBu5N/fqZIzlhGPRd1yRhIeHK7MqQ 5YPqxWRUhh7Unm5l8VVJPzp/XKB0aCFimLnUhkI9TulIOQuoIWC9Dtnevp2rCTP/iOvN Ct774JFyMJ/Cj3Kle1M54pM/hQewCQqb5PtCUA+MeDrp9XQd3xpfiCRYOI2QKeVwxwyZ +ABF0Dl55o0UuMoXkXgb7Qy567Qo1MyLpUDfcflKK4Wbtu89FC2Kla+lymkrMed3IzRP sA7mbvgLj0xu9bCfiL+vkDGOf5jn7YwCebco1TQvMOj6qS/4PegYgIsFON4kocebao4H xiWQ== X-Gm-Message-State: AOAM532L1LG7wP6GlP3k3TMx4calipaiSPNWWVuCzDD1/9vLpsZoAvKs 2FCZgtBPHMAaFHi9P2q5mk5dt/e543I= X-Received: by 2002:adf:c54a:: with SMTP id s10mr5906273wrf.405.1631130167626; Wed, 08 Sep 2021 12:42:47 -0700 (PDT) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id p5sm72852wrd.25.2021.09.08.12.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 12:42:46 -0700 (PDT) From: Wei Liu To: Linux on Hyper-V List Cc: Michael Kelley , kys@microsoft.com, haiyangz@microsoft.com, decui@microsoft.com, sthemmin@microsoft.com, Wei Liu , Arnd Bergmann , linux-arch@vger.kernel.org (open list:GENERIC INCLUDE/ASM HEADER FILES), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] asm-generic/hyperv: provide cpumask_to_vpset_noself Date: Wed, 8 Sep 2021 19:42:42 +0000 Message-Id: <20210908194243.238523-2-wei.liu@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908194243.238523-1-wei.liu@kernel.org> References: <20210908194243.238523-1-wei.liu@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a new variant which removes `self' cpu from the vpset. It will be used in Hyper-V enlightened IPI code. Signed-off-by: Wei Liu --- Provide a new variant instead of adding a new parameter because it makes it easier to backport -- we don't need to fix the users of cpumask_to_vpset. --- include/asm-generic/mshyperv.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index 9a000ba2bb75..d89690ee95aa 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -184,10 +184,12 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number) return hv_vp_index[cpu_number]; } -static inline int cpumask_to_vpset(struct hv_vpset *vpset, - const struct cpumask *cpus) +static inline int cpumask_to_vpset_ex(struct hv_vpset *vpset, + const struct cpumask *cpus, + bool exclude_self) { int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1; + int this_cpu = smp_processor_id(); /* valid_bank_mask can represent up to 64 banks */ if (hv_max_vp_index / 64 >= 64) @@ -205,6 +207,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset, * Some banks may end up being empty but this is acceptable. */ for_each_cpu(cpu, cpus) { + if (exclude_self && cpu == this_cpu) + continue; vcpu = hv_cpu_number_to_vp_number(cpu); if (vcpu == VP_INVAL) return -1; @@ -219,6 +223,18 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset, return nr_bank; } +static inline int cpumask_to_vpset(struct hv_vpset *vpset, + const struct cpumask *cpus) +{ + return cpumask_to_vpset_ex(vpset, cpus, false); +} + +static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset, + const struct cpumask *cpus) +{ + return cpumask_to_vpset_ex(vpset, cpus, true); +} + void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die); bool hv_is_hyperv_initialized(void); bool hv_is_hibernation_supported(void); -- 2.30.2