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=-3.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham 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 D940DC43387 for ; Fri, 11 Jan 2019 21:41:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B54812084C for ; Fri, 11 Jan 2019 21:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfAKVla (ORCPT ); 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