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 BD0B5C27C4F for ; Fri, 31 May 2024 15:31:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40A006B008C; Fri, 31 May 2024 11:31:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B9976B0092; Fri, 31 May 2024 11:31:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A8426B0095; Fri, 31 May 2024 11:31:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0CF876B008C for ; Fri, 31 May 2024 11:31:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B5161120A67 for ; Fri, 31 May 2024 15:31:27 +0000 (UTC) X-FDA: 82179080214.18.E7F0298 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 1B35940012 for ; Fri, 31 May 2024 15:31:25 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of mark.rutland@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=mark.rutland@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717169486; 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: in-reply-to:in-reply-to:references:references; bh=mE7/vC9nd6+vjcHVyD7TtacNUdFLTr6J593jxr3DGeM=; b=l3jIBh07eJCw3xevGHCz4mf2UuJO9bl0+vttyhkg4saPE5S8tmot2dcN4ElZPyrN8lyB+6 MAtQ3yTuYfql6RKzgvKDJjwEbYrltiMqwYEqAlvWLH8tbGihJjXj8ZzgG4EDMQ2+sxs0fa vQ324TLiaW19ygeNKQNXlIP0NuEJp2Y= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of mark.rutland@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=mark.rutland@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717169486; a=rsa-sha256; cv=none; b=8FjcOrmpR57l630noB3euvRTpvQuIe1MrkZha0ddl2bZWa4fzepEkgkxfGbq3SnhdOmf0Y z+NMErxkkUspyHr5duIEIARjstRikP08rxVydZKZ2gibFAqL5EucCiZBCuKXvSz+aFc84q 97RgCfocWycpQRJKJdZq+4F8USlZ3v4= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 559941424; Fri, 31 May 2024 08:31:49 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A56163F641; Fri, 31 May 2024 08:31:21 -0700 (PDT) Date: Fri, 31 May 2024 16:31:14 +0100 From: Mark Rutland To: Vlastimil Babka Cc: Akinobu Mita , Christoph Lameter , David Rientjes , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , Steven Rostedt , Jiri Olsa , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH RFC 0/4] static key support for error injection functions Message-ID: References: <20240531-fault-injection-statickeys-v1-0-a513fd0a9614@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240531-fault-injection-statickeys-v1-0-a513fd0a9614@suse.cz> X-Rspamd-Queue-Id: 1B35940012 X-Stat-Signature: 3df6ybs6ei68nupd8kgoe33opqm4s6ks X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1717169485-255176 X-HE-Meta: U2FsdGVkX1+BMeU+qzCNNWPFXl/tYES/2mKOKcyfc+OZfvdCTXABUjTP6UyAN8FoP9/XJaHEZCNUe/qA+KBzPUxfOGDZfbViL2gk2VlCTF04XPyEMY6z20vqTv1rU1Cv8lbVKao3nDEIyZrtvxzMs8ymYbIijUQBjPgJHbm7MRckZCyF+05qSfjKLzeROTAXrJ3Pi3jKI2M3xZr9k3ZNe37P7pTdN1LamqQJwcwClGbr20/mCbJteECLFxgBIaJKMyEQxefsnK+vXjZ/tjtqjCN9cF1B5F75NXzLL78P3rv54OTonVZmAT9WkeOVJLwHiV27zosyzWFwzLeRXQ1GjR1D4toeIXHw3MaqgvUX3DbWAHMAL6xADoYmYPQ8gcO6leH36YKmfRkErmuG8596DdsZTfn913iogHx4b7E9DV2/e90LZ054leT6ACf/XVnncSVq+fRi98nIELSmIxtvPvHwsnv6g6olgFsMzSSFXtfXdn6MSCLhyeEBXE2HD16u4QNiqFf+oHEq27H+7oUi69awfUju4xawgwiPuQFAYmOAamlhqOJ2wBKiebwJ6NJjiS5Yv95QlZygPzy2PiCgHZh7Uz0P1CBYVj0weljmhMvz7xto7PMzkano1ZwFuIQBmx7HN5+/sB7DgqcTGJm+bbc3cvcWkdWYihO/SBiunYrERs+iHLi1p5pPJyMWaTxKGjWoCkv9k+tY/4eCiEHdsF88MKphmA2Rw8lBjr3OA1lXcGxJjCIrlvESGIFdJK0PUFic4jJEbdYK0LyGrNEukY3GFIpB9h1UrJ3PXPT+GkaqZ/Q/LqkJmvaNItwN88aASnlVqhjqWEFGlJ3OmhzYAXZi8hHhQp2rE/ZLUYyh/SB0mJs4CZg9hWsQ1yoSDNDThygEcP7/VS2egKMrQdPX/hQBZuhv4HgIkPDnOL2cbTZN62EZV3XncoryCmEEc+vhPjUiplzhZ6eeAq9zsRR 6/uE4kf+ bf0P7IWTHqig6W5lz9RlcvInNd454X2nUSitsZp0Gdr2eqjLrj5oKIv6mGmN2aS/mRe/u7i6Iwlsimc7k3/K7JvxoSlHXEbVwyRzEfHaKeIVvU2QzfAHm6JIUlAydPeCeWlQ02kfbI+u5KDiu0E1mnz5oP1XCLQf7IlpEBuw/c2Rlu719bt14voo2vQ== 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: List-Subscribe: List-Unsubscribe: Hi, On Fri, May 31, 2024 at 11:33:31AM +0200, Vlastimil Babka wrote: > Incomplete, help needed from ftrace/kprobe and bpf folks. > - the generic error injection using kretprobes with > override_function_with_return is handled in patch 2. The > ALLOW_ERROR_INJECTION() annotation is extended so that static key > address can be passed, and the framework controls it when error > injection is enabled or disabled in debugfs for the function. > > There are two more users I know of but am not familiar enough to fix up > myself. I hope people that are more familiar can help me here. > > - ftrace seems to be using override_function_with_return from > #define ftrace_override_function_with_return but I found no place > where the latter is used. I assume it might be hidden behind more > macro magic? But the point is if ftrace can be instructed to act like > an error injection, it would also have to use some form of metadata > (from patch 2 presumably?) to get to the static key and control it. I don't think you've missed anything; nothing currently uses ftrace_override_function_with_return(). I added that in commit: 94d095ffa0e16bb7 ("ftrace: abstract DYNAMIC_FTRACE_WITH_ARGS accesses") ... so that it was possible to do anything that was possible with FTRACE_WITH_REGS and/or kprobes, under the expectation that we might want to move fault injection and BPF probes over to fprobes in future, as ftrace/fprobes is generally faster than kprobes (e.g. for architectures that can't do KPROBES_ON_FTRACE or OPTPROBES). That's just the mechanism for the handler to use; I'd expect whatever registered the handler to be responsible for flipping the static key, and I don't think anything needs to change within ftrace itself. > If ftrace can only observe the function being called, maybe it > wouldn't be wrong to just observe nothing if the static key isn't > enabled because nobody is doing the fault injection? Yep, that sounds right to me. Mark.