From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F12C2D0EA for ; Wed, 8 Apr 2020 14:49:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3A9D20747 for ; Wed, 8 Apr 2020 14:49:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YOq7ZrDs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729106AbgDHOt1 (ORCPT ); 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'.