wlan-ap-Telecominfraproject/feeds/qca-wifi-7/ipq53xx/patches-6.1/0655-net-wifi-add-ATH-memory-debug-support.patch
John Crispin 68cf54d9f7 qca-wifi-7: update to ath12.5.5
Signed-off-by: John Crispin <john@phrozen.org>
2025-02-27 12:45:52 +01:00

112 lines
3.3 KiB
Diff

From 01850a48b49bd55824ae1a404ea6684e47deb2f5 Mon Sep 17 00:00:00 2001
From: Hari Chandrakanthan <quic_haric@quicinc.com>
Date: Wed, 28 Aug 2024 15:37:14 +0530
Subject: [PATCH] net: wifi: add ATH memory debug support
Add support to bring up ATH memory debug infrastructure - ATHMEMDEBUG.
This debug infrastructure tracks memory allocation and deallocation
in a red-black tree for ATH subsystem (cfg80211, mac80211 and athXX).
This help to track memory consumption and memory leak at memory
allocating function level at run time. This also helps to debug out-of
-memory (OOM) issues.
The RX SKB, that are allocated in ATH driver will be later freed in
some other sub-system (outside - ATH, cfg80211 & mac80211) thus,
changes are required in skbuff.c to track these SKB free.
This support is disabled by default. The kernel config
CONFIG_ATHMEMDEBUG can enable this support.
Change-Id: Ib064fffff08662df0545be3e0af06be9cd3e1f49
Signed-off-by: Hari Chandrakanthan <quic_haric@quicinc.com>
Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
---
mm/oom_kill.c | 6 ++++++
net/Kconfig | 7 +++++++
net/core/Makefile | 2 ++
net/core/skbuff.c | 6 ++++++
4 files changed, 21 insertions(+)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1276e49b31b0..974e5976ee99 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -44,6 +44,9 @@
#include <linux/kthread.h>
#include <linux/init.h>
#include <linux/mmu_notifier.h>
+#ifdef CONFIG_ATHMEMDEBUG
+#include <linux/ath_memdebug.h>
+#endif
#include <asm/tlb.h>
#include "internal.h"
@@ -1061,6 +1064,9 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
*/
static void check_panic_on_oom(struct oom_control *oc)
{
+#ifdef CONFIG_ATHMEMDEBUG
+ ath_upate_oom_panic(1);
+#endif
if (likely(!sysctl_panic_on_oom))
return;
if (sysctl_panic_on_oom != 2) {
diff --git a/net/Kconfig b/net/Kconfig
index 992ab27b930b..709530eaa728 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -64,6 +64,13 @@ config NET_REDIRECT
config SKB_EXTENSIONS
bool
+config ATHMEMDEBUG
+ bool "ath memory debug support"
+ default n
+ help
+ This enables ath memory debug functionality.
+ If unsure, say N.
+
menu "Networking options"
source "net/packet/Kconfig"
diff --git a/net/core/Makefile b/net/core/Makefile
index 7f0b9fe8d50a..b4dbbd573d05 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -7,6 +7,8 @@ obj-y := sock.o request_sock.o skbuff.o datagram.o stream.o scm.o \
gen_stats.o gen_estimator.o net_namespace.o secure_seq.o \
flow_dissector.o
+obj-$(CONFIG_ATHMEMDEBUG) += ath_memdebug.o
+
obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
obj-y += dev.o dev_addr_lists.o dst.o netevent.o \
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index eeb3952fd496..8b66c9c746fc 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -80,6 +80,9 @@
#include <linux/capability.h>
#include <linux/user_namespace.h>
#include <linux/indirect_call_wrapper.h>
+#ifdef CONFIG_ATHMEMDEBUG
+#include <linux/ath_memdebug.h>
+#endif
#include "dev.h"
#include "sock_destructor.h"
@@ -1062,6 +1065,9 @@ void kfree_skbmem(struct sk_buff *skb)
{
struct sk_buff_fclones *fclones;
+#ifdef CONFIG_ATHMEMDEBUG
+ ath_update_free(skb);
+#endif
switch (skb->fclone) {
case SKB_FCLONE_UNAVAILABLE:
skbuff_debugobj_deactivate(skb);
--
2.34.1