Received: by 10.213.65.68 with SMTP id h4csp1684916imn; Thu, 15 Mar 2018 06:50:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELsRtW0Mzg6XIGFX2NaY6taYiwl31zE+KlCpXRpu3JvfPSp4OiI08OjY+Nm5RfZIyJ6tbY6z X-Received: by 10.99.121.140 with SMTP id u134mr6669646pgc.89.1521121842087; Thu, 15 Mar 2018 06:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521121842; cv=none; d=google.com; s=arc-20160816; b=i+F0S9EzqTdsALZQdrvTDUIAOygwQA1BGVoCYEXyzSxBuOhAa1H2qePkrF1CTjCk5b 1wbEjB9akSKM1fl06rf2r3uJ0g/3Bt3hfDNIQdkVg4yMp8EzQbnw11q9WwUdEZzjNS/5 uExz35DEsLCg01RGKxDhOzb3mr6Fuko0TL1vVIlqiNCgy/TzC/wSFEI+TzBlf5/vxoMH FIEkN4ci6WNQd3/sI5w9nV1NHRAeNP0XVSNhAk48aO1JH1F3yWs/QdEjOD56gnjwk6Ng 4IjP8R3J38uRZHB/oId2ERT5DBS0VNE5AxKp1+g3xmfvi1hIkSGnxBY/92Cz+LC/rJRU GPKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=+jgkCy7RSeV/rCWGYm+XT6RsPyKzsvNj0Sz/z8S7f38=; b=P+L8SfNSUqc4mJHpoM8igdx1cbLIUh/im/zLORQRQVzTi8CHFuvg0I+hOTrfHdPmy9 cxxUcdaAL+h6x9WyhBcypMdFn2nAFuOponZI6n2eotu6qTqAQYdEGmH8l6qG/8kNY8/Z +PnKjfvsU5mKtD6YR/hC6qWP29oJ/jS0NE9ZvKL4UQs50pkqQz0LsTAf7Y1i1TDZtVzf 2ghcYN54ujk8jaNCm7L1aBSkpJMXOY3j2Ybv4cUzQ1pRI7ohVpl8fPnx1h3nRqOfSAAA yaT+Q4YIeC+hZoWi0nns0bHduMBKoAusV0F4YVhd8a9hrcgs2i0V+G2F3azcHRkkiAKl PiMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=1/8R4Ort; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6-v6si4084047plm.590.2018.03.15.06.50.04; Thu, 15 Mar 2018 06:50:42 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=1/8R4Ort; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbeCONs7 (ORCPT + 99 others); Thu, 15 Mar 2018 09:48:59 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49804 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751502AbeCONs5 (ORCPT ); Thu, 15 Mar 2018 09:48:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+jgkCy7RSeV/rCWGYm+XT6RsPyKzsvNj0Sz/z8S7f38=; b=1/8R4Ort/aYPCaDt0YdzcxEHe 8H273GhabcYLheDrVHifIb4ocp4ou666Krjtph0T47DghWAbXvQhtgltQxI6+NfMK21FG5ip+XJti diVszX0TJGIJTsaZA8j8bNEgRWDP9pFehT2XhuGlvapTIGMB+nzQr3gSF4zWaesb1080KxXYcJSrk P4yz8cRJtsJc5MXrFYiKnzqltKH/K7PwVH7HubVBS8/HNEv6jBLHP2NpxpXvdUFe6OenfxMXbLANO 3wPHZUc6W16SyNrK8wAZaLejbN8oyPFM7KUwRbArDSkI9GZ9eGKNwIuka2Ymq/5A8mvsfdhVfaTaV gogGJ/37Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewTFT-0003Ti-Bb; Thu, 15 Mar 2018 13:48:51 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EDA1D2029B0E8; Thu, 15 Mar 2018 14:48:48 +0100 (CET) Date: Thu, 15 Mar 2018 14:48:48 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: Vitaly Kuznetsov , kvm@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Bandan Das , LKML Subject: Re: [PATCH v3 4/7] x86/hyper-v: allocate and use Virtual Processor Assist Pages Message-ID: <20180315134848.GV4043@hirez.programming.kicks-ass.net> References: <20180309140249.2840-1-vkuznets@redhat.com> <20180309140249.2840-5-vkuznets@redhat.com> <87bmfpbqek.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 12:45:03PM +0100, Thomas Gleixner wrote: > On Thu, 15 Mar 2018, Vitaly Kuznetsov wrote: > > Thomas Gleixner writes: > > > On Fri, 9 Mar 2018, Vitaly Kuznetsov wrote: > > >> @@ -198,6 +218,12 @@ static int hv_cpu_die(unsigned int cpu) > > >> struct hv_reenlightenment_control re_ctrl; > > >> unsigned int new_cpu; > > >> > > >> + if (hv_vp_assist_page && hv_vp_assist_page[cpu]) { > > >> + wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, 0); > > >> + vfree(hv_vp_assist_page[cpu]); > > >> + hv_vp_assist_page[cpu] = NULL; > > > > > > So this is freed before the CPU is actually dead. And this runs in > > > preemtible context. Is the wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, 0); enough to > > > prevent eventual users of the assist page on the outgoing CPU from > > > accessing it? > > > > > > > After we do wrmsrl() the page is no longer 'magic' so in case eventual > > users try using it they'll most likely misbehave -- so changing the > > shutdown order won't help. > > > > The only user of these pages is currently KVM. Can we still have vCPUs > > running on the outgoing CPU at this point? If case we can we're in > > trouble and we need to somehow kick them out first. > > The first thing we do in unplug is to mark the CPU inactive, but I'm not > sure whether that prevents something which was on the CPU before and > perhaps preempted or is affine to that CPU to be scheduled in > again. Peter???? I think we can still have tasks running at this point. AP_ACTIVE (sched_cpu_deactivate) simply takes the CPU out of the active mask, which guarantees no new tasks will land on the CPU. We'll then proceed all the way to TEARDOWN_CPU as 'normal', at which point we'll call stop_machine() which does the old DYING callbacks. It sounds like we want this done here, although possibly we can't do vfree() from that context, in which case it needs to store the pointer and do that from a BP callback (what used to be the OFFLINE callbacks or something).