Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756606AbdDGUq1 (ORCPT ); Fri, 7 Apr 2017 16:46:27 -0400 Received: from mail-by2nam01on0115.outbound.protection.outlook.com ([104.47.34.115]:57728 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756578AbdDGUqR (ORCPT ); Fri, 7 Apr 2017 16:46:17 -0400 From: Jork Loeser To: Vitaly Kuznetsov , "devel@linuxdriverproject.org" , "x86@kernel.org" CC: "linux-kernel@vger.kernel.org" , "KY Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Steven Rostedt Subject: RE: [PATCH 6/7] x86/hyper-v: use hypercall for remove TLB flush Thread-Topic: [PATCH 6/7] x86/hyper-v: use hypercall for remove TLB flush Thread-Index: AQHSr5Hv7dIOzBIb8EGcRSIrNTRi16G6VNRg Date: Fri, 7 Apr 2017 20:46:13 +0000 Message-ID: References: <20170407112701.17157-1-vkuznets@redhat.com> <20170407112701.17157-7-vkuznets@redhat.com> In-Reply-To: <20170407112701.17157-7-vkuznets@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2001:4898:80e8:4::1f] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR21MB0639;7:jvNJvaDaRKF99ebnX0axygbU/jFEzpblcJ9VD9KdupvrWvT4Td/704OjauIlfL09TtBrlVEBSoA4L0FAm0za915ssl/DtHZrqVSqq/0vzn0UqtvkFm7raFcO6YbYZGcl7/RTO2YGTghZpAqnmvngHcLTjBwWaieSyHxWHggYuFaX6z5g+VfXs1jbg21vPJ/fuR1B14bLj2j7aitOdF76489qswSlojVBgcflAriExbxpphPqomGepKUKMd9mLX5gN5HnnaTs7hKNDkq1zL5IRyBeoknqYq9e9nb/FBTbjJ3zemkruOhbBIs8fVyqJnn7JzsGRbDqIOuGBYLobUe2K21VQBSOvooyBHq7uY+28uI= x-ms-office365-filtering-correlation-id: 597555b3-88b2-4ac9-5aef-08d47df72146 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:MWHPR21MB0639; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123562025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(6072148);SRVR:MWHPR21MB0639;BCL:0;PCL:0;RULEID:;SRVR:MWHPR21MB0639; x-forefront-prvs: 0270ED2845 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39410400002)(39450400003)(39860400002)(39850400002)(39840400002)(39400400002)(13464003)(99286003)(54906002)(55016002)(8936002)(9686003)(33656002)(53936002)(189998001)(81166006)(7736002)(305945005)(74316002)(6116002)(2201001)(102836003)(86362001)(86612001)(2501003)(76176999)(54356999)(50986999)(2906002)(6436002)(8676002)(7696004)(4326008)(2950100002)(10090500001)(10290500002)(5005710100001)(38730400002)(6506006)(6246003)(122556002)(5660300001)(77096006)(25786009)(3660700001)(53546009)(3280700002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR21MB0639;H:MWHPR21MB0639.namprd21.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2017 20:46:13.3644 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0639 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v37KkUHk022885 Content-Length: 2485 Lines: 76 > -----Original Message----- > From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] > Sent: Friday, April 7, 2017 04:27 > To: devel@linuxdriverproject.org; x86@kernel.org > Cc: linux-kernel@vger.kernel.org; KY Srinivasan ; > Haiyang Zhang ; Stephen Hemminger > ; Thomas Gleixner ; Ingo > Molnar ; H. Peter Anvin ; Steven > Rostedt ; Jork Loeser > Subject: [PATCH 6/7] x86/hyper-v: use hypercall for remove TLB flush > diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c new file > mode 100644 index 0000000..fb487cb > --- /dev/null > +++ b/arch/x86/hyperv/mmu.c > @@ -0,0 +1,128 @@ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * Arbitrary number; we need to pre-allocate per-cpu struct for doing > +TLB > + * flush hypercalls and we need to pick a size. '16' means we'll be > +able > + * to flush 16 * 4096 pages (256MB) with one hypercall. > + */ > +#define HV_MMU_MAX_GVAS 16 > + > +/* HvFlushVirtualAddressSpace*, HvFlushVirtualAddressList hypercalls */ > +struct hv_flush_pcpu { > + struct { > + __u64 address_space; > + __u64 flags; > + __u64 processor_mask; > + __u64 gva_list[HV_MMU_MAX_GVAS]; > + } flush; > + > + spinlock_t lock; > +}; Does this need an alignment declaration, so that the flush portion never crosses a page boundary when allocated with alloc_percpu()? > + > +static struct hv_flush_pcpu __percpu *pcpu_flush; > + > +static void hyperv_flush_tlb_others(const struct cpumask *cpus, > + struct mm_struct *mm, unsigned long > start, > + unsigned long end) > +{ > + struct hv_flush_pcpu *flush; > + unsigned long cur, flags; > + u64 status = -1ULL; > + int cpu, vcpu, gva_n; > + > + if (!pcpu_flush || !hv_hypercall_pg) > + goto do_native; > + > + if (cpumask_empty(cpus)) > + return; > + > + flush = this_cpu_ptr(pcpu_flush); > + spin_lock_irqsave(&flush->lock, flags); What purpose does the spinlock on the CPU-local struct serve? Would a local_irq_save() do? Could this be called from NMI context, such as from the debugger? Could this be a long-running loop, e.g. due to a large start/end range? If so, consider disabling interrupts only in the inner loop / flush the entire space? Regards, Jork