Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4530439rwo; Tue, 25 Jul 2023 07:25:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlG/xYW4HJuO8l/FxFjYtuV69RkVhBvr8SFIjuEe9SoouXJ2f2RKaJjwa77E6Y6YYqIFjYfn X-Received: by 2002:a05:6a20:508:b0:130:835b:e6b7 with SMTP id 8-20020a056a20050800b00130835be6b7mr9162707pzp.47.1690295117454; Tue, 25 Jul 2023 07:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295117; cv=none; d=google.com; s=arc-20160816; b=ubqTicIE7j5lck4TQIDQYHLrLILfyFmpGmsu1R41nSR9Xx08ABscIxJfR3108lK/7t jwhFMiBJkuALcbuVA9Sq+0YhLiRgtpygpGEJNbsT2celGPKB2zSz73kzY+5noFmKRL7h mEjp9S+bRuSKIbDPRPK5/kxvIXvWwOFtjECUyWV+IgJCqNtk4beEP4d7BoVdlt5Pr1KW cIU/yzxjAcV7afBqQTIRG7Mtu25eGIqvsIXHIU9h4sWCBeJ6Nxt+9EqPKeKMDy1kuNkW veuS3DVUA7KNdzUoQVmqfSHVXcNwgt59W/2uIXkRAPN7O6CcrCE5nJxwBs1pit1jinaJ khZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AqhhXygkgYbNIUoMbam6nKKv+65xhkGjy3g6V0cI3YE=; fh=ey1j/7BgyS/4wWfsbyGkrtKs5OF42wPqAIpIXt7ZEeY=; b=jRjfQxwSsGXjgNFaSGALeFkjiEzMC7snGq9g9Vsc06WAfP0T1N9F9UaNeOBKUlBj3c M6ObQ8TiHkGnseOOVOBxN3KXUZ1T2EDcaY0OxJoSZGP6DUxeFrQnx67t9mebmruuyrwb ORpeRc6NPLO2+BkE2hGsEGpU/pf7Pd+h/kTkE6aCqZ/Ba9avs71bZ5Slju8NhwLl/CyV di5LcofYg+DPjra8nEEhbqU5B+DoBzynd2NjUWCoZyM1Lsw5qld0rflrvq9JyDhT+grL wWI3uJ1z7eh3WUTL6R24KZiLRiUqSNCfh9fl7qVsFprDFNyI7Fx9HALfWBX8wdBXT+tk +TPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=hU0juKjh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l23-20020a637017000000b005579a12f405si12129070pgc.200.2023.07.25.07.25.05; Tue, 25 Jul 2023 07:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=hU0juKjh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbjGYNjo (ORCPT + 99 others); Tue, 25 Jul 2023 09:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231221AbjGYNjn (ORCPT ); Tue, 25 Jul 2023 09:39:43 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E6D2BE; Tue, 25 Jul 2023 06:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=AqhhXygkgYbNIUoMbam6nKKv+65xhkGjy3g6V0cI3YE=; b=hU0juKjhnKQNMPcWxGTglXF1kD xBeNXFwO6bnr7cRSGSRHFONAWDnx+6524lg/8FLjxvB00LuNdyZOyZfcpfPUYsI9/m4/wxx3XADTa IhO/K2oW4GRTfGIQ608wBXqm9GjRT1kOVe8WYSkXmy8R6Xy4Kmol7TQFesj4k3+2Ucyms3qwYaJY7 jLJUnGnJNEcVrXPXgDy1IK44aIJfxkS+/FqW0+yWhU8qeyJh4cu9RXzeK/Gb1Zl8copgtkKLHoxDF JMGM13VNEgUa451vGA877Yf6lodJWN7+QQiNx8EG7C7Z5r9rUdrUihkgPelx/JvMdyFS4IfyITpst ZPZuwbig==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qOIGH-004AGP-0U; Tue, 25 Jul 2023 13:39:38 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C0A9B300095; Tue, 25 Jul 2023 15:39:36 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A54B92CCD6B85; Tue, 25 Jul 2023 15:39:36 +0200 (CEST) Date: Tue, 25 Jul 2023 15:39:36 +0200 From: Peter Zijlstra To: Joel Fernandes Cc: Valentin Schneider , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, Nicolas Saenz Julienne , Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Jason Baron , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: Re: [RFC PATCH v2 18/20] context_tracking,x86: Defer kernel text patching IPIs Message-ID: <20230725133936.GM3765278@hirez.programming.kicks-ass.net> References: <20230720163056.2564824-19-vschneid@redhat.com> <6EBAEEED-6F38-472D-BA31-9C61179EFA2F@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6EBAEEED-6F38-472D-BA31-9C61179EFA2F@joelfernandes.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 25, 2023 at 06:49:45AM -0400, Joel Fernandes wrote: > Interesting series Valentin. Some high-level question/comments on this one: > > > On Jul 20, 2023, at 12:34 PM, Valentin Schneider wrote: > > > > text_poke_bp_batch() sends IPIs to all online CPUs to synchronize > > them vs the newly patched instruction. CPUs that are executing in userspace > > do not need this synchronization to happen immediately, and this is > > actually harmful interference for NOHZ_FULL CPUs. > > Does the amount of harm not correspond to practical frequency of text_poke? > How often does instruction patching really happen? If it is very infrequent > then I am not sure if it is that harmful. Well, it can happen quite a bit, also from things people would not typically 'expect' it. For instance, the moment you create the first per-task perf event we frob some jump-labels (and again some second after the last one goes away). The same for a bunch of runtime network configurations. > > As the synchronization IPIs are sent using a blocking call, returning from > > text_poke_bp_batch() implies all CPUs will observe the patched > > instruction(s), and this should be preserved even if the IPI is deferred. > > In other words, to safely defer this synchronization, any kernel > > instruction leading to the execution of the deferred instruction > > sync (ct_work_flush()) must *not* be mutable (patchable) at runtime. > > If it is not infrequent, then are you handling the case where userland > spends multiple seconds before entering the kernel, and all this while > the blocking call waits? Perhaps in such situation you want the real IPI > to be sent out instead of the deferred one? Please re-read what Valentin wrote -- nobody is waiting on anything.