Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1036591imu; Fri, 11 Jan 2019 13:49:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qvbAd7b+tGOOcIqE56HH7Cth04W1C4cwKF7vbhJsCNH9QszNRuElJr3fLvqz+eigQXfLA X-Received: by 2002:a65:4946:: with SMTP id q6mr14542280pgs.201.1547243349618; Fri, 11 Jan 2019 13:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547243349; cv=none; d=google.com; s=arc-20160816; b=nRYd/pzv2UoonSKaZN0xcis30nUOzuOxl+d/KFv4zDoS2PxnD0c8kmkRXMY2X92Jm0 56Z7coGkbAfI/bvFadhd4odphiGi1T3fz/G2b3E9zZOdsQF4Ro44U4UhcAP9lBym4Qd/ irUDWxdSKtdTNitxu1BTB4N2qeK0QCoZgdxisItVbnlLg6UGvSmd3lubF8JnFWkHfAWW YqeICW2y7iNV1BssDEcBVe5V6BBSYORmHOPDa48vlhUA2xTPJLvsodR8uZxtambRPP0d Hnf8M9S0NejWBN0n0ZD/NHko0vBEUMu295g5wMu5pag0CAXzhinYaZnXdYvW2GFw9EbG 0m3g== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9GuxyrBFKYLs78grpgSGeSep9HVrUh/u5wawxR5bpaA=; b=meTydQ6uMNbOi0kZUCwkGxdvbMCJW2UVUqNWGwhjEcipb/2SDxllc1tslAc6Rt9hvP F5X8nbQxKHjIl6i2Ovro5M6HWIAoleXdIL291vgd8+0mpObL6eYCSouvqC+cNwGq4Mio LvLleBh5nd4wbxhGdFpFgUi1su8PlilCrzZB3Bnr4E3t3qrF0mYCnp6n/DjBCkNvVjQa /0IFCulK4gdmP0MXFmNCf3mJ01qsfgCiSptHPGEvrjd9aPGLkabpS0nN0cI1E3S+Q1Nq n0Z4x3k/OXUr2U2AvTb7T8ZjWfgVGGix765rEWVZw76IzaLq58bKqNFlZaD47kJc3X25 T+kg== 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 t20si8080971plj.94.2019.01.11.13.48.54; Fri, 11 Jan 2019 13:49:09 -0800 (PST) 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 S1726399AbfAKVla (ORCPT + 99 others); Fri, 11 Jan 2019 16:41:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36034 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfAKVla (ORCPT ); Fri, 11 Jan 2019 16:41:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A8ADA8C1A; Fri, 11 Jan 2019 21:41:29 +0000 (UTC) Received: from treble (ovpn-122-231.rdu2.redhat.com [10.10.122.231]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AC4160851; Fri, 11 Jan 2019 21:41:24 +0000 (UTC) Date: Fri, 11 Jan 2019 15:41:22 -0600 From: Josh Poimboeuf To: Nadav Amit Cc: Linus Torvalds , Andy Lutomirski , Peter Zijlstra , the arch/x86 maintainers , Linux List Kernel Mailing , Ard Biesheuvel , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Subject: Re: [PATCH v3 0/6] Static calls Message-ID: <20190111214122.dzye2mg32aksuyo3@treble> References: <20190111151525.tf7lhuycyyvjjxez@treble> <20190111200420.qtyffayxceysoarf@treble> <20190111203135.5clurevf34bkiy3o@treble> <20190111212210.veyfn5vvjswcwacm@treble> <6B0B7437-0577-4FE7-A0BC-EFB5D94B8C21@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6B0B7437-0577-4FE7-A0BC-EFB5D94B8C21@vmware.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 11 Jan 2019 21:41:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 11, 2019 at 09:36:59PM +0000, Nadav Amit wrote: > > On Jan 11, 2019, at 1:22 PM, Josh Poimboeuf wrote: > > > > On Fri, Jan 11, 2019 at 12:46:39PM -0800, Linus Torvalds wrote: > >> On Fri, Jan 11, 2019 at 12:31 PM Josh Poimboeuf wrote: > >>> I was referring to the fact that a single static call key update will > >>> usually result in patching multiple call sites. But you're right, it's > >>> only 1-2 trampolines per text_poke_bp() invocation. Though eventually > >>> we may want to batch all the writes like what Daniel has proposed for > >>> jump labels, to reduce IPIs. > >> > >> Yeah, my suggestion doesn't allow for batching, since it would > >> basically generate one trampoline for every rewritten instruction. > > > > As Andy said, I think batching would still be possible, it's just that > > we'd have to create multiple trampolines at a time. > > > > Or... we could do a hybrid approach: create a single custom trampoline > > which has the call destination patched in, but put the return address in > > %rax -- which is always clobbered, even for callee-saved PV ops. Like: > > > > trampoline: > > push %rax > > call patched-dest > > > > That way the batching could be done with a single trampoline > > (particularly if using rcu-sched to avoid the sti hack). > > I don’t see RCU-sched solves the problem if you don’t disable preemption. On > a fully preemptable kernel, you can get preempted between the push and the > call (jmp) or before the push. RCU-sched can then finish, and the preempted > task may later jump to a wrong patched-dest. Argh, I misspoke about RCU-sched. Words are hard. I meant synchronize_rcu_tasks(), which is a completely different animal. My understanding is that it waits until all runnable tasks (including preempted tasks) have gotten a chance to run. -- Josh