Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1897891rwb; Thu, 8 Dec 2022 17:11:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf4DWeDQXUVtWTB719LJs9Jl0/aH5vZ6CRo9wHqhKamNZen2EAZT/3KBglUhhLBgjsxAQDxr X-Received: by 2002:a05:6a00:21c1:b0:56d:dd2a:c906 with SMTP id t1-20020a056a0021c100b0056ddd2ac906mr4833622pfj.5.1670548301753; Thu, 08 Dec 2022 17:11:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670548301; cv=none; d=google.com; s=arc-20160816; b=qHwxKtYk348LL6ZZAgD6wQ2Pj59N7+OAUAXxqle083l32fFlPJ8wxYs+WDFTZJ8oU9 QcYCnfSgkIgFD/MqAbMyDOGSfVCv6u3GygN5JTAdiBMkqoh8WWqnoyvwLYvdXBQQGSDS d+7h+K08mlypkDCTLH1VBnRl5ICgJ62FJrioeKic6i3g9t2M2IiGtkR440tf2EwF+H71 3GjxzS6A4jKVkZmj0Ebkd9m33MCw6B6XlmUvSnmDNzMBC2XCCqM7/d1ARH946w4RNSTN i+5sBD3rec1TBHOlybv4nJA7dZC4PxvNkXQFXqNfs0TBfrzFcG1alRC4/S8D+BEDCzlP K9vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JXnis/zc8U9zquz7LWANbIfYXreLG2esqriGNImoIRg=; b=ltwul/GUi/GRjF2LFyydP8ccX15NgY7M5yQq7vxu37JYLX0jiMEt6GM2XxHb0Vv6SE muiGsmtxjlEaNKDeBHx5LteFIJhb/yseTPSiJtgFKYdJCxtwvGptoWr1XHhXSfWDrZul CjuGxov1T9I7slOsaOcZ1CaeF/g0fKjmz0imOlwL3ev0eSX5aMF5Q+qqyjxBhNpeehpx MFNraszo/TzXAIR2WJouvSX++pOL9dmWObRIquuYtTwzHk8JKH8t8ZQ1+TIRaRdgpvFS RxX4kdCAQtXWKbAkhH6I5ZteKYaB0fut8HKoBaIoG21d8SbuF8OQ5dCCj5XGwaU0N9Ka mhMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MrD4avYn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020aa79433000000b005778bad9750si386298pfo.17.2022.12.08.17.11.31; Thu, 08 Dec 2022 17:11:41 -0800 (PST) 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=@google.com header.s=20210112 header.b=MrD4avYn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229517AbiLIA7M (ORCPT + 73 others); Thu, 8 Dec 2022 19:59:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbiLIA7J (ORCPT ); Thu, 8 Dec 2022 19:59:09 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C117B577 for ; Thu, 8 Dec 2022 16:59:07 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id q7so3389886ljp.9 for ; Thu, 08 Dec 2022 16:59:07 -0800 (PST) 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:message-id:reply-to; bh=JXnis/zc8U9zquz7LWANbIfYXreLG2esqriGNImoIRg=; b=MrD4avYnohCJ914+Y56t0XD+3FDuUbBD+17dMlrv9hjX6h4eE9hBqXaos4VaJnkMcf GGBXgL1PwAh5epA17v0JcgsGWhMd/HeiMh8trjmPnedLRIE3PK081U6u26iLXtru2t0G /r2yNO/S5hTGkra9DUuxxyBxU96ugo1f2wWY1dkZs+9zwTQQM8BgmG1AeWJf1T2DMcwR k8m+Gc3tWSbr2ykVLmiuBpAqUIvgx2vFWT0E3nol7bNp+s8XVqrOoUxXfpGJH2ns5pJ+ Vrwqwe8oyuOLymzT2cgmTt0386MSOgvYXO68MobM8yALIym8pz/NqajtGETtiXh1tLvg pDKA== 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:message-id :reply-to; bh=JXnis/zc8U9zquz7LWANbIfYXreLG2esqriGNImoIRg=; b=0PSL+oMY+FDExaX8iW/MoF1z5dQWANWErWYFixonmFZVy8/pxEQQ5G3wD0C1OsPu47 YayPVdfWZXc+imOra25lm5r3LZlmb+V8voqsg+AbeMMLwQIqMFdkvM3ef0Za5CrdArda dj0EPpDYjmSi60aIT74P3Py7qUxvSsWD9CONpZmDwPhpPOtcxtUhvgSLndcjqhuaSxcO BxGE9yF3nPLPnNYVgzzoQlWwDEl3VXZhgJFriYMGv6hqRONsOsRjZ+qqf0/7O/yN1Bf8 rSLI7EX2RF1dvkZgLRFTiOUKgbKsqcVp/W9tWJzRx1Z7W7b8Priok6090Uk/4W5c4yex mTQg== X-Gm-Message-State: ANoB5pmDh4Epi6q/slhoa9CQ2Rc1TX3RZrIW9CBuPI5Q+A/N/SL/Zp0T OF9pT+7iLLYWv1zrxkcjYKUnO7g4A6XVfytm6h6Kow== X-Received: by 2002:a2e:8845:0:b0:279:fe87:67fc with SMTP id z5-20020a2e8845000000b00279fe8767fcmr5014125ljj.173.1670547545816; Thu, 08 Dec 2022 16:59:05 -0800 (PST) MIME-Version: 1.0 References: <20221109024155.2810410-1-connoro@google.com> <5708a47d-5400-e75e-ccf6-96177366ea38@meta.com> <0b9023b6-9742-b317-7596-98026a0c5d03@meta.com> In-Reply-To: From: "Connor O'Brien" Date: Thu, 8 Dec 2022 16:58:53 -0800 Message-ID: Subject: Re: [PATCH bpf-next] bpf: btf: don't log ignored BTF mismatches To: Andrii Nakryiko Cc: Yonghong Song , bpf@vger.kernel.org, Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Dec 8, 2022 at 4:03 PM Andrii Nakryiko wrote: > > On Thu, Dec 8, 2022 at 10:01 AM Yonghong Song wrote: > > > > > > > > On 12/7/22 6:19 PM, Connor O'Brien wrote: > > > On Wed, Nov 9, 2022 at 8:45 AM Yonghong Song wrote: > > >> > > >> > > >> > > >> On 11/8/22 6:41 PM, Connor O'Brien wrote: > > >>> Enabling CONFIG_MODULE_ALLOW_BTF_MISMATCH is an indication that BTF > > >>> mismatches are expected and module loading should proceed > > >>> anyway. Logging with pr_warn() on every one of these "benign" > > >>> mismatches creates unnecessary noise when many such modules are > > >>> loaded. Instead, limit logging to the case where a BTF mismatch > > >>> actually prevents a module form loading. > > >>> > > >>> Signed-off-by: Connor O'Brien > > >>> --- > > >>> kernel/bpf/btf.c | 7 ++++--- > > >>> 1 file changed, 4 insertions(+), 3 deletions(-) > > >>> > > >>> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > > >>> index 5579ff3a5b54..406370487413 100644 > > >>> --- a/kernel/bpf/btf.c > > >>> +++ b/kernel/bpf/btf.c > > >>> @@ -7190,11 +7190,12 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op, > > >>> } > > >>> btf = btf_parse_module(mod->name, mod->btf_data, mod->btf_data_size); > > >>> if (IS_ERR(btf)) { > > >>> - pr_warn("failed to validate module [%s] BTF: %ld\n", > > >>> - mod->name, PTR_ERR(btf)); > > >> > > >> I think such warning still useful even with > > >> CONFIG_MODULE_ALLOW_BTF_MISMATCH. > > >> Can we use pr_warn_ratelimited instead of pr_warn in the above to > > >> avoid excessive warnings? > > > > > > I gave this a try on a Pixel 6 but I'm not sure it quite addresses the > > > issue. The amount of logging doesn't seem to decrease much, I think > > > because the interval between loading one mismatched module and the > > > next can be greater than the default rate limit. To my mind, the issue > > > is the total volume of these messages more so than their rate. > > > > > > For context, Android devices using the GKI may load hundreds of > > > separately-built modules, and BTF mismatches are possible for any/all > > > of these. It was pointed out to me that btf_verifier_log_type can also > > > print several more lines per mismatched module. ~5 lines of logging > > > for each mismatched module can start to add up, in terms of both > > > overhead and the noise added to the kernel logs. > > > > > > This is more subjective but I think the warnings also read as though > > > this is a more serious failure that might prevent affected modules > > > from working correctly; anecdotally, I've gotten multiple questions > > > about them asking if something is broken. This can be a red herring > > > for anyone unfamiliar with BTF who is reading the logs to debug > > > unrelated issues. In the CONFIG_MODULE_ALLOW_BTF_MISMATCH=y case the > > > flood of warnings seems out of proportion to the actual result > > > (modules still load successfully, just without debug info) especially > > > since the user has explicitly enabled a config saying they expect > > > mismatches. > > > > > > If there needs to be some logging in the "mismatch allowed" case, > > > could an acceptable middle ground be to use pr_warn_once to send a > > > > So it looks like pr_warn_ratelimited still produces a lot of warning. > > In this case, I guess pr_warn_once should be okay. > > Maybe pr_warn_once generic "some kernel module BTF mismatched". And > also warn per-module message with details if > CONFIG_MODULE_ALLOW_BTF_MISMATCH is not set? > Yeah, I figured the logging behavior should remain unchanged when CONFIG_MODULE_ALLOW_BTF_MISMATCH is unset, the existing verbose logging makes sense when every mismatch stops a module from loading. Then for the pr_warn_once case something like "Kernel module BTF mismatch detected, BTF debug info may be unavailable for some modules" > > > > > single message reporting that mismatches were detected & module BTF > > > debug info might be unavailable? Alternatively, if we could opt out of > > > module BTF loading then that would also avoid this issue, but that's > > > already been proposed before ([1], [2]) so I thought working with the > > > existing config option might be preferred. > > > > > > [1] https://lore.kernel.org/bpf/20220209052141.140063-1-connoro@google.com/ > > > [2] https://lore.kernel.org/bpf/20221004222725.2813510-1-sdf@google.com/