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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74054C0015E for ; Tue, 25 Jul 2023 13:40:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D4AC6B0075; Tue, 25 Jul 2023 09:40:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 082FB6B0078; Tue, 25 Jul 2023 09:40:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3D828D0001; Tue, 25 Jul 2023 09:40:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D15C06B0075 for ; Tue, 25 Jul 2023 09:40:21 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3AB7680E1E for ; Tue, 25 Jul 2023 13:40:21 +0000 (UTC) X-FDA: 81050243442.19.EE068D1 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf12.hostedemail.com (Postfix) with ESMTP id 190D940013 for ; Tue, 25 Jul 2023 13:40:18 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=hU0juKjh; spf=none (imf12.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690292419; a=rsa-sha256; cv=none; b=US87ahDDeZFGPS13AS/7IzeFOS91QqnPjIOGV6DADbo9uTdWyxNoQ7rLoCfj83jjGdGWWK +l6RlYdFwU57UqdMyXqaQmo9ZFXgVAqdgj2pW+/RUooLBx6EktVBKLtKViq6tppMDtJDZp a8Gl8c+TQZ1TLi3SWwWbhPu/RsbfwR0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=hU0juKjh; spf=none (imf12.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690292419; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AqhhXygkgYbNIUoMbam6nKKv+65xhkGjy3g6V0cI3YE=; b=pIWd7+vRJQkVRPXajAs7+aiyIMopQQJkl9QtU4HwISP8KUqvNAB8woC4yshDjqQALobmTb BGWF3d77QHDGNFLhu3i1LgKSKkRb5UMiew/mIo29Ub8v9kpZ5ITHAV/pyNehkRINVL46Kl ZoDO/HlF4fpoMAZZjXAcd3QRK7zMfz8= 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 1qOIGI-004AGS-1S; Tue, 25 Jul 2023 13:39:39 +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 C9A0B30036B; 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 190D940013 X-Stat-Signature: k7huciguma8hrxih1mqhkx5zpn66wcke X-Rspam-User: X-HE-Tag: 1690292418-290837 X-HE-Meta: U2FsdGVkX1+/dnsh33KbNYvN5Hq3y451vmOAF8Fm+BPaky3anX5wkxn94tl2dB6zcBHMp9b3jb0Hc05QGGiCQ/+vzGs/zamgx4ElaVIDToO4i6nvOote6VI9+eTskWJfqLq+DT7Uv3L9kLmAZpr036tlN4p/2cq/Pqe9ItnxnePRYgSlcwAJPhGdEYuWyuJ393CFSfOrtDf5iEyi9Nv+HPCdno3dd20nQWL9b/kTS/HNVh2TAk6MhLtj59xCiO2WBzKfHfLQFE9lLa7HI9wUxa32FZ2zBjWQBZpUywubpM2DYmWqgzXeGCvgNf/ahUwIfgOKrlpkLJYp2Hr40apYdIvKlM0djgKqg09qVs6OKbfbM8mFQLunTsI+Pt3XCE1vT9hQsA57JlhGXFEZuV9SJ36AGUGL1KrFtrGPJCp5XwOY4UlPvnZp3ufB3CrMzpI72PgeBchMxj3gEzA/8pBBohRN55ttPv8zX3ZZDQ/PpyHY9Okghnj/Hoe39IlecL7x4j3YkVpLE8wn/SfpT/trrWtJawa9D0G0NJcjuXTtopHFi6AegA+WYzChgxf/IXZkkMyH4tZTLiQqqx1pq+HkQpr8DLnscmIFVYU0Evk21Q7uWefqOOssD6hCAcq92pUL4S+ST8bfmJCKHLkKRlHlV34FNW7ntkOsV6VVdO6447pgcs1tO0EsEMGt+ecglWH7lkel2nmSISrYdnZCAykUvYoHMlNMXtpfsDBs3G83fyprvw6MxNHu+FoGNN/8mPUjXqxEWyJ8sYxGh92RBywqWdxiVY842+N7XVO3767SBqtxV/CwZJfTuGlns5f/nf//UE88xAhw4JMt6qZ4JxQxvtSpkxJQqNYXGPXWgBqdZveEJufxE1rxz5zaIdQRXtmycLtfmFPrZvfpH76vxEds06T2Do0gME4ks+uwYvaOtBHIk2pnaq5dmN4mD2ATxs823WIgvfkaAkbsCLIO/7G BRCakClH LSADNLtsNrRF5OUNozDWiXt3+Lc0fAGmSikazvWw+jmC7oH8DkAC1wkWRztcKq+GvFMasQ5se7ru+GdyFlWMfRu9H28Lq5ZDJsFfhN8BmJpFcKKN4L/XcwZs3N3AmojYBytVKeqUNKX0pOF1qRQcfeySzRfyuwUiM8amRkStB1R4GyQhm/fWpIUu9UAwt2B2ecm5R90cvaRdTKEG6s0nrtp67LsRkUhifqMnW4Aq0sGWwlMUYir+9y2tCq0fZNxfZ+TvpCtsB1J8S9JIUfEpQPWwYHQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.