From patchwork Thu Apr 22 19:47:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tanner Love X-Patchwork-Id: 426167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F0BCC433B4 for ; Thu, 22 Apr 2021 19:47:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BC356142F for ; Thu, 22 Apr 2021 19:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238818AbhDVTs2 (ORCPT ); Thu, 22 Apr 2021 15:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236058AbhDVTs1 (ORCPT ); Thu, 22 Apr 2021 15:48:27 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D675C06174A for ; Thu, 22 Apr 2021 12:47:52 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id j3so22657945qvs.1 for ; Thu, 22 Apr 2021 12:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BS4wMwOPy/+FHjBI5zqFwcN+ZsoK7V+Tg4hNVIYePko=; b=bVdYBzlCTCPh2RPU1AwFeo6nFmXpYrGgvQn164/liqW9Rw+cr1m7NWmBvrllzOm7Fl dvTXupIpxNlojbW5Bip3G4RNaNsn2/hn1fnA5nCl68TCPz4OlBmac7An/IyuAxSm++kV 5rAaWMweAoONZkbM8XbbvKUzpNJHxccURIsQVxLUm3eg4L5MqO6gbRpGA+7OJRlbWbnn Vg68Gw1tbrIhHBh24oS9VEPi3QPf9S270MqxlV1d+WROuw/BZvx3WKeQlBAVb8qq/UB1 RaPo3aqk5pPPJIqgUV2xIUV2BAU8n9uCpD/hQEHWzjxR9CmGcMIpwIpmogeRBT2zdIGf sGzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BS4wMwOPy/+FHjBI5zqFwcN+ZsoK7V+Tg4hNVIYePko=; b=kLl2HF8T0E4020w1Uw8mpMe2o5GgXtMMveewKXE3/RuK684d3nN6B1E/CPOf8pGo2J 9xE1aY5y1mpdlRaK7R6fplXtO+6xI4LNtEFA1k0giAleggNv25rJe3TWK/TCPdBNAq6J YkOAHFjbX4Qrt+wkk0PeAw9jlm5qrb8FL1ePezuQ9exbxC62js5mPBa0fiAy934IUjPv srYbgxytcucOD2dLjOGKfiPwPs14NZbk2tgXSzHY50JqlkvLVKnsvfc65FMbJkPuJxk4 Kp1UL0dnsq8y7fd7OxdCiBOxY+kke5qO8nJODsYH4R26WJ0min+EXkpbaMl7diz4likZ hSEw== X-Gm-Message-State: AOAM5326YmBDITc82gB4GNSFq7u9/8zc3b1EtZlQ7UkPBLNpvXPtdVfg 0p5b4vCGy4CjAqlBKBXEkh3clAOTzo4= X-Google-Smtp-Source: ABdhPJwIrKwrU1Ig5eGcFlLijh9jc7JwHmpA2YBtD+06MDMKAbeobUwd9uN3JPFBhaJ/jHZ6oM955w== X-Received: by 2002:a0c:da13:: with SMTP id x19mr522653qvj.53.1619120871601; Thu, 22 Apr 2021 12:47:51 -0700 (PDT) Received: from tannerlove.nyc.corp.google.com ([2620:0:1003:316:e069:ac66:9dd7:6f76]) by smtp.gmail.com with ESMTPSA id a4sm2821781qta.19.2021.04.22.12.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 12:47:51 -0700 (PDT) From: Tanner Love To: netdev@vger.kernel.org Cc: davem@davemloft.net, Tanner Love , Eric Dumazet , Mahesh Bandewar Subject: [PATCH net-next 1/3] once: implement DO_ONCE_LITE for non-fast-path "do once" functionality Date: Thu, 22 Apr 2021 15:47:36 -0400 Message-Id: <20210422194738.2175542-2-tannerlove.kernel@gmail.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210422194738.2175542-1-tannerlove.kernel@gmail.com> References: <20210422194738.2175542-1-tannerlove.kernel@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tanner Love Certain uses of "do once" functionality (such as many occurrences of static bool __section(".data.once")) reside outside of fast path, and thus do not require jump label patching via static keys. Implement DO_ONCE_LITE, which offers this "do once" functionality without using static keys. Implement DO_ONCE_LITE_IF, which offers the same functionality but gated by a condition test. This is common in current uses of static bool __section(".data.once"). Signed-off-by: Tanner Love Acked-by: Eric Dumazet Acked-by: Mahesh Bandewar --- include/linux/once.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/once.h b/include/linux/once.h index 9225ee6d96c7..a92bb213f817 100644 --- a/include/linux/once.h +++ b/include/linux/once.h @@ -52,6 +52,22 @@ void __do_once_done(bool *done, struct static_key_true *once_key, ___ret; \ }) +/* Call a function once. Similar to DO_ONCE(), but does not use jump label + * patching via static keys. + */ +#define DO_ONCE_LITE(func, ...) \ + DO_ONCE_LITE_IF(true, func, ##__VA_ARGS__) +#define DO_ONCE_LITE_IF(condition, func, ...) \ + ({ \ + static bool __section(".data.once") __already_done; \ + bool __ret_do_once = !!(condition); \ + \ + if (unlikely(__ret_do_once && !__already_done)) { \ + __already_done = true; \ + func(__VA_ARGS__); \ + } \ + unlikely(__ret_do_once); \ + }) #define get_random_once(buf, nbytes) \ DO_ONCE(get_random_bytes, (buf), (nbytes)) #define get_random_once_wait(buf, nbytes) \ From patchwork Thu Apr 22 19:47:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tanner Love X-Patchwork-Id: 426742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BF74C433ED for ; Thu, 22 Apr 2021 19:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE5BD61437 for ; Thu, 22 Apr 2021 19:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238948AbhDVTsb (ORCPT ); Thu, 22 Apr 2021 15:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236058AbhDVTsa (ORCPT ); Thu, 22 Apr 2021 15:48:30 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B45A1C06174A for ; Thu, 22 Apr 2021 12:47:54 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id d19so11868973qkk.12 for ; Thu, 22 Apr 2021 12:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2bSX7Hj382/0LPpLMZUook4VTsK1GZOKkJm2uri9jg4=; b=fmCYbt81MnAWvDO2JzMHpnOjz/EcqjJtn+b1NoN6iMI/4nyjAh9cmoptQe4u1jpHG1 lD7X4giKGcDVSfemNlFlDIAW9x38gJhYTZv0SNHJz78cxnCUJsjNJuaX8pvo275t5YO5 TSHGsPkgcdyg4ym0AuPocP8JYubaGb98hXyBTnF+46ECrZ6P5TZ784TucMdf2qYbiRip jTO2o7XD5eE4+mJgpAkSKOGmY4gZrMdilefeS29dzRzPc0PNlSucqMTP1URb941oC43t YKwH90ANXX3jjFFAivJDA66Rb3FJDbJl+BeWmHVg8/Th8wGmVkKYzh7KXCuwExSpzstU v4aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2bSX7Hj382/0LPpLMZUook4VTsK1GZOKkJm2uri9jg4=; b=a5OHGxgHfB6pgUVxoi7kx8WW3utBsgfvk7v4zBs9HTplyXo3eGhW8ifHWiB39xyr59 NcwItIEw9n81NIYV4wnszbqEkP5ncDJcSIj9yaghRCnN9WcOo0uuGURljfVFbJ7/EO7M PjmWOUyQYAalXwPPZPT1uyZ4Urd327RyNmgyOzkgHVQyEWdOeEhE7lE9MqqCiYZfL9IH VlJ9diyxjASZB7hI72fGQroQmZcRlor6JeIFAcQI5POgerw1TxPSRQTgMF3Uih3fEsCi +XXVozWRw/DRJPISeHgQVAzqCUaIi6t6OOHqaLKgkB0BVKXZsqgESWSfyYB2jE9NJJ0M P/yQ== X-Gm-Message-State: AOAM533ESQNjb3A9josjbGdfAHBy3Ibs1zQLvEHnHk+JxcYVGMK8xgDj aW9zRXMYwqQx+eIfG603PFrg9b0u8IY= X-Google-Smtp-Source: ABdhPJxyHOKrNeTVJegmLvClxJx1pp8PUB6K/B903w8Na30YfvH7eGQczmydP2HgGv9p+rmUFGHV6A== X-Received: by 2002:a37:c44d:: with SMTP id h13mr408038qkm.414.1619120873746; Thu, 22 Apr 2021 12:47:53 -0700 (PDT) Received: from tannerlove.nyc.corp.google.com ([2620:0:1003:316:e069:ac66:9dd7:6f76]) by smtp.gmail.com with ESMTPSA id a4sm2821781qta.19.2021.04.22.12.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 12:47:53 -0700 (PDT) From: Tanner Love To: netdev@vger.kernel.org Cc: davem@davemloft.net, Tanner Love , Eric Dumazet , Mahesh Bandewar Subject: [PATCH net-next 2/3] once: replace uses of __section(".data.once") with DO_ONCE_LITE(_IF)? Date: Thu, 22 Apr 2021 15:47:37 -0400 Message-Id: <20210422194738.2175542-3-tannerlove.kernel@gmail.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210422194738.2175542-1-tannerlove.kernel@gmail.com> References: <20210422194738.2175542-1-tannerlove.kernel@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tanner Love DO_ONCE_LITE(_IF)? abstracts this "do once" functionality, presenting an opportunity for code reuse. This commit changes the behavior of xfs_printk_once, printk_once and printk_deferred_once. Before, these macros resulted in code ultimately evaluating to __print_once. Now, they ultimately evaluate to true. This is acceptable because none of the clients of these macros relies on the value. Signed-off-by: Tanner Love Acked-by: Eric Dumazet Acked-by: Mahesh Bandewar --- fs/xfs/xfs_message.h | 13 +++---------- include/asm-generic/bug.h | 37 +++++++------------------------------ include/linux/printk.h | 23 +++-------------------- kernel/trace/trace.h | 13 +++---------- 4 files changed, 16 insertions(+), 70 deletions(-) diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h index 3c392b1512ac..e587e8df6e73 100644 --- a/fs/xfs/xfs_message.h +++ b/fs/xfs/xfs_message.h @@ -2,6 +2,8 @@ #ifndef __XFS_MESSAGE_H #define __XFS_MESSAGE_H 1 +#include + struct xfs_mount; extern __printf(2, 3) @@ -41,16 +43,7 @@ do { \ } while (0) #define xfs_printk_once(func, dev, fmt, ...) \ -({ \ - static bool __section(".data.once") __print_once; \ - bool __ret_print_once = !__print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - func(dev, fmt, ##__VA_ARGS__); \ - } \ - unlikely(__ret_print_once); \ -}) + DO_ONCE_LITE(func, dev, fmt, ##__VA_ARGS__) #define xfs_emerg_ratelimited(dev, fmt, ...) \ xfs_printk_ratelimited(xfs_emerg, dev, fmt, ##__VA_ARGS__) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 76a10e0dca9f..c93adb63780e 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -4,6 +4,7 @@ #include #include +#include #define CUT_HERE "------------[ cut here ]------------\n" @@ -140,39 +141,15 @@ void __warn(const char *file, int line, void *caller, unsigned taint, }) #ifndef WARN_ON_ONCE -#define WARN_ON_ONCE(condition) ({ \ - static bool __section(".data.once") __warned; \ - int __ret_warn_once = !!(condition); \ - \ - if (unlikely(__ret_warn_once && !__warned)) { \ - __warned = true; \ - WARN_ON(1); \ - } \ - unlikely(__ret_warn_once); \ -}) +#define WARN_ON_ONCE(condition) \ + DO_ONCE_LITE_IF(condition, WARN_ON, 1) #endif -#define WARN_ONCE(condition, format...) ({ \ - static bool __section(".data.once") __warned; \ - int __ret_warn_once = !!(condition); \ - \ - if (unlikely(__ret_warn_once && !__warned)) { \ - __warned = true; \ - WARN(1, format); \ - } \ - unlikely(__ret_warn_once); \ -}) +#define WARN_ONCE(condition, format...) \ + DO_ONCE_LITE_IF(condition, WARN, 1, format) -#define WARN_TAINT_ONCE(condition, taint, format...) ({ \ - static bool __section(".data.once") __warned; \ - int __ret_warn_once = !!(condition); \ - \ - if (unlikely(__ret_warn_once && !__warned)) { \ - __warned = true; \ - WARN_TAINT(1, taint, format); \ - } \ - unlikely(__ret_warn_once); \ -}) +#define WARN_TAINT_ONCE(condition, taint, format...) \ + DO_ONCE_LITE_IF(condition, WARN_TAINT, 1, taint, format) #else /* !CONFIG_BUG */ #ifndef HAVE_ARCH_BUG diff --git a/include/linux/printk.h b/include/linux/printk.h index fe7eb2351610..f706be99f0b6 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -8,6 +8,7 @@ #include #include #include +#include extern const char linux_banner[]; extern const char linux_proc_banner[]; @@ -436,27 +437,9 @@ extern int kptr_restrict; #ifdef CONFIG_PRINTK #define printk_once(fmt, ...) \ -({ \ - static bool __section(".data.once") __print_once; \ - bool __ret_print_once = !__print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - printk(fmt, ##__VA_ARGS__); \ - } \ - unlikely(__ret_print_once); \ -}) + DO_ONCE_LITE(printk, fmt, ##__VA_ARGS__) #define printk_deferred_once(fmt, ...) \ -({ \ - static bool __section(".data.once") __print_once; \ - bool __ret_print_once = !__print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - printk_deferred(fmt, ##__VA_ARGS__); \ - } \ - unlikely(__ret_print_once); \ -}) + DO_ONCE_LITE(printk_deferred, fmt, ##__VA_ARGS__) #else #define printk_once(fmt, ...) \ no_printk(fmt, ##__VA_ARGS__) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index a6446c03cfbc..8c868e5b4525 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef CONFIG_FTRACE_SYSCALLS #include /* For NR_SYSCALLS */ @@ -98,16 +99,8 @@ enum trace_type { #include "trace_entries.h" /* Use this for memory failure errors */ -#define MEM_FAIL(condition, fmt, ...) ({ \ - static bool __section(".data.once") __warned; \ - int __ret_warn_once = !!(condition); \ - \ - if (unlikely(__ret_warn_once && !__warned)) { \ - __warned = true; \ - pr_err("ERROR: " fmt, ##__VA_ARGS__); \ - } \ - unlikely(__ret_warn_once); \ -}) +#define MEM_FAIL(condition, fmt, ...) \ + DO_ONCE_LITE_IF(condition, pr_err, "ERROR: " fmt, ##__VA_ARGS__) /* * syscalls are special, and need special handling, this is why From patchwork Thu Apr 22 19:47:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tanner Love X-Patchwork-Id: 426166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8C00C433B4 for ; Thu, 22 Apr 2021 19:47:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C7EC61450 for ; Thu, 22 Apr 2021 19:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239035AbhDVTsc (ORCPT ); Thu, 22 Apr 2021 15:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236058AbhDVTsb (ORCPT ); Thu, 22 Apr 2021 15:48:31 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EE6C06138E for ; Thu, 22 Apr 2021 12:47:56 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id gv2so13361846qvb.8 for ; Thu, 22 Apr 2021 12:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GUNg497FpZ8teQXdqiLqOVPoiukxMOOVSjbroCtlrzw=; b=RXJW2XuTjJdwhdR+WgkSZgJGdmWf5XFY7QeVgCLMy7qioFqhuUd9WLt2owjnwZpkH1 pvK6jN9jt2Cz0ckOx4hd1IIx6orBFtV4/2VF0HJjGeyrFapYt7be7NC3KX12/PccWBdZ 52THKsDlpNQd6RZTPP26pxN+kn2BgDALm4i14bSBM2nhujv6852js8nXzDcIMxqtlKUd 5Ds70qE+wOhhNwvPU0Cq7DA7ehynsarh+dkbbczVC4Ke2NLkK/vH45XThLyxjEFzOjH6 JXZpjJQuSqeSPCfAOLXdlVpXUhy1vhkctCa2zDMCtKyr5h+q8y7VzYBTu25HLXcX+ir0 x+Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GUNg497FpZ8teQXdqiLqOVPoiukxMOOVSjbroCtlrzw=; b=IRBDnDtF9CLLEIgvrwObbQQdeX9e+6dLCBehP4S0bFo3atuPlvCBPKcs3AsRcI0+oU MZL2WU8D8J83ZwtKNORFPTNf/E4v38t3vWgt6QinhOa9BEuUco33C09Asu7rDByaFcd/ EBvywwtzWWIii6fLbtG5Y0SigePbAT+j4Zt/BzA3h4o/t8ZupVTTOnIixDYgfGv9AnrB p23MWew2MWm2Srgokhgxd3Y+Mlor2WOiDAykTVMbxmhqdshFBnhdW0+iN3RVSW51ljxM 50tr6zJ2FMM5M7XT+Yd/29DspmRenCZ6KtV6/RZapH6fgQml0jDosG+vBO3UxnqwKvgy uYqQ== X-Gm-Message-State: AOAM530k+hfuCDLLAkFRpJBDHRv/nOFqWcDOmMRmukaG85i1QtqoLlPE F6lQG/qvxwP/B5zAYrKtb1EcwXRXKew= X-Google-Smtp-Source: ABdhPJzRYVFg/e1orm/wMfGEYZYUiwzz1NExHDQQ5xZeAH0e9Rhsj1vEex/cS6gGK9jc7a11FDCGmg== X-Received: by 2002:a05:6214:5ad:: with SMTP id by13mr345646qvb.15.1619120875535; Thu, 22 Apr 2021 12:47:55 -0700 (PDT) Received: from tannerlove.nyc.corp.google.com ([2620:0:1003:316:e069:ac66:9dd7:6f76]) by smtp.gmail.com with ESMTPSA id a4sm2821781qta.19.2021.04.22.12.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 12:47:55 -0700 (PDT) From: Tanner Love To: netdev@vger.kernel.org Cc: davem@davemloft.net, Tanner Love , Eric Dumazet , Mahesh Bandewar Subject: [PATCH net-next 3/3] net: update netdev_rx_csum_fault() print dump only once Date: Thu, 22 Apr 2021 15:47:38 -0400 Message-Id: <20210422194738.2175542-4-tannerlove.kernel@gmail.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210422194738.2175542-1-tannerlove.kernel@gmail.com> References: <20210422194738.2175542-1-tannerlove.kernel@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tanner Love Printing this stack dump multiple times does not provide additional useful information, and consumes time in the data path. Printing once is sufficient. Signed-off-by: Tanner Love Acked-by: Eric Dumazet Acked-by: Mahesh Bandewar --- net/core/dev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index d9bf63dbe4fd..26b82b5d8563 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -148,6 +148,7 @@ #include #include #include +#include #include "net-sysfs.h" @@ -3487,13 +3488,16 @@ EXPORT_SYMBOL(__skb_gso_segment); /* Take action when hardware reception checksum errors are detected. */ #ifdef CONFIG_BUG -void netdev_rx_csum_fault(struct net_device *dev, struct sk_buff *skb) +static void do_netdev_rx_csum_fault(struct net_device *dev, struct sk_buff *skb) { - if (net_ratelimit()) { pr_err("%s: hw csum failure\n", dev ? dev->name : ""); skb_dump(KERN_ERR, skb, true); dump_stack(); - } +} + +void netdev_rx_csum_fault(struct net_device *dev, struct sk_buff *skb) +{ + DO_ONCE_LITE(do_netdev_rx_csum_fault, dev, skb); } EXPORT_SYMBOL(netdev_rx_csum_fault); #endif