Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp778822ybb; Wed, 8 Apr 2020 09:42:12 -0700 (PDT) X-Google-Smtp-Source: APiQypJheNDaMct3z+HxsOIl3+skLgT43NcVgFpNR+H38TwUkYMXfT+ku0ysqlUvy0vwkkiqyznA X-Received: by 2002:a54:4f0a:: with SMTP id e10mr3145979oiy.127.1586364132152; Wed, 08 Apr 2020 09:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586364132; cv=none; d=google.com; s=arc-20160816; b=fAUVl35EDySz2mdo9IXh8ILFJwRO9bAKAD8aaWL4Sw3piK/LPi/0qKm+HUW8lRGsib STEjS2QjcGqUisFRolu5Bjo9G6Faga+zs+GCdjjJO4+yKuXV0Bk8lwEedCpqZjzuc9VD 35VAHM1A4fhPxosg56NEcwY6QsyKtDM5NyJNRuE5B1f92GwXy0OTWZj5T1ysasV54YWW fhUjTII4iz4T+qDjQNBVWLLNflXWzTxtseOfKAe0tjwlOdpyybvrmlfRbJ/UeJRVFeFz 6MEIBQ16Ojcm/vOdM7/xiSACnfsy0ErcSw2iesv5+xVEYdz30Rf0tz76WpO2MEAtyieZ AGHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=N8ykcQQ3SOpdB5xsAT3pwV11DGg8xQH7SevAPGdtwTg=; b=CgK8NCCP0hqKq1YDUULCBEm5EuXGzqPwUIzfiFjPFaqQJxDwfMiIf1x9trHQZyKVgd X+ckZQ17x+XIz5J7jCpvAv18eRXBvv7zPx/Ece+f/G3CB3k6kJ9b+zKYMV5YzcekKkyc L4a9vXQBFNEx9aKocJts6ku815MCZxWD4jA4HuRBWyi0Ce494J7JT4FeeibgZ9XNH1iN VjYob6RUC+gdA6SrWu0meB58l/HTQXbl859U6ux9k10P8Z53mxYtinjnoShiPLIfQQno JZd4w46jdPhNkIdg3i4PQZQkNRWT/Yykdx50kl1B9vADMm5FyILweSpY5J9Mc6UJsqqH ohpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YOq7ZrDs; 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 b16si2558275oop.83.2020.04.08.09.41.55; Wed, 08 Apr 2020 09:42:12 -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=bombadil.20170209 header.b=YOq7ZrDs; 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 S1729096AbgDHOt1 (ORCPT + 99 others); Wed, 8 Apr 2020 10:49:27 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44718 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728367AbgDHOt1 (ORCPT ); Wed, 8 Apr 2020 10:49:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=N8ykcQQ3SOpdB5xsAT3pwV11DGg8xQH7SevAPGdtwTg=; b=YOq7ZrDsmTyGEBcCI6BSDKkjsL I0uT/nJsD58Z+VHPMPAHi0wRyC61w6xXBMjcZFL/2mAsz2fbtr2mmjek7SrHTS63SneNCwGwzHyPL S6MegKRHQ/nk/fGNaJ8Yz3jQF01jD37BeyYMXiT7eN6emnX4N2gqwsKwlbXITRiIhFb2j8OdeEA6i EFM6XQ1O24xEkXwi2ZPKN/MNkvCJD42WZQ91uLBB3Kz9N8eWpkQrZbjuPLmlGMfjS+qjHTXkSzn8v TUIi2+UWQ5UwjS0BvK/up5CVJDBsoMmz8NqwVB+LGs7/FnCAsL8VncXNigzzuY1EjQvss6OMnwXmk pkaGs/vw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMC0r-00044L-OE; Wed, 08 Apr 2020 14:49:09 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4BFC5305FB6; Wed, 8 Apr 2020 16:49:07 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3E3F52BA90A66; Wed, 8 Apr 2020 16:49:07 +0200 (CEST) Date: Wed, 8 Apr 2020 16:49:07 +0200 From: Peter Zijlstra To: =?iso-8859-1?Q?J=FCrgen_Gro=DF?= Cc: Ankur Arora , linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, jpoimboe@redhat.com, namit@vmware.com, mhiramat@kernel.org, bp@alien8.de, vkuznets@redhat.com, pbonzini@redhat.com, boris.ostrovsky@oracle.com, mihai.carabas@oracle.com, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, virtualization@lists.linux-foundation.org Subject: Re: [RFC PATCH 00/26] Runtime paravirt patching Message-ID: <20200408144907.GL20730@hirez.programming.kicks-ass.net> References: <20200408050323.4237-1-ankur.a.arora@oracle.com> <20200408120856.GY20713@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 08, 2020 at 03:33:52PM +0200, J?rgen Gro? wrote: > On 08.04.20 14:08, Peter Zijlstra wrote: > > On Tue, Apr 07, 2020 at 10:02:57PM -0700, Ankur Arora wrote: > > > Mechanism: the patching itself is done using stop_machine(). That is > > > not ideal -- text_poke_stop_machine() was replaced with INT3+emulation > > > via text_poke_bp(), but I'm using this to address two issues: > > > 1) emulation in text_poke() can only easily handle a small set > > > of instructions and this is problematic for inlined pv-ops (and see > > > a possible alternatives use-case below.) > > > 2) paravirt patching might have inter-dependendent ops (ex. > > > lock.queued_lock_slowpath, lock.queued_lock_unlock are paired and > > > need to be updated atomically.) > > > > And then you hope that the spinlock state transfers.. That is that both > > implementations agree what an unlocked spinlock looks like. > > > > Suppose the native one was a ticket spinlock, where unlocked means 'head > > == tail' while the paravirt one is a test-and-set spinlock, where > > unlocked means 'val == 0'. > > > > That just happens to not be the case now, but it was for a fair while. > > Sure? This would mean that before spinlock-pvops are being set no lock > is allowed to be used in the kernel, because this would block the boot > time transition of the lock variant to use. Hurm.. true. I suppose I completely forgot how paravirt spinlocks looked before it got rewritten. > Another problem I'm seeing is that runtime pvops patching would rely on > the fact that stop_machine() isn't guarded by a spinlock. It can't be, stop_machine() relies on scheduling. But yes, that another variation of 'stuff uses spinlocks'.