Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp171839rba; Tue, 26 Mar 2024 12:22:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3RUEUAff6Q1qBTC7v21ui1vrFwSQgXv8laj75gI/qWDHctneCXTcRuuNV1QAKCd7cJBDIdDUlK8JtVyxP/VrC3ILCB9QXEKXWb8fdxQ== X-Google-Smtp-Source: AGHT+IEcU7RUHucutbbOnYc9PHBoRgEflFbrUFdOu9G3x3jyW9RjXJVwK9kwp81oZpWMsj20Y8WC X-Received: by 2002:a05:6214:2a86:b0:691:3c21:2c11 with SMTP id jr6-20020a0562142a8600b006913c212c11mr17514908qvb.26.1711480927439; Tue, 26 Mar 2024 12:22:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711480927; cv=pass; d=google.com; s=arc-20160816; b=RfJJLix9qg9LYueQLWwKucpCuGI0yXNb6RsYtVlOKxsqyDtZHez8V7Y9eNYc0s2MNt /bUB/jrMeNbNALAmeNxf4mwtii1Ykwe1eezzS7ObDbiiPQ0o3gzPswX3ldFQ6jBDAYa4 2wUoLz04UVx0pxNVujfurkYnuQ1uaHVSOhAHn2mcwxgVUZLp4dwvIcxpZ340Ya9o4xRY dRLmyhej8C2ewiqseqysujSV8gK5Iusyv+wa6a1OwLw8a/I5/Je7TlJemJCOBjMVNhgX oVgaG3T1k7EWIxpdjHzSOlKX0Y8hTShmXBtVKsGv7/UvJ5kxoc8bmTTTO5wvy8lncZt5 nwfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WkRKV3yR6IEr4VIV4AmMyNoDfYPPGMrONmoxJb/nN94=; fh=JN7tMyF6zC6ERZ5PXsr4V7IKiYp4vRUwR5tQFwkRxbI=; b=J3si8jqJe5CvH4y2ohojldsdVqu5ou4FhjmjuDlMuYigksWBi+qP6Tld1gz1pk504t r+Sh99K2CdGyqurKHBquBFE/HBrGHWeCr093HvngYmNpZ3C3uiy7TrN6nqVTzq1RFVtZ +ENLZMN97cZ+fvRh82GAp/Gcp/F7aFr4nMsp+LXQNPbWwlICNYoAPE8DQWOggcespK7Y uvXsGJaeTQbvt3jbIZ+7psRnyMrX+OfaIyimHvQEWhbNzXqPG9UiAzYaMWEyq30bKtVv vEtblN8m+E0YDauHluTyRLdguJ9wdfzhAqu1cqpep25sTJqTGtTt5vMnLTCjO0SYlqSx 3xcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=wUcVvffb; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-5297-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fo11-20020ad45f0b000000b006915edf8591si10533180qvb.308.2024.03.26.12.22.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 12:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5297-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=wUcVvffb; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-5297-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 235251C652D9 for ; Tue, 26 Mar 2024 19:22:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9FFF13D277; Tue, 26 Mar 2024 19:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="wUcVvffb" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9701713CF8A; Tue, 26 Mar 2024 19:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711480901; cv=none; b=sSgd2asB9n649hdPJscM6te1nlYQWdUAunA8PgBgxIZUdvR9sBpjefwRsl48IMe020XmWwzo7ELPAROnCTeZJxX4BnqN9L7MogmbaMR+A12slJsiw4WKgkkvvs9Ts2mYLyI9lTNRhIEhM/+EehpgxDOWzj+8/E28SWkURyMg5g0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711480901; c=relaxed/simple; bh=uSs11ecjpgeDVqx2WavChqveazw3qSi8rFo6RbMu0Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uSAuM/tW0I4S1ZKxL07c2WwUHEbWUwUV+kbE84agsKhqHSMFRtkN5cwu6tkShbvxeng3ZJi7wzIXNwO96UdWMdCCDyUVvw1dYWLhZhq+ejjd4nKdcIRQaUwnLoJeerSOkhCy023ZfZCEoyh2+AO6JozhTrksS4D8+C5YzW62jA0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=wUcVvffb; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=WkRKV3yR6IEr4VIV4AmMyNoDfYPPGMrONmoxJb/nN94=; t=1711480899; x=1712690499; b=wUcVvffbFXFy5ahGZ9AP8yn4jiuM4cQQKLOIQ8v09fVjZA2 QDFwbhI125ZSxDXbHgGIj+1OvU/CAk9+FaWQ5tbef/143bBQhWUUkNI/joIP7qOIBdHvrB8nuVA+Q 1FAORe94g6I8UgM9oTVTzNOc3wFf+I+kQBMFq1Sbv2VMghtqepOa4AdNwbP7z+iYA2U2C3U2p6qAy BLAlPkBQGtqX/PgxZEOcT8t2Wd7HEIkld3J8nh2vOTMzc4Ccgm9iujzBJT5Sc5ZKIU/DqtwQBNPPo EvdvkYH1KRESP4eQIwlZ1RVDHa9Ur7HgrwqGFi7t5Gi13AN565RdhP1wlbjFGIZA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rpCMa-0000000FvLV-1XHM; Tue, 26 Mar 2024 20:21:36 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org Cc: linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Johannes Berg Subject: [RFC PATCH v2 2/4] net: dropreason: use new __print_sym() in tracing Date: Tue, 26 Mar 2024 20:15:57 +0100 Message-ID: <20240326202131.fcbc8a528439.I075de1ac698b47710b94c631afdfb328f07be961@changeid> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326192131.438648-6-johannes@sipsolutions.net> References: <20240326192131.438648-6-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg The __print_symbolic() could only ever print the core drop reasons, since that's the way the infrastructure works. Now that we have __print_sym() with all the advantages mentioned in that commit, convert to that and get all the drop reasons from all subsystems. As we already have a list of them, that's really easy. This is a little bit of .text (~100 bytes in my build) and saves a lot of .data (~17k). Signed-off-by: Johannes Berg --- include/net/dropreason.h | 5 +++++ include/trace/events/skb.h | 16 +++----------- net/core/skbuff.c | 43 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 56cb7be92244..c157070b5303 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -42,6 +42,11 @@ struct drop_reason_list { extern const struct drop_reason_list __rcu * drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM]; +#ifdef CONFIG_TRACEPOINTS +const char *drop_reason_lookup(unsigned long long value); +void drop_reason_show(struct seq_file *m); +#endif + void drop_reasons_register_subsys(enum skb_drop_reason_subsys subsys, const struct drop_reason_list *list); void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys); diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 07e0715628ec..8a1a63f9e796 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -8,15 +8,9 @@ #include #include #include +#include -#undef FN -#define FN(reason) TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason); -DEFINE_DROP_REASON(FN, FN) - -#undef FN -#undef FNe -#define FN(reason) { SKB_DROP_REASON_##reason, #reason }, -#define FNe(reason) { SKB_DROP_REASON_##reason, #reason } +TRACE_DEFINE_SYM_FNS(drop_reason, drop_reason_lookup, drop_reason_show); /* * Tracepoint for free an sk_buff: @@ -44,13 +38,9 @@ TRACE_EVENT(kfree_skb, TP_printk("skbaddr=%p protocol=%u location=%pS reason: %s", __entry->skbaddr, __entry->protocol, __entry->location, - __print_symbolic(__entry->reason, - DEFINE_DROP_REASON(FN, FNe))) + __print_sym(__entry->reason, drop_reason )) ); -#undef FN -#undef FNe - TRACE_EVENT(consume_skb, TP_PROTO(struct sk_buff *skb, void *location), diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b99127712e67..012b48da8810 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -147,6 +147,49 @@ drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = { }; EXPORT_SYMBOL(drop_reasons_by_subsys); +#ifdef CONFIG_TRACEPOINTS +const char *drop_reason_lookup(unsigned long long value) +{ + unsigned long long subsys_id = value >> SKB_DROP_REASON_SUBSYS_SHIFT; + u32 reason = value & ~SKB_DROP_REASON_SUBSYS_MASK; + const struct drop_reason_list *subsys; + + if (subsys_id >= SKB_DROP_REASON_SUBSYS_NUM) + return NULL; + + subsys = rcu_dereference(drop_reasons_by_subsys[subsys_id]); + if (!subsys) + return NULL; + if (reason >= subsys->n_reasons) + return NULL; + return subsys->reasons[reason]; +} + +void drop_reason_show(struct seq_file *m) +{ + u32 subsys_id; + + rcu_read_lock(); + for (subsys_id = 0; subsys_id < SKB_DROP_REASON_SUBSYS_NUM; subsys_id++) { + const struct drop_reason_list *subsys; + u32 i; + + subsys = rcu_dereference(drop_reasons_by_subsys[subsys_id]); + if (!subsys) + continue; + + for (i = 0; i < subsys->n_reasons; i++) { + if (!subsys->reasons[i]) + continue; + seq_printf(m, ", { %u, \"%s\" }", + (subsys_id << SKB_DROP_REASON_SUBSYS_SHIFT) | i, + subsys->reasons[i]); + } + } + rcu_read_unlock(); +} +#endif + /** * drop_reasons_register_subsys - register another drop reason subsystem * @subsys: the subsystem to register, must not be the core -- 2.44.0