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 E0B86ECAAD3 for ; Thu, 1 Sep 2022 08:43:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5349A8D0001; Thu, 1 Sep 2022 04:43:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BDA16B0073; Thu, 1 Sep 2022 04:43:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383FC8D0001; Thu, 1 Sep 2022 04:43:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 24CDF6B0072 for ; Thu, 1 Sep 2022 04:43:41 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 044C214073F for ; Thu, 1 Sep 2022 08:43:40 +0000 (UTC) X-FDA: 79862878242.01.8A5141D Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by imf23.hostedemail.com (Postfix) with ESMTP id B7CBF140053 for ; Thu, 1 Sep 2022 08:43:40 +0000 (UTC) Received: by mail-lj1-f177.google.com with SMTP id q16so17126606ljp.8 for ; Thu, 01 Sep 2022 01:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=VH72CkJdWHRYjuIFqG3YYZtTrJw2Fhi5jnFxkucPCHY=; b=q7AjWjhmnd64a4Ge80aSMXzM40DYISK3cXmW/EibDBVwJ+8k/kXbGydZOb9luK+PIZ Ht/KjsMCWD5TF/twQCHm6itfvd6g64oIsvl5c5eKge4E9VhNnF7iOxqToHuyozIfoFb1 5I88bd1UfHObAquK0acXH+XbI6Py13HNPo09dD+NGiTxpVgIr43RQcU5305AlaqKPpll qwKybw5Q2+9d/Onlv8u1vDEdJlLQ1JUMSCRevC4eAiHePyL2wzZzh3KSvr/OLrTmD05T eLyu3SeubEOLjLKn16wG4v4TsahkBmU2CrHwp0/PiiByarcOmjtEcsv6KWve7EKHFu99 DiuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=VH72CkJdWHRYjuIFqG3YYZtTrJw2Fhi5jnFxkucPCHY=; b=4tUhCHo+V+1HHCCII8SmBPGt9OiKlC7/83Nj1EWu3xSV3T/aLFFlmjU4ee/tkoTOhr KIWLNX/earKrxH1XKY1z060CFsC6lPUhXpfMwusVZj++hDuhmRqWSb8lfmTwUd8j8Aor S+l9SYR9kQWaYzXN5TYz3XmVdfWq15oBbpZNt+cxc0XmY04kzlny9u2SSM+9IpgxGG9B h0a3l7HNIMt7+lnk9wR1LZ3s4J+KVzVVTmMdwYF2TPxcl27b15TLJ3acdme834Vb0V/S zs1Tsen2s4T3v12rhKDwN1YvBPP7J5AlEZOM249EM+tmaxs6rSreFRNhIs4S3OPds/I5 1vaw== X-Gm-Message-State: ACgBeo1kQ9J/xhMdG8u5ntQqVgduMGVXI49er3tXBS2/bC1f9hC+pZ1U +iZBhdib8l5fmNYcsV34PUBDHYKf3q6FXhuAK4Hv3w== X-Google-Smtp-Source: AA6agR4BjD3DwjS+CZ4CCVxEVQ6+miy/r1+fo/IQYDRJogJb7LowD/eAhVezdlkQzk6xOh63IrvI7g9qP1YqXlNutus= X-Received: by 2002:a2e:be88:0:b0:25f:e9a8:44b8 with SMTP id a8-20020a2ebe88000000b0025fe9a844b8mr8851946ljr.92.1662021818766; Thu, 01 Sep 2022 01:43:38 -0700 (PDT) MIME-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> <20220830214919.53220-23-surenb@google.com> <20220831173010.wc5j3ycmfjx6ezfu@moria.home.lan> In-Reply-To: <20220831173010.wc5j3ycmfjx6ezfu@moria.home.lan> From: Dmitry Vyukov Date: Thu, 1 Sep 2022 10:43:26 +0200 Message-ID: Subject: Re: [RFC PATCH 22/30] Code tagging based fault injection To: Kent Overstreet Cc: Suren Baghdasaryan , akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, shakeelb@google.com, songmuchun@bytedance.com, arnd@arndb.de, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-mm@kvack.org, iommu@lists.linux.dev, kasan-dev@googlegroups.com, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662021820; a=rsa-sha256; cv=none; b=gu/u2piN7sIj1uMHnyfuLDbbR5YOsuK278UI+QAQ1pmtO3HUHoQYJYjgH+/o9W8KdupGo1 LGGNiek5dGcsmwYmvHzugQsS/XueiO6wp5r2XpVFyiIDLrGw7onERcz8O1/Uw/K7dsKM2Q 8yFxiD5y+damPkF9UOpY5p+tOyNUh74= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=q7AjWjhm; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of dvyukov@google.com designates 209.85.208.177 as permitted sender) smtp.mailfrom=dvyukov@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662021820; 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:dkim-signature; bh=VH72CkJdWHRYjuIFqG3YYZtTrJw2Fhi5jnFxkucPCHY=; b=WsRg/BagszcTz52PAOUj34PvXT/AF91xVpVY4CaFP8eazkZYEGpmGcZjpWJx+GViIZanOS Kw4zjsx+Oyi9y7m+PR0UpOheDhtncP3D7Hmcm1tBzoS+8bjtg5J6jtS8yJnxUIZhT37A+L UbD7c4ppugE9NMD7huPpHSUh00Q7itg= Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=q7AjWjhm; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of dvyukov@google.com designates 209.85.208.177 as permitted sender) smtp.mailfrom=dvyukov@google.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: jyggynjiwdz3ssfb5tz1txdgaagu5bnx X-Rspamd-Queue-Id: B7CBF140053 X-HE-Tag: 1662021820-721891 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 Wed, 31 Aug 2022 at 19:30, Kent Overstreet wrote: > > > From: Kent Overstreet > > > > > > This adds a new fault injection capability, based on code tagging. > > > > > > To use, simply insert somewhere in your code > > > > > > dynamic_fault("fault_class_name") > > > > > > and check whether it returns true - if so, inject the error. > > > For example > > > > > > if (dynamic_fault("init")) > > > return -EINVAL; > > > > Hi Suren, > > > > If this is going to be used by mainline kernel, it would be good to > > integrate this with fail_nth systematic fault injection: > > https://elixir.bootlin.com/linux/latest/source/lib/fault-inject.c#L109 > > > > Otherwise these dynamic sites won't be tested by testing systems doing > > systematic fault injection testing. > > That's a discussion we need to have, yeah. We don't want two distinct fault > injection frameworks, we'll have to have a discussion as to whether this is (or > can be) better enough to make a switch worthwhile, and whether a compatibility > interface is needed - or maybe there's enough distinct interesting bits in both > to make merging plausible? > > The debugfs interface for this fault injection code is necessarily different > from our existing fault injection - this gives you a fault injection point _per > callsite_, which is huge - e.g. for filesystem testing what I need is to be able > to enable fault injection points within a given module. I can do that easily > with this, not with our current fault injection. > > I think the per-callsite fault injection points would also be pretty valuable > for CONFIG_FAULT_INJECTION_USERCOPY, too. > > OTOH, existing kernel fault injection can filter based on task - this fault > injection framework doesn't have that. Easy enough to add, though. Similar for > the interval/probability/ratelimit stuff. > > fail_function is the odd one out, I'm not sure how that would fit into this > model. Everything else I've seen I think fits into this model. > > Also, it sounds like you're more familiar with our existing fault injection than > I am, so if I've misunderstood anything about what it can do please do correct > me. What you are saying makes sense. But I can't say if we want to do a global switch or not. I don't know how many existing users there are (by users I mean automated testing b/c humans can switch for one-off manual testing). However, fail_nth that I mentioned is orthogonal to this. It's a different mechanism to select the fault site that needs to be failed (similar to what you mentioned as "interval/probability/ratelimit stuff"). fail_nth allows to fail the specified n-th call site in the specified task. And that's the only mechanism we use in syzkaller/syzbot. And I think it can be supported relatively easily (copy a few lines to the "does this site needs to fail" check). I don't know how exactly you want to use this new mechanism, but I found fail_nth much better than any of the existing selection mechanisms, including what this will add for specific site failing. fail_nth allows to fail every site in a given test/syscall one-by-one systematically. E.g. we can even have strace-like utility that repeats the given test failing all sites in to systematically: $ fail_all ./a_unit_test This can be integrated into any CI system, e.g. running all LTP tests with this. For file:line-based selection, first, we need to get these file:line from somewhere; second, lines are changing over time so can't be hardcoded in tests; third, it still needs to be per-task, since unrelated processes can execute the same code. One downside of fail_nth, though, is that it does not cover background threads/async work. But we found that there are so many untested synchronous error paths, that moving to background threads is not necessary at this point. > Interestingly: I just discovered from reading the code that > CONFIG_FAULT_INJECTION_STACKTRACE_FILTER is a thing (hadn't before because it > depends on !X86_64 - what?). That's cool, though.