From patchwork Fri Feb 21 13:52:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985539 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5CDC20B80A; Fri, 21 Feb 2025 13:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145940; cv=none; b=qCCRgLlaZ2dV1/wYZvyd6WvVJFxb4dm0rduT2qnf6P0WIqVZN494R/fmzx8aAWL9xJGJ8M6RANc0h3hIc/lm98VekfF8+wWHzIyvGf182UVXHeRyLXycBWP1NOt/F98+M3ndHyvvmrQDhZi/aPF6c5vyiv1Wdv9cZx8j4PjOnbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145940; c=relaxed/simple; bh=qd79kNXwt/HQTrzjcvKIpR/xJTo/G9eIk5zkjXwC4rk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dhX/H9PNS9SBGGWq7KRLcTnv2VVl+ISo8SeFOVfyJiEzZkVbQ+W+DbNHwVtVH30HOWiqxv31WljiigTOG92RA+X/U9KHzOafQuIYEGTwubKNeCppdMLZPx+POPT1lwQSOXincqVGZKaSUXgsHcHwgxDJUW7WwF7ZqsrXEgfp1Hw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-abbd96bef64so344811966b.3; Fri, 21 Feb 2025 05:52:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145937; x=1740750737; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AMQIzzUDLylhdt65XZnHbHj+QNMnnT9fm3s4NlvWkE4=; b=TGm+7ojobpL3Vrk7FUGsmiQQBAWfXK4sH47ZS5xrMhvrrjApPiASvjKIJ5KhHq2nF8 gZzIS1FPWbK8ybrEX9Lz6zwM/70b77jX/ll/vMLC9C9B4Z83X9m56G03STVRtoBnON8H KR9uwijoClL9uIfPdZWGX0M1NjFubOMt4vgkRcYFNtQFOflftAwyT/yk1JjbNMaa9J38 oB5IaB7qO/SHSkivdC4fNSfih4P9aBKlPa4VksGp/56iKcAKbzpC+CWoVQBmyFu5EliR o6tUMxY1Ge2Qpr/axqboWLXay665uZ8NaeWK+YtUrlOsc9aZT6SSMkhmVwAdqik4mY5s NB4w== X-Forwarded-Encrypted: i=1; AJvYcCUOAXs7RrXrE/bToug345/7AskZZqy6/S6RUvfCRmPuOKxLjwz3C8BTpdU1AFagU5RAo3kblnTav1U=@vger.kernel.org, AJvYcCVdd41KoZCVldLFfl7dmz/8cQa3YoucW+cBf4R1IZVm9Mz7fSnmgDVWpgvj+l8qGVtgpGJpDAkS0NHKtgGINwjv@vger.kernel.org, AJvYcCVwkwplMuKY5M4VAyeemVUcGuNoZzCSJbwoA7By9Rm7u1iwUHsSD0E7uyj9en1CYbhh+0nJJmWCBCB4q6fD@vger.kernel.org X-Gm-Message-State: AOJu0Yy5RVku4dXfDM69fIT6YvXTkHI44jgUHqYEsftM+B9ukxe7IdvA 00Oa2dXBm8G4oSXw561e0R/ItSMzrlHPGzeeoPIBbTN7b75h4cKsxwZ6Ig== X-Gm-Gg: ASbGnctTtuU20Aqi5ly0JXDvcMYRAI8Mz61LbXRuLjK6ENNHOO3UZBPi4cYZ6AAORlQ 4e3+q2uxsvqx6/xB2poosBpY2Hy9BngnLCSN6qPV7r3XY23Gm4nxiu335yuKkrTyJaILr/uNyL9 C7Egw0b/mL0fcabUF7/KC2MwCxXj5twVmIZi2X55Rj4VPvMgrDEeQD3x+d6qCdq9llv4TQuUoXb dZbMf+ogbBixpcCbmFItoPSuidreHtN10fJPCuK7J+6lkgH/t9197JAXCaT8biSv+r1oNT1Smuo fkPul9wSB9VSRw== X-Google-Smtp-Source: AGHT+IHug/ztUo0GwBXc3XkhycLt7jEmpZVXVlASuiFgB8erdIaD3w17ljV228j7iujwrfl/TlTW2w== X-Received: by 2002:a17:907:9814:b0:abb:b1a4:b0fe with SMTP id a640c23a62f3a-abc099cca23mr328795566b.1.1740145936580; Fri, 21 Feb 2025 05:52:16 -0800 (PST) Received: from localhost ([2a03:2880:30ff::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb7c76b0cfsm1203699766b.28.2025.02.21.05.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:15 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:06 -0800 Subject: [PATCH net-next 1/7] netconsole: prefix CPU_NR sysdata feature with SYSDATA_ Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-1-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2740; i=leitao@debian.org; h=from:subject:message-id; bh=qd79kNXwt/HQTrzjcvKIpR/xJTo/G9eIk5zkjXwC4rk=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUMmKrAKNkKqrRTLD/DEaZxsJynw0aSK2Nw5 pyuKs1kxA6JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bUs/D/kBp6+nezMAR/BNox0ur+m0Rk6CysSAPfH6/5CsNA7pHdNb+5PygsI1qLADPwoeMMO4gc1 0eQJ71wTUQpbdslkXsNjFV72e7c3njPPiTBT2r4SjbXgO7Gz1sV/xaXPBGkmb0bJBN4pxS7zTuJ RW1i+VnAe8E99scZaR8OS3wag6fjtCNL0domk8OFx087uRurL2YCKpluckA6HTWm2/5PwnumQS5 evhIAuSESXAR29DBJNPoCXkQ7iX3TmnlESmndUdvxuCgD8eh1eXhvTuWTXgxCD3TXTg+gEcmc/k Ap6xldjckb3aD2WLh1irRJOz2VoYB25b0fbICKNhw5max/SRYc1V/6LTkpB/vsHt9WCNUMfpGWe NhfyLI2nv4v7q7RlgbN0yDtCw34q7OQeETynbP8sU1O9Y9X/9W5Mk2DUHC+Dj5cWJIwc07tVFW5 a7u4FvmV3ORED5h1C6Y9cWQf7wMQtyZFZQEuLp3pySbv7p7Pp9yITY0n/l2BhKZq0hEoLec3sDO Mod+JxeFwd2Kj1zp3is/1iRt34BvkyyCw5mvSPmW4e3FfyZ6JdrZbm46KCWAIsqBMZd21aqX/+2 JnV/Q5UmGF5JECsWxaUeNa+dotVNfb8lcOVpQQZ0dLLN1qJ059LBNCCJIyxGvEibrIQhMCO0aqQ mdTnYKWSv8Vez5A== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Rename the CPU_NR enum value to SYSDATA_CPU_NR to establish a consistent naming convention for sysdata features. This change prepares for upcoming additions to the sysdata feature set by clearly grouping related features under the SYSDATA prefix. This change is purely cosmetic and does not modify any functionality. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index f77eddf221850fe2778cd479e49c91ad695aba3c..c086e2fe51f874812379e6f89c421d7d32980f91 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -103,7 +103,7 @@ struct netconsole_target_stats { */ enum sysdata_feature { /* Populate the CPU that sends the message */ - CPU_NR = BIT(0), + SYSDATA_CPU_NR = BIT(0), }; /** @@ -418,7 +418,7 @@ static ssize_t sysdata_cpu_nr_enabled_show(struct config_item *item, char *buf) bool cpu_nr_enabled; mutex_lock(&dynamic_netconsole_mutex); - cpu_nr_enabled = !!(nt->sysdata_fields & CPU_NR); + cpu_nr_enabled = !!(nt->sysdata_fields & SYSDATA_CPU_NR); mutex_unlock(&dynamic_netconsole_mutex); return sysfs_emit(buf, "%d\n", cpu_nr_enabled); @@ -699,7 +699,7 @@ static size_t count_extradata_entries(struct netconsole_target *nt) /* Userdata entries */ entries = list_count_nodes(&nt->userdata_group.cg_children); /* Plus sysdata entries */ - if (nt->sysdata_fields & CPU_NR) + if (nt->sysdata_fields & SYSDATA_CPU_NR) entries += 1; return entries; @@ -850,7 +850,7 @@ static ssize_t sysdata_cpu_nr_enabled_store(struct config_item *item, return ret; mutex_lock(&dynamic_netconsole_mutex); - curr = nt->sysdata_fields & CPU_NR; + curr = nt->sysdata_fields & SYSDATA_CPU_NR; if (cpu_nr_enabled == curr) /* no change requested */ goto unlock_ok; @@ -865,13 +865,13 @@ static ssize_t sysdata_cpu_nr_enabled_store(struct config_item *item, } if (cpu_nr_enabled) - nt->sysdata_fields |= CPU_NR; + nt->sysdata_fields |= SYSDATA_CPU_NR; else /* This is special because extradata_complete might have * remaining data from previous sysdata, and it needs to be * cleaned. */ - disable_sysdata_feature(nt, CPU_NR); + disable_sysdata_feature(nt, SYSDATA_CPU_NR); unlock_ok: ret = strnlen(buf, count); @@ -1130,7 +1130,7 @@ static int prepare_extradata(struct netconsole_target *nt) */ extradata_len = nt->userdata_length; - if (!(nt->sysdata_fields & CPU_NR)) + if (!(nt->sysdata_fields & SYSDATA_CPU_NR)) goto out; /* Append cpu=%d at extradata_complete after userdata str */ From patchwork Fri Feb 21 13:52:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985540 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B34E420A5DB; Fri, 21 Feb 2025 13:52:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145942; cv=none; b=ZueiESP3XGXdNpTsvW+pIvcX9EL7onld26ps+XZfSMBUJtHYt/JrzTLFnjV/qnlP+3G9acr9okDHa+MDiV0hVTxGE/Jswr+uGb8Xb7BCDOBeqAhEe3qPq3DiNOMYl9UaF3JN3u12eu4p4CfrYmZZBfuYqyRyqBCwT8vi9Tu7Jrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145942; c=relaxed/simple; bh=ouzsS6LEZy5R1+wbJDmnkKV4jTSjqxGnKLnsqYxr+B4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MavQnnuc0ZmgvaSUIhFp1YVKzuzpCGxiANaP60axUNLQW1c/bNYeR4O6+ZPKfhu5TQTSjOHLxoavJNqVowsnua1FyoA7fhUW5/DeaqYE49RqsIIsjrAsHpxyVGqQ9B9KyfJ0xLc9GAsYrQ+/ua68hIvy4tsKas4yJZnJMcEJ6xQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-abbdc4a0b5aso401467266b.0; Fri, 21 Feb 2025 05:52:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145939; x=1740750739; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h2zfb+4gI7tn7/YbAaJLOzfVab5hlUbmHbxbNlQhJLU=; b=Wa8jcywGoMXXr0q02nfF4XvO1nh5AMx01rL7pPr22uLkVn6g3Ti42NETqJKtOUT48b 9RV9XwbIHcIqobq5I5MeANA6E92PkFvUwurdhZI7SIes+v930RpFjAXDhB7l4stXMp1a LAAzq22xoYgMoQv2joWnRmqnCLV6lU/k9JT3I+yG5Csnokz6k3Kzpe74G5Ev+jsX8eWg n3c42cSaOe+oswvSRRmq2RhH76gcH5Z60jdB+FwegT3s02LlJnPF0Suw216zec3tKu6Y iGUIK38J4MdKXveJwbmdBOASMDSJqmx3RMsEuYoFv74M2IittF1knHZlDCZuYVYx95Dt 9jlQ== X-Forwarded-Encrypted: i=1; AJvYcCUndSsLiQJDyIm76gCcSOY3aRPD3ZU9IcusV/Nvz7nkh4oUxZr9usOuEvmJ2MVCic1zjhJfzw9jIyzFQIQlbvKs@vger.kernel.org, AJvYcCVcCyFCsaSkBl1mwKDY+FFtkDQF6dtEsshqRRwrikz/z0yl9Awsnz1wqIqSeu1StmrrYGqB7sPqpfs=@vger.kernel.org, AJvYcCXBe+JA49rKJzXBq8GE2EBBkVzg+jvJ6QdTzzBUr7Ffua4M7ACypoXZaof5zLt/0gbhCQ19m5ShclgpgRyo@vger.kernel.org X-Gm-Message-State: AOJu0Yx/mdYoMhoZTohryf88VJJq6Npm4xaqEyi9ATAiOa1o+y0NGuFq Ad113FZEBpDEDY1TU1+kyaBDYIXoEfVMOKdsioGFOFBgkm89Rwu2JujUqQ== X-Gm-Gg: ASbGnctvLv75+NXDgxynJQuo3ok9Mf2k2+s1RYxI2/6nby/bfyoWfF++FqZFCYKmvf+ WaitCfvUuozGKIcbK81XWzHhjaHUYVKpdtqK36U9Xp4YsHyVWpVhnToWQCEmkv7xGO8Vj5tI/1k V62vHKTfQ24n55dOIRsaH5JpXueyatiiGklmlwElRurY9BsXoydT7Is6iAlFN/kyLuaMNc9v5PG QKPEYjrwaeterhIGGX+wOkiqADihyvR/GMbluH28MejFOPZm9OTxPNslZzOq9NQs8eCm5M2ZI4G rvnXHgFPDqFOgABv8A== X-Google-Smtp-Source: AGHT+IGMUCJOPm0mkufH1pHQ6A4LkbIgOHvnbQOpIFyEPIcdewG3uisCTkveNRpP4uPuHRSN3hkcgg== X-Received: by 2002:a17:906:308c:b0:ab3:9aba:ce7d with SMTP id a640c23a62f3a-abc0ae1ab4cmr259483566b.1.1740145938327; Fri, 21 Feb 2025 05:52:18 -0800 (PST) Received: from localhost ([2a03:2880:30ff:40::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb9e44b7fasm934937266b.120.2025.02.21.05.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:17 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:07 -0800 Subject: [PATCH net-next 2/7] netconsole: refactor CPU number formatting into separate function Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-2-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2265; i=leitao@debian.org; h=from:subject:message-id; bh=ouzsS6LEZy5R1+wbJDmnkKV4jTSjqxGnKLnsqYxr+B4=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUMOSMCwnRQu+wfrEnqGdzKJblDAs5/gtCvK dZgc/jPS96JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bdz1D/9W1LCNzsx6Hrt4u39U2I1T6Wwn2YlH1by7/phhojTF4sicrQAthnWxApREcKFD16MA0UK SdsdsnVV1i7w3mwTVa2YqWms9PTeypySJCpwDNOqVoYO4TgigjYYD82KOLZbSUoYh3YktHHAE21 0NXssSAgqu2oDXElJ1spRMCei/iPEk5ywsVxJf3oFd78wDv/uN38S/KprHexJswrWFf5DFJJQRW Lsemz2g+g4aUxMpB0dlHoTjEuQ8Bc6Tm6ybyiLRRebplN4yAXr2ersS6W53ivKfd5MvaiHhymsQ pr1n7K2eP/ki7281GnxAfpaRaq7uTrtq9YEh4N9KPmJXTLd2pULNiwZIVBK86JBBkkDnzP19yeN SXgdQbvHD2ehUad8XfAlbk1SegMACKnw4ocUcMzelYHotkX544cZO3yE01EJgLxECegQuIibETN +bG18In96Wkw99pKXgm2k5za8XHp7PCMPa+0Eg8BDg51hwMr9U4tAEO3TxYhdKFe6ErEFN3X9v9 ND3WDxVZQwJq17op6RnSxaNLp4JjmWUi8JPm68KOaSUf/Tuvm82f4jin7JjYSK4AZrxV1swiQyy vZFBOOjKqJ5WuwyPxcCAZp0SJHgsxQapX77ZZhYXjo7p+0o24NijEGQiXzHlTAPKhbH3ot47cox 6nJaBfYXHz0s3jA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Extract CPU number formatting logic from prepare_extradata() into a new append_cpu_nr() function. This refactoring improves code organization by isolating CPU number formatting into its own function while reducing the complexity of prepare_extradata(). The change prepares the codebase for the upcoming taskname feature by establishing a consistent pattern for handling sysdata features. The CPU number formatting logic itself remains unchanged; only its location has moved to improve maintainability. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index c086e2fe51f874812379e6f89c421d7d32980f91..26ff2ed4de16bce58e9eeaf8b5b362dfaafaca0a 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1117,13 +1117,21 @@ static void populate_configfs_item(struct netconsole_target *nt, init_target_config_group(nt, target_name); } +static int append_cpu_nr(struct netconsole_target *nt, int offset) +{ + /* Append cpu=%d at extradata_complete after userdata str */ + return scnprintf(&nt->extradata_complete[offset], + MAX_EXTRADATA_ENTRY_LEN, " cpu=%u\n", + raw_smp_processor_id()); +} + /* * prepare_extradata - append sysdata at extradata_complete in runtime * @nt: target to send message to */ static int prepare_extradata(struct netconsole_target *nt) { - int sysdata_len, extradata_len; + int extradata_len; /* userdata was appended when configfs write helper was called * by update_userdata(). @@ -1133,12 +1141,8 @@ static int prepare_extradata(struct netconsole_target *nt) if (!(nt->sysdata_fields & SYSDATA_CPU_NR)) goto out; - /* Append cpu=%d at extradata_complete after userdata str */ - sysdata_len = scnprintf(&nt->extradata_complete[nt->userdata_length], - MAX_EXTRADATA_ENTRY_LEN, " cpu=%u\n", - raw_smp_processor_id()); - - extradata_len += sysdata_len; + if (nt->sysdata_fields & SYSDATA_CPU_NR) + extradata_len += append_cpu_nr(nt, nt->userdata_length); WARN_ON_ONCE(extradata_len > MAX_EXTRADATA_ENTRY_LEN * MAX_EXTRADATA_ITEMS); From patchwork Fri Feb 21 13:52:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985541 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEA1220F092; Fri, 21 Feb 2025 13:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145943; cv=none; b=P+9imntsrcZxx0H/d5Qkmf8tX8QvD/AzU3T4D35ogRXEhjkfwVSimCG9Xza2N6cYbWktPlX7dBa4tO0AC/s84swM94+J06WFpEMzdcWl3TF8BpkuL/ZHPTHjklC2dONnr8g1+Wq8AKKL7wGzhJ3A2jLmNq8Kn7bp3TTTsFyFdqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145943; c=relaxed/simple; bh=u5ltNMXLomd/VKoMx0k0X7Td/0jnNXUeCNEZOwKvmD8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EmWVehJp7+UnkJu5FvUpvEdreNzaRrTLgmnVXbrDNltHWob7HRA9LhZUK1/cm/bGRLQd5fwgAOyk6VoVBmDN4gD6oMOdFRq7xSOcP/0/AauhduzuRk/QT8z9Kds4eFk9Fdza30YlHgWjbTdtoJasFTrnqM06t5WpOcUC0BySgrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5dee1626093so5935284a12.1; Fri, 21 Feb 2025 05:52:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145940; x=1740750740; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q4/MpsTJO29ajEchL8wNN+rTvfyOSL6kg7YIOeeMVYo=; b=GLCWz6bYo4YPi4JskdOAY44sZrHZy258b7sOF4ndCDbE40GugZQsmLR3sNlqaSB7gV EBkS44mNy+GdZD3HQD6FiR7/0xF9oscQw7ePMUTySdU/LwHT/4rIG81lwZiRP786H6w0 ityrDK/0X2ECna8qX+CcaP9vvDrhYGchI2UX9AZyttPlGdvV5Ue+zetdsASSp+rsj640 m/a1rBTq92hYkjobXktvFtyNxEUFTlA0x3bQic3j7wNZi13Cd7lxggubf5i3lmNQ1UIK OD/c813F8BJU63WBgKzNaKBHqJR7yMQDnw6fa6gLqGnFZxKD4umQ3Q14Ffua2meTuUXT Q4Mg== X-Forwarded-Encrypted: i=1; AJvYcCVqBgpunv4iZlsiZuN3z48oc6nLJTbzxj4QTLi2rcBiXAAJjDLAyZBJSNM+ycS/B59Yx6dcoV9FxhY=@vger.kernel.org, AJvYcCW5wI8GEll5a6cHxMADLbnqXnMqNIVz28iAYzn7zfsjefTb9U7INJ6j216CjZpUZvPM2hL8YIEtbuKaz20xPzZZ@vger.kernel.org, AJvYcCXtBvstjtOqxrfFTQJ322CPfL/1oUGKZKObBA6ddf3N4C4iQ2X3MHwQA7RPMb1tsg+vp0n+FxY6wKuUqJTT@vger.kernel.org X-Gm-Message-State: AOJu0Yw9dIoHjoZ/RK355d3GvI7UVujiLJP+6lFzWaLsD5HcfHqWR8JM wX85AObE4GLZ3AKOvz0y0P/aBvfpSE9CcnzguwIi+imP+SQ5GFLlZXf9yg== X-Gm-Gg: ASbGncsM6wGVtcmnjtX8QgS9+xJWKW3IkSatfVTkw9TMm5GAqxIV4M8KtG8GsDUF2uO ShIQ67NHWKCEl1kvVsirskTQ0ZG4JL42egSoSjkwRV6dA50NIJq+RfKW5d9Hgx9uxVWt30JcGz0 Dtjq2tmkFrzMgKStl1VgYJNla7ZJcQQFpySr/gvf43AZhy1wAZXYwFckMJ3RDqw93+YV0P7hFZT PRT7/DY2sPiu9KH4UNAGi2DKTuS+imucfusHZcFWj42AlOuagADVMljMLwRNdy9BbRgtvl9oA8O 7KbT2u9YmPQOibvl X-Google-Smtp-Source: AGHT+IGidcbdqjOzKFbsbBTB7aHNtjKSCxzH9uMEGKbJStgH8B9nmnwmj6QrA/l+Ba5YhDC31pZsdw== X-Received: by 2002:a17:907:d109:b0:ab3:3b92:8ca5 with SMTP id a640c23a62f3a-abbeddc5984mr741431066b.12.1740145939892; Fri, 21 Feb 2025 05:52:19 -0800 (PST) Received: from localhost ([2a03:2880:30ff:6::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abbdac1015dsm496385066b.127.2025.02.21.05.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:19 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:08 -0800 Subject: [PATCH net-next 3/7] netconsole: add taskname to extradata entry count Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-3-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1191; i=leitao@debian.org; h=from:subject:message-id; bh=u5ltNMXLomd/VKoMx0k0X7Td/0jnNXUeCNEZOwKvmD8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUMae+lYoGodNvYOK9LVnzJ8VBKd/7S8vY/i iyyJmLAXBOJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bYyXEACH5A1C0xX3mV/h0UVgeJoWPBdPDdPY79hfEvBBrxjw0xhrs6Fw6dHmuRHzywnIkoE6XqS w7+Z8AbsZwIA5eLjaT703dOlB6V1hfvfV/GdB8VhETqO6HTDUVhYGiPE0CBrWwFzLoszwrvCVME ULj4KdNp4o6HwD9Yr4UOKkTm1GlE+veBm4qjaAbosoCdNg1ZTs0rt/W7f1kz8Drt1zD+cF0HjZq SlB2rgEKtZ6VdQd1HgeolSHbiXTg1LXKbl99Tebq5WGh73PlHmoKHWnfSrRNDevJNJbyRLyoCLu Ix2aTp8Fo1eAhd/oGR7PEnbQEZF/tmRIcfX/JYI7Hvaul+iVDb8nphmgL5qO2Mxd7tlfBRf3VhT AQxsxe15HGRpKplXhIZ71boWxW0p4FOYwG+lw77rhq+7r/4rLc/eb/jFD3IXCpMIrgsYHuci/hn 4KiYJ78ID11irsDD/SZK7qaH2EUw6NHIRn0SxCMTcsVzT6o0SCoKVlxAUpurQFH5/K1lkkwFXro pVOvDOMP5iicM8CQiNMuIZ8XqXTv+NDFq+30DjothkHM8vPQkSgN3LgqVlxZ4TJgVUWzIifv02M hMFKkbMFmWtzGxOOj9SFY0loIJTiOyBWSJ9aW/b2YtheCq8NQMOJWVlW1Y1P39+nHkko15aL83x yf/mPGaKYH73tWw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D New SYSDATA_TASKNAME feature flag to track when taskname append is enabled. Additional check in count_extradata_entries() to include taskname in total, counting it as an entry in extradata. This function is used to check if we are not overflowing the number of extradata items. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 26ff2ed4de16bce58e9eeaf8b5b362dfaafaca0a..1b109f46512ffb7628c6b34c6efdfc301376dd53 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -104,6 +104,8 @@ struct netconsole_target_stats { enum sysdata_feature { /* Populate the CPU that sends the message */ SYSDATA_CPU_NR = BIT(0), + /* Populate the task name (as in current->comm) in sysdata */ + SYSDATA_TASKNAME = BIT(1), }; /** @@ -701,6 +703,8 @@ static size_t count_extradata_entries(struct netconsole_target *nt) /* Plus sysdata entries */ if (nt->sysdata_fields & SYSDATA_CPU_NR) entries += 1; + if (nt->sysdata_fields & SYSDATA_TASKNAME) + entries += 1; return entries; } From patchwork Fri Feb 21 13:52:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985542 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E591A2101AF; Fri, 21 Feb 2025 13:52:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145945; cv=none; b=CeYs04V/QIj8RnEm2dCa7nAD2cA8Iux1+fEMgk9jYETA1wJ0Pni3sAMDF8zuM4zNAJBO/Lf0h8py7RzmQneL76fur06iyA5m9Eclf6tWGl5Er5qrmpphOcUr76+5RueUdY/lLWJ1n7E/8Jz0D5TN9wAc1qj9mvfTt5pcl+Qf7U8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145945; c=relaxed/simple; bh=IU6qyy1iFpjo663fbxCoKchOukk6qnpwGi0c7ZPjG10=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mX5n6QA1AuOMXkEyag7/+KibtRk/AKlFtDrVJiUxDTgiBt4+qfWwuBu+zNLpTz06bADqWrn/X8n9Fyd2P+dNxQs3YXNcjxJECoTI02sYmF/RnTEt41mh9phSbCbDnhaFvIMs/bh6Wc/syn52HUY16k6uDjdkHh7/On8bHhX8448= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-aaeec07b705so339278166b.2; Fri, 21 Feb 2025 05:52:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145942; x=1740750742; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uoqUgw8CK5il/VCYnynrUwMUzbSS7YtelAZ9JMzXTRU=; b=iO8m20UYkJPqvXTKViUAI4tZfGTqqZUHiTiACCpM2GW3cHGyjMwLKW6tpj0oeZramM WBSZA35/VBa9eGQrKOKa8l3OJkNGJ7vitiUd+zZ4D19DzK0mvcNyr1arlxoVxCR4f0mk meVqLyL9n5rajZayA5sGxvzsDc/JdnJLYQyB3CQNXtaPVjVNDiAAyCqW8t1Tax8tLrEn n4TJxkpp/J3HjY1h+UN4oJA0nQN64gg22KuaYvDeVS28Ce1L1ORomBjllKccLRcrYSVp ps8sBp8VeGngxZpQPEP1rVNtovtFPmP63GLlTWIDeWXCL1dFISUV79hm597lMzAOkNDo NFHQ== X-Forwarded-Encrypted: i=1; AJvYcCUAXtJ/bf4z2Tn7p0TqWWYIIF+z3CEF8M7L/DSFbw9siN+fIsfTqTr/ykPsWRg/7XrGhidKlLhsWm6IAhBO@vger.kernel.org, AJvYcCWEMaYZt11uAh2WqcetBxK6SHRlF0scDr1uhLKBLIGD1xA7+fHiOaozuBYxiEpKHnqmzTjgeXs6e3NK8qGrryEa@vger.kernel.org, AJvYcCWVuTIh/GtpTCut1GAj3OhJhzB/TzkypPtt7KLYfcwhuYTjCwFitL0sn/vVBUQegvf1wKoUKaQx+rQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5xKPqyua1rdCdYo0d2LvbTj1uvk1iTd1HHa724vCXcFk4ezs7 X1C4JQq3z03etRSVTAH/suvYK6P/VdSeHAmqpPc2LRvSMmqAaZxWeboR4g== X-Gm-Gg: ASbGncuE1DUyhPf+CvBSeEtRJdByPo7dlj43yv1cu23+yyvy2j4IxJ4q2Sdl491i+NL fpEIqwEck1So7g02YIfFgqMKG5HTne7zUR8/K4z79hgpuRq2pVAuafqdAXaJg1D2/q4vkBb7OuZ 8DlDu2228txic019+kb28CIVayryBnLx34BCt01qBvNs6/dAMUeILPAnp4nLPhEo81xshItNP4+ 3VPTfEbfzTQ4I658ZSZwP4UbvL8HXyCoQidwxiT4kq59D7ukxCV7tRLSPDm6H4E3z019TeqOhBX FQ8mqEfY4bKRb2TrSg== X-Google-Smtp-Source: AGHT+IHWeHLxvWH0kTgEzlyoV8ZqeDKqrz0soE2mxMN3ulJz83Gmo7xlHHsJjZzpKM+q7tGjTYz0iQ== X-Received: by 2002:a17:907:d8f:b0:abb:e961:ca32 with SMTP id a640c23a62f3a-abc0d9dae22mr295273666b.21.1740145941530; Fri, 21 Feb 2025 05:52:21 -0800 (PST) Received: from localhost ([2a03:2880:30ff:41::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abba577d6d6sm885539366b.136.2025.02.21.05.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:20 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:09 -0800 Subject: [PATCH net-next 4/7] netconsole: add configfs controls for taskname sysdata feature Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-4-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3183; i=leitao@debian.org; h=from:subject:message-id; bh=IU6qyy1iFpjo663fbxCoKchOukk6qnpwGi0c7ZPjG10=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUMuJnGxWYBi44JmUbllgqr0bFIXZaygKw9A I3OFMmxoX2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bTqvEACcB7Q089Txgfw4pMpIrGgsDLZzhBuVhIsZInSBClWUhG9TfI7MybMop4nUlSqy7VsOQY1 Fq/QUomj1N4iWknvPetjZkoPgGpsavvpwihlPKUSSulhhO6QKIE9ro4fWMXSAT37vE5jy9uYFEq a1c6oyGWbNLrKQbcpi2ALLuKqc+YabLq797Kue6n9WfdcVbgZTP3+b4QoFcTdEEpL9h9nylDhnQ csE6yBuQs6p5EnvC9KGvl9NyRs+2h+Md8nehmnPNbjN3R3q40Qri79iiC0VoUJUuKYoHiP48uZd COEC0Sp/CS0vqwCBNJOpRCV/Amk9oaGpUSwZXIzYtFtio1ODjjtyUQ55u60oAOeRruxJacOQRDH yvFzTbwnTtMYwZN92zrAGRnzWd66ALREOVr9o3V+IOf8Z7OmyXaYteSPxeeoy6t9UdrJ2QbgaVl 2zEr51kcEKz0Eu8S31jsYFIrJ8vJY3q3kxLf/tb+EgBNpJUVKXy08gjN3fU1sxPN0j6xv6Tn/tz WeRBhT1jBPeSdITFlDksIxuZhH2uBmvYc2jhHOFLLhlPB3uwWibf255F+G0v4S2X2rn8eOtS0gd GaukkVVhUQtJ5a1/rlrGmaMW2Td3cwGizLDEwxqsnkfS4iy8iJDIuZ7EHS347wUdGn+cFEfwq8R 8su059qNa043okQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add configfs interface to enable/disable the taskname sysdata feature. This adds the following functionality: The implementation follows the same pattern as the existing CPU number feature, ensuring consistent behavior and error handling across sysdata features. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 1b109f46512ffb7628c6b34c6efdfc301376dd53..5a29144ae37ee7b487b1a252b0f2ce8574f9cefa 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -426,6 +426,20 @@ static ssize_t sysdata_cpu_nr_enabled_show(struct config_item *item, char *buf) return sysfs_emit(buf, "%d\n", cpu_nr_enabled); } +/* configfs helper to display if taskname sysdata feature is enabled */ +static ssize_t sysdata_taskname_enabled_show(struct config_item *item, + char *buf) +{ + struct netconsole_target *nt = to_target(item->ci_parent); + bool taskname_enabled; + + mutex_lock(&dynamic_netconsole_mutex); + taskname_enabled = !!(nt->sysdata_fields & SYSDATA_TASKNAME); + mutex_unlock(&dynamic_netconsole_mutex); + + return sysfs_emit(buf, "%d\n", taskname_enabled); +} + /* * This one is special -- targets created through the configfs interface * are not enabled (and the corresponding netpoll activated) by default. @@ -841,6 +855,40 @@ static void disable_sysdata_feature(struct netconsole_target *nt, nt->extradata_complete[nt->userdata_length] = 0; } +static ssize_t sysdata_taskname_enabled_store(struct config_item *item, + const char *buf, size_t count) +{ + struct netconsole_target *nt = to_target(item->ci_parent); + bool taskname_enabled, curr; + ssize_t ret; + + ret = kstrtobool(buf, &taskname_enabled); + if (ret) + return ret; + + mutex_lock(&dynamic_netconsole_mutex); + curr = nt->sysdata_fields & SYSDATA_TASKNAME; + if (taskname_enabled == curr) + goto unlock_ok; + + if (taskname_enabled && + count_extradata_entries(nt) >= MAX_EXTRADATA_ITEMS) { + ret = -ENOSPC; + goto unlock; + } + + if (taskname_enabled) + nt->sysdata_fields |= SYSDATA_TASKNAME; + else + disable_sysdata_feature(nt, SYSDATA_TASKNAME); + +unlock_ok: + ret = strnlen(buf, count); +unlock: + mutex_unlock(&dynamic_netconsole_mutex); + return ret; +} + /* configfs helper to sysdata cpu_nr feature */ static ssize_t sysdata_cpu_nr_enabled_store(struct config_item *item, const char *buf, size_t count) @@ -886,6 +934,7 @@ static ssize_t sysdata_cpu_nr_enabled_store(struct config_item *item, CONFIGFS_ATTR(userdatum_, value); CONFIGFS_ATTR(sysdata_, cpu_nr_enabled); +CONFIGFS_ATTR(sysdata_, taskname_enabled); static struct configfs_attribute *userdatum_attrs[] = { &userdatum_attr_value, @@ -946,6 +995,7 @@ static void userdatum_drop(struct config_group *group, struct config_item *item) static struct configfs_attribute *userdata_attrs[] = { &sysdata_attr_cpu_nr_enabled, + &sysdata_attr_taskname_enabled, NULL, }; From patchwork Fri Feb 21 13:52:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985543 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D23720E027; Fri, 21 Feb 2025 13:52:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145947; cv=none; b=YU4wKNeLno4l1wNU6WVSsxLnSaWHzfV6ouMU1BcE5buY+D7sxLELjt2vg7afV/xqBUAsYLgIttUbw8+RSYEkgqbWdM9JF7Vs+s2QxN9uKYDxdkctVstK/dGdX3kW0fKgME3640pRXl57W+XJh89kFn4ktx2kjyLMfX4olvSqLDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145947; c=relaxed/simple; bh=4d5F9hw/MC11IojS+Ua6223OipgO2ANKHuJKGY8jDf8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AAaRyaeiswBpvO4OLfDn1WY6hrG0NYrlozIdFykpUcEFs2/aYuWkMItCb7Tub04PSC97OE0atRW5qegL7qb5Uuu+LwOqjrqEaZP+zwbOjxO+veQjJ8O7K6V+WjEUXFtfyk1JUQAtEvjjGmXoBuNnXN3pJBfsczVb2gDq40FcG5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-abb90c20baeso285027166b.1; Fri, 21 Feb 2025 05:52:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145943; x=1740750743; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xFytzJ1XN5zmdiS1teTibU1DKqNU5XabnaEcWVaGmeE=; b=Tj0/fmItlnINIlZO8LrZkf+QqZZr90UijF6mNxiWtnV1n4npWq3ddN5P+94s866Guz hmFWL+aRqA3ck1C44lRj1Lajdbh23qTDoixbh7SO1pEZhZddodPkKMS0wx1iLEdqlGwR jzcgTnGRc4wi9QmYhofxy8Fmb/jRkbSobsNg7VuKz0TJVsxMCWq2UYzoH2TwGGuUQOQK 1phD9DLJzFTN2LGzCLzGoCgvlVZIEbFfhOwp3jYJHzWPCpS4hT9VXzg7FBZUK4o8oUtM ppZ8WfG0Ijtcb7hqjMcFKq+k4YO0y2xHzGZdaVN6+cN2ZdBmqpVA0A5QtcBxDmH+OI7j tG4A== X-Forwarded-Encrypted: i=1; AJvYcCU3TXZBqMQqnJ+Q7T9x+Ddld138tDf63HVXeYL6U0dGtRNcr1+dO5fXCz8wQm9RrH0OHLwlfnE61pvY/Na775Nq@vger.kernel.org, AJvYcCV6p6/HAf2q5v+RKnnxUczXgprrqz4UyW+k7eYkqMAX52ymTBJ34BX75xJOSZGptEJJLd0clR6ydGtG5Qln@vger.kernel.org, AJvYcCVAIj/aV+2VkwEi6Prf1m2duGHRjcRbyqiOLUn1Vdmi0sHOtJR/Gt2mGxWWKlHraJ6ga7mva9Z0JuA=@vger.kernel.org X-Gm-Message-State: AOJu0YwvSAZ/c1sgdM5ukkLI2tDExyIlemCZRBBrwsRWUPQYXUj0q02D 7IvwE2fch183sogRJy7kRiy4aIULewjbAJuZPxFGMUh4Yv7HVB2Orz14GQ== X-Gm-Gg: ASbGncvfasyEVTUQFBQWSJ8CERmAcTmFhy7PxdoCB3VFbEnFLN5BhvDr1GZ++U/uuzw JLGd8zcKU3g/9yo27BmVVD2XBHn/s6Oa0Qt4EWwUzYmb2DJ7tAEjUDHu4vfsfCGijknFgOOHsz0 VnPWSCr5SoFjKsrnrabbuRU1YaOYapjzqkSY9CyOwEjUYZtufy5FoSHYH3jvvesNgGGn9JnlMHm zx/OVGmVv9jeDCS4X+Vo+/8mtNFxjFWZn+nWaF4mmT3yNOM2tID7j0eMZ5vWt+VlmaaCJCaPXbA EXs5dulNiE0aaA== X-Google-Smtp-Source: AGHT+IGlZ7okfxBb+is8wq3VskHdM6A78aGWUaoh9njORHgf6Z++fXR2qZP4IE+QfuFrPzT/tYIK8w== X-Received: by 2002:a17:907:d22:b0:aba:a81c:f972 with SMTP id a640c23a62f3a-abc0d9d7a7cmr346617566b.17.1740145943153; Fri, 21 Feb 2025 05:52:23 -0800 (PST) Received: from localhost ([2a03:2880:30ff::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb9acb9acdsm987280066b.66.2025.02.21.05.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:22 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:10 -0800 Subject: [PATCH net-next 5/7] netconsole: add task name to extra data fields Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-5-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2177; i=leitao@debian.org; h=from:subject:message-id; bh=4d5F9hw/MC11IojS+Ua6223OipgO2ANKHuJKGY8jDf8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUMukz11k9tZaWs9ipUN4NpSO4HL4ODjAcwf 3fUG+ePofGJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bU2ED/9Uk1b+wXGhGwGDSjLAWhfFKNYzImdiGZD2b3DCSPjjA/d4+cD2jfP/SMKzW+eAnHJnZHU 43GfbfKm9JKQHSsKG9t1uuotgQ7GEbHBUcHRKaXiHqKmbpbaOn5idQ0kGHONF4pT+qQyLR4/N1o pylQc/NboJI/Q2mWl8rH8dBWGw7kJXmJJYIltUsVgiTs0/NwROZBBFJUPsynbMbgDMHU+cKPnS5 YK5Wni3zpfIlO3x+tsJMkuk0ErcqlMl2k1Hu5XjzOhwCaL379hFoJ0LAYqR9LT9cbzGsJoHFkoS Dk4S78uw9m+a14i/6usP7TGUDELShTnrFygmO8WDBp3BqFSiFX+NT6EHw/Ic1uZHflOtW9mu3Yl Tu6qvGeMYMV9hz41haLD+03BqPYy8TXI4hYbBLSocEeR2GCF4q0M1XqPvjO15HsVWTuvbhGhSQC NCfGuuPsFb846CXw/0Fp+A6hD20oTwYPRlGkLohpXeVvuPGl5DMIkKtnf2qjic8mh21Qp720Lh2 tpGXaL+zaA99nyZgEHwaLVK6E9ZdHpRWpxNN9/Q2klSbKvXShtR+GDAtjsLyQSWJqmHGKUAfxVC Vunea6tAS/b4I9fmiAWQQcm1Dz/8SqMnxFSIhI3YIQZV7ougQIqDn+RYSwZK65v6cQuJsnfOuGp SLqG4eWKWO5zjzA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D This is the core patch for this whole patchset. Add support for including the current task's name in netconsole's extra data output. This adds a new append_taskname() function that writes the task name (from current->comm) into the target's extradata buffer, similar to how CPU numbers are handled. The task name is included when the SYSDATA_TASKNAME field is set, appearing in the format "taskname=" in the output. This additional context can help with debugging by showing which task generated each console message. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 5a29144ae37ee7b487b1a252b0f2ce8574f9cefa..625f4c0be11d8deb454139b1c526abc842697219 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1179,12 +1179,22 @@ static int append_cpu_nr(struct netconsole_target *nt, int offset) raw_smp_processor_id()); } +static int append_taskname(struct netconsole_target *nt, int offset) +{ + if (WARN_ON_ONCE(!current)) + return 0; + + return scnprintf(&nt->extradata_complete[offset], + MAX_EXTRADATA_ENTRY_LEN, " taskname=%s\n", + current->comm); +} /* * prepare_extradata - append sysdata at extradata_complete in runtime * @nt: target to send message to */ static int prepare_extradata(struct netconsole_target *nt) { + u32 fields = SYSDATA_CPU_NR | SYSDATA_TASKNAME; int extradata_len; /* userdata was appended when configfs write helper was called @@ -1192,11 +1202,13 @@ static int prepare_extradata(struct netconsole_target *nt) */ extradata_len = nt->userdata_length; - if (!(nt->sysdata_fields & SYSDATA_CPU_NR)) + if (!(nt->sysdata_fields & fields)) goto out; if (nt->sysdata_fields & SYSDATA_CPU_NR) extradata_len += append_cpu_nr(nt, nt->userdata_length); + if (nt->sysdata_fields & SYSDATA_TASKNAME) + extradata_len += append_taskname(nt, extradata_len); WARN_ON_ONCE(extradata_len > MAX_EXTRADATA_ENTRY_LEN * MAX_EXTRADATA_ITEMS); From patchwork Fri Feb 21 13:52:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985544 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 099F021146E; Fri, 21 Feb 2025 13:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145948; cv=none; b=o5EC7t/7oS/COmtEoQ0CDdzV0vzl2+wtyhcgnwEfKigpmFiTKFgq4ljoCqn8wP9WVZ4oeJQ3euzcux7ircw1Ut1fNZ1NoaQsE9TX5mXyzCeVNYCDsWfOFfUFMUo9kJqLwzg3HSsR3i2Az9bfqdYrDLllPt3PZyg/UqoibKA1I18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145948; c=relaxed/simple; bh=Ob2n3Gjxes2mq/Ts8e3t4uuvkN8LtpNdlLQUukz3fEE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tAXpqDe0TeqjpL3jftQYQQr5Rn9r3I+3sF3ynlzpbSTazZUoOFn9tuZ1WSagnmlRvBvRnW39TU5cDorCuJnuHMqFnV8Ko/mj9co9orxIqcBJ7eKiaLoWWGx+wvl80te/MMAyCUcJ7cP1C/rxrElqSV8/r+VldPn4BoCb01FEcvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5dee07e51aaso4007161a12.3; Fri, 21 Feb 2025 05:52:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145945; x=1740750745; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OhLoXurUg9nsUH5I3z7BRsf0MsfxSUDScjQg851KMjo=; b=xTeLRVJBVmSKCYCtEKI3xzahuCUJu9exMUsjPNhMz200l+CHFK5TtbsXwJ+4lILFdI CK1OG3G4r/dTwak27uHLuhsJ4rN92UrRxiIJr8MPWgtqI63UeY20irud/bELETGlHnWy vkeecgKZyIS6d2rmJaLE7Vd/Gv/bcpXrtydPh0Fya0tifviXG08ch/VL84974Q/2AOyy DitEz0eDcLKWD8+AUuGykHz/BShk1x5vwKyNgk9AGZMY99+KBaSLt/PwgnGJ67bqpieU Y3+EpAaVhtq5bCstbug/p8Ol90XvwB5gvaBXTYlI5WZ/VEYf22RjzHidDssyEIiSoTos 3v+w== X-Forwarded-Encrypted: i=1; AJvYcCUsNLTbJF+/pSDd5veJVZQTJ+yZKKls9c/3yqmACiKyWvz3UVS76Nydiai3Awh7+xNjFjH865MfO3c=@vger.kernel.org, AJvYcCX6JNSX1++subzc9iAhxwYU1gBRyX4ESzsx2+J4qZjBVOj1SszkS+r58rJc96+/n2NvQdeS/p1/ihv85lCI@vger.kernel.org, AJvYcCX7W7d4gC9KXXTqmNLSjjJv1vrOKST3Y4llcmW5TR2uczu3ydi80cL0mbZHvOeiQFaniCb7E4lgzW/czr+2Rzgp@vger.kernel.org X-Gm-Message-State: AOJu0Yw8G6qq/pPpZPvSAsu0+0hyodVJ8/H6Uxsp8j2X0ckhznhu4YF4 aWtZOCl2dV29zPGdY52dHWSX1U/40fyw8qrQUTldURhhag1gmLMPbRWI5Q== X-Gm-Gg: ASbGncv8gIKhcT4gp1d0vQXGvKCGjZylSIjjdL16mwTQjVSJu+B3Ax3TZRVRBZwf+B0 vd48L8dgH3cpKC1c9TLEK3zdRTuXyXmX3GXbracLfJdjMODeLSBKYZFuQ5ther2CZTPctu6E/cI wooOXSN5LOC5W0t+Ax0WkhE3wT/rBGIXXt7tfiT8DnnORH0PQmmf3uUTHfxvQ/VHdI3R1OPd+1P 7dIMKZ+W9w08Yv6qXD3NfMzmNv1u+6lS9kZK3/4W3uksB8XKSemDqn3KGtownTtJYvTBf2ewpcy Bs01bZGNOQuTsm5h X-Google-Smtp-Source: AGHT+IGyyXHo3KUES95XHnDPWbIM/9t2Rcs2i4ef+6srCMDnYSmMw/LOm/ofPOs8TwXax2JPzTvJeA== X-Received: by 2002:a05:6402:430a:b0:5de:6bc2:7bb with SMTP id 4fb4d7f45d1cf-5e0b7103f28mr2936975a12.17.1740145944740; Fri, 21 Feb 2025 05:52:24 -0800 (PST) Received: from localhost ([2a03:2880:30ff:1::]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e09072247esm4257416a12.51.2025.02.21.05.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:24 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:11 -0800 Subject: [PATCH net-next 6/7] netconsole: docs: document the task name feature Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-6-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2198; i=leitao@debian.org; h=from:subject:message-id; bh=Ob2n3Gjxes2mq/Ts8e3t4uuvkN8LtpNdlLQUukz3fEE=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUM2R8RCAjq9vUavbVP3mpQxIAhAsHXr2Szg ayP0uMgaUmJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bRVJD/oCHdk1nUcH7d6syKrxakso9UyrwJtwZUnnyKRcgzirBpgLO/ZtLlwD0c88LinpUW2TdYw bDGuNP7mmAFrgKKJuP0LHNkG231wgf/GJh+vttzPfSiiYRAhlcg1PX9g5sepZZHYcAlEc+xpBJu 24W5iusSAbN2K8kdEa9EUuPiYn7ywNCA+uQOLCAvp6DUw/eM0JrF3pS9Ao10bbP8WltjxxwtaQR P/7KtLMlvUHW63wIa72faiDVti4S+2gS9rZSB+AJq8OQkht5pUSTy2mtGnEKAB4nJRbdgjI5iOm JEMuDBwYQBbTcWaAjgz2bNjMJWyFKnDwPBL4u+Sm9T0YhP4NIim8QI9d3jaUh+6e5J1nxNzO/Wp Oeqk1O/FNRdnzjqa55L9NbgCHQRloYD4jQ7V+PkA31TkGDON6lAdXH0v2EE48c6M/0u3GXT4Z0H PaVtGBsGpKZkdlthE7aQaUvbpwy8+8PNEifm4Svd7uxjGS4c1A/cLmLIYltQW2b4dFB+DqaQQQr 9ID3JlCXdSeM/XzN1Xh3v3KqmJxbH9WvBO09ldLE4NPY/c/4PQwLzldGJPABXzlaBC8v4T5pf6f U//UZeG4YnC1rFj9BB7G2GfftS7b2FdG5/gnkzhKhYQN55FvPXOL0nLhKJ9eLhtQSYlunhZB/UU XtJaSr2ptoRJj4w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add documentation for the netconsole task name feature in Documentation/networking/netconsole.rst. This explains how to enable task name via configfs and demonstrates the output format. The documentation includes: - How to enable/disable the feature via taskname_enabled - The format of the task name in the output - An example showing the task name appearing in messages Signed-off-by: Breno Leitao --- Documentation/networking/netconsole.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst index 84803c59968a3237012fab821f432eb531aba45c..ae82a6337a8d8a07a0d691e2da170f6cf70ae86f 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -240,6 +240,34 @@ Delete `userdata` entries with `rmdir`:: It is recommended to not write user data values with newlines. +Task name auto population in userdata +------------------------------------- + +Inside the netconsole configfs hierarchy, there is a file called +`taskname_enabled` under the `userdata` directory. This file is used to enable +or disable the automatic task name population feature. This feature +automatically populates the current task name that is scheduled in the CPU +sneding the message. + +To enable task name auto-population:: + + echo 1 > /sys/kernel/config/netconsole/target1/userdata/taskname_enabled + +When this option is enabled, the netconsole messages will include an additional +line in the userdata field with the format `taskname=`. This allows +the receiver of the netconsole messages to easily find which application was +currently scheduled when that message was generated, providing extra context +for kernel messages and helping to categorize them. + +Example:: + + echo "This is a message" > /dev/kmsg + 12,607,22085407756,-;This is a message + taskname=echo + +In this example, the message was generated while "echo" was the current +scheduled process. + CPU number auto population in userdata -------------------------------------- From patchwork Fri Feb 21 13:52:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13985545 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CD26211A2F; Fri, 21 Feb 2025 13:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145950; cv=none; b=iJOzuHc0ZktbpG0+RmVGrmSN68T6dKDYqYQE0unH8SHI0B8cg/z2CDW8bG6XUBPwI8WfRqG65T4RxgqobotwiVPVADH+Ary42uS6YXtr9UbiMxryICe18GnOY/K/BEmX0W/6bCmBCitZiu11gLyZLxVwxwdhcp8nA3t4b5JSCEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740145950; c=relaxed/simple; bh=UAMiYSp0KHUcRLeGDdf4eEUuv3guyClaUcJy9nLPA7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RqS9PgFxpaLoXyxve8KQMwfg5YJAiVhTTopeVY3x4+TuBpaPaKv26J4T1PHnY1I43FTLRnMwfvyQk74jNBj34Iz1Oh6+vvy1sCCPeqQhwML1bJZI527tv2M8b852DLtWcTmRKP+aS6lKkx6lEPkCsuCogPIyM63s1BVL725Me2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5e050b1491eso5648348a12.0; Fri, 21 Feb 2025 05:52:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740145946; x=1740750746; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TUXvrwelqbD1V75CQwnY7FgY79R0MbcECGMShqCA46U=; b=ju7CPHthny4esZN31/cJHUrahdxHpAAj8L8ZJqZmyk9eL8ILRFAQCWgf93DJRr3tgM L6pgtkzuVm/zfz3ohNhUOjZJYx8oMLCGgbWhXCRZr2WTRZyTHiqNWmMJeQsq1fILgkSN Q9kAZVAAubzoAqOfnyn44cT7JZAd3JL2rVdrxv7dCGI8xVngfARn8wXhofXbMc0843qb fC+Ojtxn4H912vOeaHEk2vs76SXL+zVbcclpySgj9gnAz610dEfstNi58gO4nYTDR2XA mXswC8THfC7HJuFe3uQ4Ml8k+dGokkLhl0jLeFQKawWPBhFWX7LmEzjt+YCJhKX5Sb5U Nz+g== X-Forwarded-Encrypted: i=1; AJvYcCWVyqEydfh9ynrXcfKDiMjT3BNKYQzmNe2zRYSMqJAn2Dh1H3DFjqboOlyfIwHKoQgrU5bagZYrGg4=@vger.kernel.org, AJvYcCWk76RweSnX35W5/H64oMs+ZKOcL6HGhcewwlYHcQeH6dDnwQFS9xNzLtD3WDv145Ete2NYDfKs6iBP+i5k@vger.kernel.org, AJvYcCX8toQTbO8sMcZrqnSKl//ucZ+7rJDBGhyI5yuEJaAMK0+tBMIOky/0VFDi/5Il46jgFC3UUK687r6EpwWbNNkp@vger.kernel.org X-Gm-Message-State: AOJu0YyYf+w/LFFX7dFdLlvirXdUQnwSUsrgt71kvmiAu8hnNMkH1qha AFaUmMho4vHW8bHIwCxUeBEhbfltmXrG14LnyAeO3dYvolGeATyGCodklA== X-Gm-Gg: ASbGncuwlGsa7pAXGOEGxl/u/FoQQXSloO2aBDsemYhfLTChEKrqS0NwvP0UOh2sqv9 urfsuu6CgfoEdL8oHe9MlbMdzKEAsDjjBX0pEco6SFO+bZ7fQtcLFddRoARuOYFIKrGGcMwLPII fX+4cOWsezMAVXAWcekqJCFYfFAws2TKHULFOBk6GnCOI6pBM13BRTta7zxYFV2vbC8rwlms1OX QcNr5I9uJWM1vQXex7zrnu14K0Y+3ycVkyuRbOLKxSCxzTXBt9YthmeQlhyNgVSV+Nvc92s/Oxy NshwDeUPqHZ5Alec X-Google-Smtp-Source: AGHT+IFM2bCjUEEf+k8Bat7h8Tcg/3FtntblsSmSvoqqXX0anKjWVo6IaqCfPW2KnZT1GZBkNuPhmw== X-Received: by 2002:a17:907:7a88:b0:ab6:fe30:f49e with SMTP id a640c23a62f3a-abc0b0e5fcdmr354463666b.28.1740145946307; Fri, 21 Feb 2025 05:52:26 -0800 (PST) Received: from localhost ([2a03:2880:30ff:7::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8a647c7dsm1112639866b.72.2025.02.21.05.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 05:52:25 -0800 (PST) From: Breno Leitao Date: Fri, 21 Feb 2025 05:52:12 -0800 Subject: [PATCH net-next 7/7] netconsole: selftest: add task name append testing Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250221-netcons_current-v1-7-21c86ae8fc0d@debian.org> References: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4260; i=leitao@debian.org; h=from:subject:message-id; bh=UAMiYSp0KHUcRLeGDdf4eEUuv3guyClaUcJy9nLPA7w=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnuIUMJjAspGO8HO4uoPYIg3Zb0goymWI1KXVBp 5X9ErcMswGJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ7iFDAAKCRA1o5Of/Hh3 bcWaD/40iZKArz5bw2/fo5GELpRSNZJaC5y6BS2xxBnjo2saV3YWhbLi0pxmEL2onRCMCpodDcl UjD0CcjCH+uzzD0gWu+8Mt3d5cQhH0pKn0vMwlEs7WSYFxbOrGbyUdcuu5NzXp9RGiPbr3NhAK1 cbIMapTpCf5hTxYHlEp2/+Oaqq0huFRQDunx7OGmSqwIWNZhfKjmm5YZ9hkcZ4vTLRuHm5LovFE B3W41m3OBO1Fmv3zdbNJUDsavQn9irAPh2OEzkUEymSY4Kel2DCJ74URKCexprXfwEC/2I2MbbL 6PgJNcUCgUNc4KrovHLwjtiFEGfVMJkoXUaB6V1tqfS1UghFQV+JZ1xFTuOOxg8FUK7Pt6PpxFD WK7D2xTTpoYPJYEPQJPiKIwx3MNFULh/+QAHLmswgYSDZHTA5dsUZ2kpQgnRpBsN8HEGHb50quR q4rghn+WklsZ7jBOWW4LiAjiUTJXMt98pRZFGOC5qZHCX5X6xhybo9URTa9UxydjF+79MhHg+os su+nlBdiXBxveM/CwfDVnCk987m19xqkIIR7UTenqcJTXeVwSaAo3YH0rkVI+xdG1PleBWv4knd w2rGLwi4htMUVLGLIb2KbHbT41pCZfhe9TjmwwxlPN+syBIJ3NHwIZB87ABTxvG2U6Qk6Lirzqj q4YirEV3TMWRoAw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add test coverage for the netconsole task name feature to the existing sysdata selftest script. This extends the test infrastructure to verify that task names are correctly appended when enabled and absent when disabled. The test validates that: - Task names appear in the expected format "taskname=" - Task names are included when the feature is enabled - Task names are excluded when the feature is disabled - The feature works correctly alongside other sysdata fields like CPU Signed-off-by: Breno Leitao --- .../selftests/drivers/net/netcons_sysdata.sh | 51 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/drivers/net/netcons_sysdata.sh b/tools/testing/selftests/drivers/net/netcons_sysdata.sh index 2b78fd1f5982fee81b379bf9ac6f64a38d915974..f351206ed1bda4d46269a521b27b9b8e56d524be 100755 --- a/tools/testing/selftests/drivers/net/netcons_sysdata.sh +++ b/tools/testing/selftests/drivers/net/netcons_sysdata.sh @@ -31,17 +31,38 @@ function set_cpu_nr() { echo 1 > "${NETCONS_PATH}/userdata/cpu_nr_enabled" } +# Enable the taskname to be appended to sysdata +function set_taskname() { + if [[ ! -f "${NETCONS_PATH}/userdata/taskname_enabled" ]] + then + echo "Not able to enable taskname sysdata append. Configfs not available in ${NETCONS_PATH}/userdata/taskname_enabled" >&2 + exit "${ksft_skip}" + fi + + echo 1 > "${NETCONS_PATH}/userdata/taskname_enabled" +} + # Disable the sysdata cpu_nr feature function unset_cpu_nr() { echo 0 > "${NETCONS_PATH}/userdata/cpu_nr_enabled" } -# Test if MSG content and `cpu=${CPU}` exists in OUTPUT_FILE -function validate_sysdata_cpu_exists() { +# Once called, taskname=<..> will not be appended anymore +function unset_taskname() { + echo 0 > "${NETCONS_PATH}/userdata/taskname_enabled" +} + +# Test if MSG contains sysdata +function validate_sysdata() { # OUTPUT_FILE will contain something like: # 6.11.1-0_fbk0_rc13_509_g30d75cea12f7,13,1822,115075213798,-;netconsole selftest: netcons_gtJHM # userdatakey=userdatavalue # cpu=X + # taskname= + + # Echo is what this test uses to create the message. See runtest() + # function + SENDER="echo" if [ ! -f "$OUTPUT_FILE" ]; then echo "FAIL: File was not generated." >&2 @@ -62,12 +83,19 @@ function validate_sysdata_cpu_exists() { exit "${ksft_fail}" fi + if ! grep -q "taskname=${SENDER}" "${OUTPUT_FILE}"; then + echo "FAIL: 'taskname=echo' not found in ${OUTPUT_FILE}" >&2 + cat "${OUTPUT_FILE}" >&2 + exit "${ksft_fail}" + fi + rm "${OUTPUT_FILE}" pkill_socat } -# Test if MSG content exists in OUTPUT_FILE but no `cpu=` string -function validate_sysdata_no_cpu() { +# Test if MSG content exists in OUTPUT_FILE but no `cpu=` and `taskname=` +# strings +function validate_no_sysdata() { if [ ! -f "$OUTPUT_FILE" ]; then echo "FAIL: File was not generated." >&2 exit "${ksft_fail}" @@ -85,6 +113,12 @@ function validate_sysdata_no_cpu() { exit "${ksft_fail}" fi + if grep -q "taskname=" "${OUTPUT_FILE}"; then + echo "FAIL: 'taskname= found in ${OUTPUT_FILE}" >&2 + cat "${OUTPUT_FILE}" >&2 + exit "${ksft_fail}" + fi + rm "${OUTPUT_FILE}" } @@ -133,10 +167,12 @@ OUTPUT_FILE="/tmp/${TARGET}_1" MSG="Test #1 from CPU${CPU}" # Enable the auto population of cpu_nr set_cpu_nr +# Enable taskname to be appended to sysdata +set_taskname runtest # Make sure the message was received in the dst part # and exit -validate_sysdata_cpu_exists +validate_sysdata #==================================================== # TEST #2 @@ -148,7 +184,7 @@ OUTPUT_FILE="/tmp/${TARGET}_2" MSG="Test #2 from CPU${CPU}" set_user_data runtest -validate_sysdata_cpu_exists +validate_sysdata # =================================================== # TEST #3 @@ -160,8 +196,9 @@ OUTPUT_FILE="/tmp/${TARGET}_3" MSG="Test #3 from CPU${CPU}" # Enable the auto population of cpu_nr unset_cpu_nr +unset_taskname runtest # At this time, cpu= shouldn't be present in the msg -validate_sysdata_no_cpu +validate_no_sysdata exit "${ksft_pass}"