Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1711914pxb; Fri, 10 Sep 2021 11:59:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPmMCbfvyhzcVkm/AuoNXQoxYxpAwFgDYUovrsl8QG9SHsIVOTTunQ6b8iwBwB9o4aR3ER X-Received: by 2002:a17:906:25d4:: with SMTP id n20mr11014001ejb.399.1631300356633; Fri, 10 Sep 2021 11:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631300356; cv=none; d=google.com; s=arc-20160816; b=hgqx+Py3W0Ud5CpOyU2l0+MsYK+Ug1s84PTJnQ7W2x/AdVXD0P3M1vhrorQhP7vr0t dBQJYIDnOSr142FiYdTEhRMFPzQlFsQprw4ZUC5AwZmm+tisKu7iXhnDFgrGh9kW9//h mWeQ3vtpK6GgYd2HfP99JKbRzrCB8dJCaGbQDe+NSUvgAAmqdBfheI5BTDV3LJMkfQ9Q vNIoG6LxlG27uo3IIbbCOSRB39UGDqMNwg5TiSESSbxU3/s+yFuGDYBf70u7yeafOESC u5JVxnWZ8iz3eI9aWm/pkgbaL5W0oQdSbIexv/IGah2M8FCP4t786JU2n7hMlX2aiQmB k4pA== 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=RmF22FF10VEqJ3XXc0rOTEglVQ69MnGfxCNpGugVz3s=; b=KicG7m3ucUBYYY8LqSoWBylPW41+EIvvQr2IWFl15cVHnQkDTutOZjxD5zW5c5c8N7 Wm6sPDYB5fs9MVUqcPalA3/Ehb75dUvUowsV8aMhue/SVRBLkkoeZCDhs4vR4sZwyPGE grlyx7CXSr/FF28yr78wh+5uURBXiv1SJNVMeZcOnD4BkVu5Bmkdkse6AZTJBuU+vQbz j+fH6FcRYxO6TCa0AgHunIDVfK2ouDAjzlfVgUupi2p7t3oQz474Go5PQLuQORWSDf24 pEVWDKVD/8lJWrup172x1Qoq0cNYrMiOafo50KpEkO/pYc2GBkiJJtpXF164GE1XBB8l 6lCg== 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 cb3si5714872edb.528.2021.09.10.11.58.52; Fri, 10 Sep 2021 11:59:16 -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 S232210AbhIJS6g (ORCPT + 99 others); Fri, 10 Sep 2021 14:58:36 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:41843 "EHLO mail-wm1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbhIJS6a (ORCPT ); Fri, 10 Sep 2021 14:58:30 -0400 Received: by mail-wm1-f42.google.com with SMTP id u15-20020a05600c19cf00b002f6445b8f55so2054518wmq.0; Fri, 10 Sep 2021 11:57:18 -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=RmF22FF10VEqJ3XXc0rOTEglVQ69MnGfxCNpGugVz3s=; b=VBiXpmS2PSdLU6yvYPVGgk3tgFjMBMYwlgT1IG/ogJymSwQUM/HVC9do7FwIIiBX/f 8PjW4kD09eAgaDbdIQ5yIbOTAVr9vemIHtKo26pHVBQRqp9B4jTjDXQMPMxgOqnYt/9+ MaSqW80ZHAlb6kSwhoNaRaRrgxewBp0+IysHMqIdhvlU06JcgSvxW7F1nF732y4sNO7g Nc1VLyOXOlliarpwtb+3BB8pJwTO56xznBAtjGEEhkpZgAnX1E7wPxTRcyYfPRaLOWgk 3hAu0X64Z5OXy9+j52HiS8MlNUwJPbCfgulLeMTkLbKSCcUD03EXldCLjv4GNCPyOYWT Trpw== X-Gm-Message-State: AOAM532TFbWa6HHvssJm8B6zq3NOwhRWKZx1O0Fsd9pSbxYWosT+iVWa 4OptTHw7PZoNBkC+wAlkogVXeJt7i+Y= X-Received: by 2002:a05:600c:22ca:: with SMTP id 10mr9753190wmg.170.1631300238170; Fri, 10 Sep 2021 11:57:18 -0700 (PDT) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id y4sm5015351wmi.22.2021.09.10.11.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 11:57:17 -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 v2 1/2] asm-generic/hyperv: provide cpumask_to_vpset_noself Date: Fri, 10 Sep 2021 18:57:13 +0000 Message-Id: <20210910185714.299411-2-wei.liu@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210910185714.299411-1-wei.liu@kernel.org> References: <20210910185714.299411-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. v2: 1. Rename function 2. Add preemptible check --- include/asm-generic/mshyperv.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index 9a000ba2bb75..9a134806f1d5 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(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,19 @@ 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(vpset, cpus, false); +} + +static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset, + const struct cpumask *cpus) +{ + WARN_ON_ONCE(preemptible()); + return __cpumask_to_vpset(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