Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2380112pxb; Tue, 12 Oct 2021 05:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtPUcDVLfxgyKEndpQPAGPUDFqL098accIpsiSyOpxhTZ615L3z/TSTPwlwBKlr7pxrCEP X-Received: by 2002:adf:a294:: with SMTP id s20mr31570855wra.34.1634041897770; Tue, 12 Oct 2021 05:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634041897; cv=none; d=google.com; s=arc-20160816; b=i7R7DCOPFBu5kXHdx0FpfO+aN/nhokgmQxLS9hDQ9XChLO+lUQ+oV5RiubTHD1Fxuk pVT3Sb/+aawrjS4uvDigdWh5084uHl7iq07laCzs8i1bMEHsgVHsALhd5l4pvCxNX+gT 784xad3WhoeqKxNkuFMy9E6XxC/zo0x2YP7uXyBF2RBVcUIE4kbiixqCG4uxzzmlAXOE nD8q6IxXe9odLv1MDE4LFXfTKVKC60yYJJklNh8x5V+uixziEpU+AhdtZ10yjKVbXjtK 1tj/fNESshEm+eDcHzRImzlZG+okQ498gUzKrcl/Ra3qdX6hKJ6PrPrSmeRtuBo5utgq btjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=mkH8oT6A/Ua6QxgQhhs2BQojKD42D5pReZZBqmCiodw=; b=UqzpnYJzielO4mklUJqMKm5x8djevn107Nt6xVazx195PtM+OMATGnieFhxrtmQqJE SWH1F7ZMKd+xNzAivojDSQU9nzQ41AV0U1+7PYcnAWUcJWAR6DhP0OrBTEBHvOZ1Mqar sprKFWT9e3xZZ6vBWN3GxEyqP015uqht6sTybKUPNCcPBvayJLCUptFz0XeUzQfNrR7l sUaR49NBwxEamwzAH/xXcup3RzcfVt7EhzRKIYf8WWQ7/o2JeBeJowQkJB1XEceYlzP/ tbQ4mITinhzodh8YMbCdKzM1FtMj0iynKVaAbmZfz20dgZZwu0eKezp9ji7BEioZJShO sZBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si15134249edu.157.2021.10.12.05.31.11; Tue, 12 Oct 2021 05:31:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236394AbhJLMb0 (ORCPT + 99 others); Tue, 12 Oct 2021 08:31:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236281AbhJLMbZ (ORCPT ); Tue, 12 Oct 2021 08:31:25 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8122460E74; Tue, 12 Oct 2021 12:29:21 +0000 (UTC) Date: Tue, 12 Oct 2021 08:29:20 -0400 From: Steven Rostedt To: Miroslav Benes Cc: =?UTF-8?B?546L6LSH?= , Guo Ren , Ingo Molnar , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Jiri Kosina , Petr Mladek , Joe Lawrence , Colin Ian King , Masami Hiramatsu , "Peter Zijlstra (Intel)" , Nicholas Piggin , Jisheng Zhang , linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, live-patching@vger.kernel.org Subject: Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion Message-ID: <20211012082920.1f8d6557@gandalf.local.home> In-Reply-To: References: <8c7de46d-9869-aa5e-2bb9-5dbc2eda395e@linux.alibaba.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Oct 2021 14:24:43 +0200 (CEST) Miroslav Benes wrote: > > +++ b/kernel/livepatch/patch.c > > @@ -52,11 +52,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, > > bit = ftrace_test_recursion_trylock(ip, parent_ip); > > if (WARN_ON_ONCE(bit < 0)) > > return; > > - /* > > - * A variant of synchronize_rcu() is used to allow patching functions > > - * where RCU is not watching, see klp_synchronize_transition(). > > - */ > > - preempt_disable_notrace(); > > > > func = list_first_or_null_rcu(&ops->func_stack, struct klp_func, > > stack_node); > > @@ -120,7 +115,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, > > klp_arch_set_pc(fregs, (unsigned long)func->new_func); > > > > unlock: > > - preempt_enable_notrace(); > > ftrace_test_recursion_unlock(bit); > > } > > I don't like this change much. We have preempt_disable there not because > of ftrace_test_recursion, but because of RCU. ftrace_test_recursion was > added later. Yes, it would work with the change, but it would also hide > things which should not be hidden in my opinion. Agreed, but I believe the change is fine, but requires a nice comment to explain what you said above. Thus, before the "ftrace_test_recursion_trylock()" we need: /* * The ftrace_test_recursion_trylock() will disable preemption, * which is required for the variant of synchronize_rcu() that is * used to allow patching functions where RCU is not watching. * See klp_synchronize_transition() for more details. */ -- Steve