Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp492989imm; Wed, 20 Jun 2018 01:35:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJUfm9v12cR24xpLC3KPQ3Ubjdw3fLs0nthvUcstZkP0VONxhidXXjZH/94p89g1eThefgb X-Received: by 2002:a62:da59:: with SMTP id w25-v6mr21648549pfl.161.1529483736101; Wed, 20 Jun 2018 01:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529483736; cv=none; d=google.com; s=arc-20160816; b=mDShVNLrIsUbKYtidDmngZMyPVjAiMNXImjjwP0ugimGCBGaHntXvw4H2VpXZyDUxv 8f9kDPTaEF2gRd5cfn95KC/MM9ck96gG/eLHWamEzaowoHqrqM6HvWSqaapeIaKhoCr5 m2gmCrfR5Tb9cmVLwStmQq8XQgOhXayBmyiv/Sq4ZlV79+ibwU7LaE0ogKTdm4idi/6K Y2n+BQeq2FZ3L3bRWxwXLwfJVhJ5FgSZoKLZsgb5aKlbfclGxlM+viI8zVchzeyjAoDj ekjMnIzAWiIlHOegPC5t+QEZ7Eb2AAxfhDrK1MO0UbpCDY58TvE5AGqb0JRqfA59z0Bm dbNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=OI0/wbCib1hFEf5MUWtOE7vDdOCfNzvkCpl+7rq7jOI=; b=JV6WUTqAtiA50hcWnQXN5Ll7OIcvpYwbGD0FSRHmQA5ewBUvqY6j77jSslV4uZNfYf Fp2uv8PP+SDKSCIdaJQmmOZg45OZmCAa1fsg6sbbjfBVemzTWH74y09tqtr6ioqVZdlC 8K9gi/udcG3u51aVcPc4DpEmSCKnLHib238n36Y14bVUMeWWuHVi+Y/NGAh5L3rpwEYA z6PMf68ooZS89kA11t7uvUXb59YAPxzDm2QZTk99ydemudnYf+Rr8bXOYIa9nL7WiKy/ z0iXQ0eZTWj6QqGZc20sdAFHg3wS2HQidbyd3Fm6i7t8czVrP2VXNBY8TodjuqkLfuaR h7jQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si1561156pge.373.2018.06.20.01.35.22; Wed, 20 Jun 2018 01:35:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754666AbeFTIem (ORCPT + 99 others); Wed, 20 Jun 2018 04:34:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47276 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754630AbeFTIeh (ORCPT ); Wed, 20 Jun 2018 04:34:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09865401EF00; Wed, 20 Jun 2018 08:24:17 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56A5A2156880; Wed, 20 Jun 2018 08:24:15 +0000 (UTC) From: Vitaly Kuznetsov To: "Michael Kelley \(EOSG\)" Cc: "x86\@kernel.org" , "devel\@linuxdriverproject.org" , "linux-kernel\@vger.kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Tianyu Lan Subject: Re: [PATCH] x86/hyper-v: use cheaper HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE} hypercalls when possible References: <20180615163010.20381-1-vkuznets@redhat.com> Date: Wed, 20 Jun 2018 10:24:14 +0200 In-Reply-To: (Michael Kelley's message of "Tue, 19 Jun 2018 17:56:51 +0000") Message-ID: <87tvpxkgr5.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 20 Jun 2018 08:24:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 20 Jun 2018 08:24:17 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Michael Kelley (EOSG)" writes: >> -----Original Message----- >> From: linux-kernel-owner@vger.kernel.org On Behalf >> Of Vitaly Kuznetsov >> Sent: Friday, June 15, 2018 9:30 AM >> To: x86@kernel.org >> Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; KY Srinivasan >> ; Haiyang Zhang ; Stephen Hemminger >> ; Thomas Gleixner ; Ingo Molnar >> ; H. Peter Anvin ; Tianyu Lan >> >> Subject: [PATCH] x86/hyper-v: use cheaper HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE} >> hypercalls when possible >> >> While working on Hyper-V style PV TLB flush support in KVM I noticed that >> real Windows guests use TLB flush hypercall in a somewhat smarter way: when >> the flush needs to be performed on a subset of first 64 vCPUs or on all >> present vCPUs Windows avoids more expensive hypercalls which support >> sparse CPU sets and uses their 'cheap' counterparts. This means that >> HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED name is actually a misnomer: EX >> hypercalls (which support sparse CPU sets) are "available", not >> "recommended". This makes sense as they are actually harder to parse. >> >> Nothing stops us from being equally 'smart' in Linux too. Switch to >> doing cheaper hypercalls whenever possible. >> >> Signed-off-by: Vitaly Kuznetsov >> --- > > This is a good idea. We should probably do the same with the hypercalls for sending > IPIs -- try the simpler version first and move to the more complex _EX version only > if necessary. > > A complication: We've recently found a problem with the code for doing IPI > hypercalls, and the bug affects the TLB flush code as well. As secondary CPUs > are started, there's a window of time where the hv_vp_index entry for a > secondary CPU is uninitialized. We are seeing IPIs happening in that window, and > the IPI hypercall code uses the uninitialized hv_vp_index entry. Same thing could > happen with the TLB flush hypercall code. I didn't actually see any occurrences of > the TLB case in my tracing, but we should fix it anyway in case a TLB flush gets > added at some point in the future. > > KY has a patch coming. In the patch, hv_cpu_number_to_vp_number() > and cpumask_to_vpset() can both return U32_MAX if they encounter an > uninitialized hv_vp_index entry, and the code needs to be able to bail out to > the native functions for that particular IPI or TLB flush operation. Once the > initialization of secondary CPUs is complete, the uninitialized situation won't > happen again, and the hypercall path will always be used. Sure, with TLB flush we can always fall back to doing it natively (by sending IPIs). > > We'll need to coordinate on these patches. Be aware that the IPI flavor of the > bug is currently causing random failures when booting 4.18 RC1 on Hyper-V VMs > with large vCPU counts. Thanks for the heads up! This particular patch is just an optimization so there's no rush, IPI fix is definitely more important. > > Reviewed-by: Michael Kelley Thanks! -- Vitaly