From patchwork Wed Nov 13 15:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13873867 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 B87EB208A7; Wed, 13 Nov 2024 15:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731510678; cv=none; b=VNpAIyqnLb2S175dzPFkjsQJCON2Q56CtZZFqLILchxIzd2zihnrGgKR1AmF4B4a7V0WWI2Eej7aiAs76JhdT+X9HU4cZgOKX6OdROiXwedMLFcvApz8imD03+Pb6rRy/DS+cnqkqzn5Qqmejts0urwK9QiSHZ4kujwLBRe/0zM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731510678; c=relaxed/simple; bh=dvK97ikucZCA3mi0xw8qgSct+K0NNsxtWtBJbaBwBso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hYo9gFQGKoSIRo+9qkVvo06upC0TMD3URQGMegF3k2F1kABSkgOaFygTL6ZOOdbi/McDh9fcYEJutyki/MpchX2xevA8xZpAi2bZ2go0faCSdGDZtrA11BzmtYGAEmCERvfrjf//lBwUHKbeSgz9Z1F8sGK4ePn6qDFLgSwEnEU= 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.42 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-f42.google.com with SMTP id a640c23a62f3a-aa1e51ce601so327885066b.3; Wed, 13 Nov 2024 07:11:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731510675; x=1732115475; 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=W0okCZd3Tx+gQrgEVOilpTV31ZqkJUqPhWl0/A78bQ0=; b=re8fdyCM7fzxQxS1qsgfhIUfjw0Lfm4Z0IC0/Te9PJbe8wpiUbaU76ISAGj2NY1ve2 3EjWNW+IP5ZB80xrxomaxMLlQKvS2zFLNTJ7j2tLqyZSf30WbdtW0b8tdKXj2lIueUwY crNx5/Tfn1hn3yH0+X3yzjV7BNhVlGNsKq46DUaTfezuXwkH42sMJ/gFiutxcr2FTrGs AarJGugQJbmN7Byw525/ejImGwXlwfojptePfs/yKxyyRocpd/GHpg50syF2/46T74pQ C4Zt7xz/ZhkGG5IepRAje7VCgI9kW0UYftJulxcy6v8uLR5iLYIyW/41CJSFPmpxCWev +EUQ== X-Forwarded-Encrypted: i=1; AJvYcCUmT22IR3BAU8LzPf+EVb/1Xt9MKszASD32NfmJrFRgKcGQSM2N1MhbEhaUJjM6DZjhbGB99uoueWk=@vger.kernel.org, AJvYcCXFRhImIRU2Uf3uCw/J5WuJB/FAJgVC30qgdIejFdHb7Ux7P1INChK5r9z+hATm5GSS3zG8A9vaHnQt4oH1HoAd@vger.kernel.org, AJvYcCXnHA0PLFM0eh6BU8spsOXdIopOoof322bWf0W/f50F0FSq9Az1O2rYoLegdmD3A7tR7b11mQaWKizxcdBd@vger.kernel.org X-Gm-Message-State: AOJu0Yw2/2xM2byXqxNClboqdCkAu5SnQId72z6X13a0DEqr0EVQ/FM+ i/DXN3QFcC5G3fpq2hacsTWo2bHQ3j1+zVC3hEaVIJ04Hsk1kSnJ X-Google-Smtp-Source: AGHT+IEqga+x5+wVzdRkFEVj9yPEB6xOIvRkkWxf81x+yvhYejVYjpTd9wj5MB3gxeXmIfKIUFYygA== X-Received: by 2002:a17:907:2688:b0:a9a:a7fd:d840 with SMTP id a640c23a62f3a-a9eefeb2c37mr1909473966b.1.1731510674837; Wed, 13 Nov 2024 07:11:14 -0800 (PST) Received: from localhost (fwdproxy-lla-001.fbsv.net. [2a03:2880:30ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9ee0a4a9b1sm874787166b.52.2024.11.13.07.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 07:11:14 -0800 (PST) From: Breno Leitao Date: Wed, 13 Nov 2024 07:10:52 -0800 Subject: [PATCH net-next 1/4] netconsole: Ensure dynamic_netconsole_mutex is held during userdata update Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241113-netcon_cpu-v1-1-d187bf7c0321@debian.org> References: <20241113-netcon_cpu-v1-0-d187bf7c0321@debian.org> In-Reply-To: <20241113-netcon_cpu-v1-0-d187bf7c0321@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 , max@kutsevol.com, thepacketgeek@gmail.com, vlad.wing@gmail.com, davej@codemonkey.org.uk X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1125; i=leitao@debian.org; h=from:subject:message-id; bh=dvK97ikucZCA3mi0xw8qgSct+K0NNsxtWtBJbaBwBso=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnNMGNNLZFDm5UODb/yliTCrMzkzzRmOblnI0ne zFE3eQ7QcOJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZzTBjQAKCRA1o5Of/Hh3 bSeoD/0YXmv/scg2QQ7OU0VAUCNpnLD08+t+xQ+IwTqsxUH5H7gj3wnukCQejaaFu2TAqNJtBPa lhRyMnRHZu9X2hjVHFhWZHWR4FibG2ADkEoyqxHyPJjeTn1MKVk1bB2fuvPRMsziosdB2TSpEbX S1dE1jemAtmpYBZpACpBgoEeET3C0iS7Qk3M8UxLF1pfSiGT2VXUJtqmW0a+WAWkfoDROFyj4qH ub0ZOaI/ILV2Ky7sl+W6DGwFTxxOERWin+Swjr9HI7vP8/lURJem0gGh5fVBIn5XlW3jop3jCaD IQLZ6wOjDBOjV39gX7reqazNlO9MXM2HyewTrchP4U/JCR/VT5tEi5x/CNhv759kirLFegZgB7Q us4gi94MbIkNY6oBzP+91Sza0IKxBDa9fUmWTd95ZM6uiBZBuSsYHFDrm+KF1iOpUR4uJO+TuKP XGYRm6/walO11gdJXudCyEw6edw4m/iCWoIReKA4WzfpF0AhGC4/oeSl6GueuW5evtrJi8GzomV LesQHUEWlnX71Of55gEjUz5HPZxcSVS6Bg8hbl6bNvb7siStQwdIOcV8psffyRV5hYPn57u7IIe GtnWvXi/kcyyahFAI0Xrb7yIESUldlNi9OuhD9FpE57NNanK8lNoT1aN8Jpf3uByY9zkBG2D1H0 FGht4XCW5YRXwcg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add a lock assertion to verify that dynamic_netconsole_mutex is held when updating the userdata fields in the netconsole driver. This change prevents calling update_userdata() without holding the lock, ensuring data consistency and integrity. The update_userdata() function is invoked only when the user changes the configuration, so this addition does not impact performance as it is not in the hot path. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 4ea44a2f48f7b1f9059d275f0f0edc40cc1997f0..965712d65a014c60f91bf35e48f1b112f66b8439 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -697,6 +697,8 @@ static void update_userdata(struct netconsole_target *nt) int complete_idx = 0, child_count = 0; struct list_head *entry; + lockdep_assert_held(&dynamic_netconsole_mutex); + /* Clear the current string in case the last userdatum was deleted */ nt->userdata_length = 0; nt->userdata_complete[0] = 0; From patchwork Wed Nov 13 15:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13873868 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 1CB271DEFC1; Wed, 13 Nov 2024 15:11:17 +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=1731510680; cv=none; b=h4gh7OIv6tlWwZU9qDDSvZs+hh4KrUX8/2P5HOPCkFlFrMUaajrcmYZsAES00ijTIWpgqBpkf480MX9ABLDvRDyaQvxJM5+mJ4YHxNtDFuxRYcHCCZoQH3Xoaaf0PLw0ZtNhZdENvWXYqVdh/usWDKWYOBMAvC5vYq3o9YZXAZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731510680; c=relaxed/simple; bh=M9uDuQTAde8qumiV+TT94/net7Txx0TCYMg4owgJhXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ey0bjzGHtZ+t2OMFVIAeNxuCH90dkGHlBwj0UVwTZsoM78jWimkrBzoNXe5w48Z47TIATshesKiC3Nxfdni86XWNGY1MoH/FAJIxQIDw+9T25WqFgox/aiJSdDrxSWvnh2zWXfgf+/LZnRsm7Fnhxot600fHciHJf+G+WHaXCEU= 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-aa1f73966a5so197484866b.2; Wed, 13 Nov 2024 07:11:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731510676; x=1732115476; 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=suvmTaEnzl11zjg8cnygNcxRnDm3roxsjMJva7RhPLI=; b=taLDEtAHsll4aCs4bXjjv1Vbbpxor2RG5pQtgH0URDsSnCLT2XGg97UKyiDdmyjc1n pqCxa1i5KeMutxQwPu8y+dDxlqpqlGG3UL2gg85SdhM1Z7WlAKA73/xG8uj+ufnu7Gum /XQL5RpgA9Ei4owSsWk9a/FLOy/cfSJt8j6IPVw9irKPj1FOw4sopQjyc2lOPHtOJi6L 9rcy5p0pJJj2upXEWEcbc3tSvtuNmhS5ElZFUG+7SYq6Vc81TnkNP4R3mp8zgIfrEbql +lSiDknJoN6yv6hA1W6bKu94+LsQeHwKZRb/qBiRWCm8Q8ghWNdbC904cbG46JR+eJzO wOkQ== X-Forwarded-Encrypted: i=1; AJvYcCViOfiM7FpcrZky/EQ0NvYqnBdL9+iutNsCr5VTgscfkWUP+EJfxMcoI3XSqzFECmsu2LYTK5gUa5pmsalq@vger.kernel.org, AJvYcCWyvW1V6K3wjNmgMf15kPxxxWRY1pSkxZHGBy0ynKE9IWDZ8xH5bl8cjGb3sPhI26fF3MB5r6wZTQlh/QDQbhLh@vger.kernel.org, AJvYcCXfZlQ4ixmH0dCbhjsLY/D/6UghWoSIL1sutC9BDoPRUmOp19rphlYdMLY5u269VdvNPkaORlRh0ZA=@vger.kernel.org X-Gm-Message-State: AOJu0YxZZ6WTMLKH2aIracwlD+MAfO7yr4p23moG+u5sY87X7ejEDMtq 0oNqpPnAUwCrWWPTfAmH+Qw9JqI8Bcj2fmqg6zP4Z6JJ+aUDzIsN X-Google-Smtp-Source: AGHT+IHr6qfcpHRDGdLKsLFJqQ9xks/fGPsz80h7XFddq8GevD34SOc4JX6iLzFGCnx1q2sNywl7Sw== X-Received: by 2002:a17:906:6a19:b0:a99:d6cf:a1df with SMTP id a640c23a62f3a-a9eeffee0e2mr2122340166b.46.1731510676404; Wed, 13 Nov 2024 07:11:16 -0800 (PST) Received: from localhost (fwdproxy-lla-003.fbsv.net. [2a03:2880:30ff:3::face:b00c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9ee0def50csm879414366b.154.2024.11.13.07.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 07:11:15 -0800 (PST) From: Breno Leitao Date: Wed, 13 Nov 2024 07:10:53 -0800 Subject: [PATCH net-next 2/4] netconsole: Add option to auto-populate CPU number in userdata Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241113-netcon_cpu-v1-2-d187bf7c0321@debian.org> References: <20241113-netcon_cpu-v1-0-d187bf7c0321@debian.org> In-Reply-To: <20241113-netcon_cpu-v1-0-d187bf7c0321@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 , max@kutsevol.com, thepacketgeek@gmail.com, vlad.wing@gmail.com, davej@codemonkey.org.uk X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5057; i=leitao@debian.org; h=from:subject:message-id; bh=M9uDuQTAde8qumiV+TT94/net7Txx0TCYMg4owgJhXw=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnNMGNJX7xXHZAgpJIfJkaljoPuxitBTtwVin+2 eqZXgy8NaSJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZzTBjQAKCRA1o5Of/Hh3 bZGDD/0c59dMjmJwCS7LsDusvfT1ekJUy9yMjzh0Td7k1uQ7WvAjIp3pkkxjFieoNEhadz90pCY 5YjFyg4tNWeJiQ/kowuP/g+XKjE0bZJ6qjdDw+MZAb+BtN0KqqAYt7C2ltkRpUJEMgsOJUc92+/ mGIHad+NYzKc04QUzrwg6MLOLzj7fW2Vzu948suirUBSH60qM1o4elCPnC+86ZJDkCHkctEtcXn SPv9C8g1pv8KQ+Cvt/v9PlkmLcyIR6c2CQR+l4rHck5V3n/He+CnMAon648tt4bPyaxev9JQDWp 6yR/GSLUtBIxCg2oemY+s5R/p7aQdo/W69YPCeRo//Rq3MCtVe49vywKZHRA/2eGfFtRR7e7LZZ ZFHOav+Kr3iwb4gTxV40qHnUkK5WGwhsSqhXSAduAGbNT4dNO7zM4lPVl+c+3zr/v6UuotoEiII uxQOdMGdxsd+XTLjS8E6zAnwenivQBopObbfZFeXQqMSQ2ooP+dvKfCSALjlr79SDobrpdVsqZ3 zm6sdfwhF2R/cwrfWEWNNdGF50BqJcaBFqoUK4KOjuOksUq51dhAmwuMrAyCOAQxLlDJ9Q9Vlca BSmRF6+knzyLTw3ZIBWpyuCId7CBxlHYyAbGXCx60I9udpCwIPC8yQacDdumpZU2+CblNZrFfKZ n/rtrlHcq+pMtQQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add a new option to the netconsole subsystem to automatically populate the CPU number that is sending the log message in the userdata field. When enabled, this feature will append a "cpu=" entry to the userdata string, allowing the receiver to demultiplex and differentiate between messages sent from different CPUs. This is particularly useful when dealing with parallel log output that gets intermixed on the receiver side. The new option is added as a flag in the enum userdata_auto and can be controlled through the populate_cpu_nr sysfs attribute in the netconsole target's configfs hierarchy. The main benefits of this change are: * Improved log message demultiplexing for parallel output. * Better visibility into which CPU a particular log message originated from. Create userdata_auto as an bitwise enum, since I have immediate plans to expand it. Since the CPU id doesn't need to be precise, do not disable preemption when getting the CPU id. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 965712d65a014c60f91bf35e48f1b112f66b8439..861e8988b8db4f29ae3de02222c9131059694aba 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -90,6 +90,14 @@ static DEFINE_MUTEX(target_cleanup_list_lock); */ static struct console netconsole_ext; +/* Fields requiring kernel auto-population in userdata. + * The fields are designed as bitwise flags, allowing multiple fields to be set + */ +enum userdata_auto { + /* Populate CPU number that is sending the message */ + AUTO_CPU_NR = BIT(0), +}; + /** * struct netconsole_target - Represents a configured netconsole target. * @list: Links this target into the target_list. @@ -97,6 +105,7 @@ static struct console netconsole_ext; * @userdata_group: Links to the userdata configfs hierarchy * @userdata_complete: Cached, formatted string of append * @userdata_length: String length of userdata_complete + * @userdata_auto: Kernel auto-populated bitwise fields in userdata. * @enabled: On / off knob to enable / disable target. * Visible from userspace (read-write). * We maintain a strict 1:1 correspondence between this and @@ -123,6 +132,7 @@ struct netconsole_target { struct config_group userdata_group; char userdata_complete[MAX_USERDATA_ENTRY_LENGTH * MAX_USERDATA_ITEMS]; size_t userdata_length; + enum userdata_auto userdata_auto; #endif bool enabled; bool extended; @@ -371,6 +381,18 @@ static ssize_t remote_mac_show(struct config_item *item, char *buf) return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac); } +static ssize_t populate_cpu_nr_show(struct config_item *item, char *buf) +{ + struct netconsole_target *nt = to_target(item->ci_parent); + bool cpu_nr_enabled; + + mutex_lock(&dynamic_netconsole_mutex); + cpu_nr_enabled = nt->userdata_auto & AUTO_CPU_NR; + mutex_unlock(&dynamic_netconsole_mutex); + + return sysfs_emit(buf, "%d\n", cpu_nr_enabled); +} + /* * This one is special -- targets created through the configfs interface * are not enabled (and the corresponding netpoll activated) by default. @@ -726,6 +748,15 @@ static void update_userdata(struct netconsole_target *nt) MAX_USERDATA_ENTRY_LENGTH, " %s=%s\n", item->ci_name, udm_item->value); } + + /* Check if CPU NR should be populated, and append it to the user + * dictionary. + */ + if (child_count < MAX_USERDATA_ITEMS && nt->userdata_auto & AUTO_CPU_NR) + scnprintf(&nt->userdata_complete[complete_idx], + MAX_USERDATA_ENTRY_LENGTH, " cpu=%u\n", + raw_smp_processor_id()); + nt->userdata_length = strnlen(nt->userdata_complete, sizeof(nt->userdata_complete)); } @@ -757,7 +788,36 @@ static ssize_t userdatum_value_store(struct config_item *item, const char *buf, return ret; } +static ssize_t populate_cpu_nr_store(struct config_item *item, const char *buf, + size_t count) +{ + struct netconsole_target *nt = to_target(item->ci_parent); + bool cpu_nr_enabled; + ssize_t ret; + + if (!nt) + return -EINVAL; + + mutex_lock(&dynamic_netconsole_mutex); + ret = kstrtobool(buf, &cpu_nr_enabled); + if (ret) + goto out_unlock; + + if (cpu_nr_enabled) + nt->userdata_auto |= AUTO_CPU_NR; + else + nt->userdata_auto &= ~AUTO_CPU_NR; + + update_userdata(nt); + + ret = strnlen(buf, count); +out_unlock: + mutex_unlock(&dynamic_netconsole_mutex); + return ret; +} + CONFIGFS_ATTR(userdatum_, value); +CONFIGFS_ATTR(, populate_cpu_nr); static struct configfs_attribute *userdatum_attrs[] = { &userdatum_attr_value, @@ -819,6 +879,7 @@ static void userdatum_drop(struct config_group *group, struct config_item *item) } static struct configfs_attribute *userdata_attrs[] = { + &attr_populate_cpu_nr, NULL, }; From patchwork Wed Nov 13 15:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13873869 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.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 4318A1F9A80; Wed, 13 Nov 2024 15:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731510683; cv=none; b=E5tK36JQXm60qoUveCDGqNMhLC47jUcS1sQM+VmmaMt3ycXev5q531NI6Lu+hUSXai1N1vqpTZJ753nU4CtGFFvYYfDW1/ybflq7g1RPNeq+JkGGN/varSBYDu/YQnsKL6aqWiIFJf/POJbC392cfjgCGjsv79KPFcA8uSKZdds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731510683; c=relaxed/simple; bh=IpyXc0ozD1GMB+Il96IkWK5dAeJgnotpsHJ8YdD/teM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D9GDv2XC903iuF4Xx2ICyo3BFfktnGHeC+7xvQLZfl8dNOyJea+yacFxkpgHyhrnIhUYBh4TAEiNbQ8Q68z+iykgmDozu+45vGqorYQw+uiSNq6VM+/QVmFC7azWonmmpiMNHpOr0g3rwxFHm2aP1PLS47V8sKZhV8FzSdyW0UI= 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.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-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5cefa22e9d5so7809698a12.3; Wed, 13 Nov 2024 07:11:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731510679; x=1732115479; 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=7S6/os6Qv1ZJNXWnYiunu3TXRi78fgOLap6v5ztnDQE=; b=krW2KAjqImoaLtsMIJ0XyEVVTx+fvXqCDhXaDiOGV/H8x3YMEIvOBt5IAQVg09YMQi qv7/5bz+kI693V3OnRKGfdDcCNl7n/UpKVabcYG7MxiXIWusvhLpThsEihNhI/gikeeY s/7wkEp7v+rxhn871gmHhKPvTAO14pLBQDd2De1cWezBU54l+vbHBQtqfzlTcxN/0Ph0 EJSKxK8o5k9/lmb8Z/GpuYQZ7TeDXZ0wUXbHTWzJC8NhvB5BZ13AzE8Cp2huzCmSSfCF PYVc6e0gGfMEVb8tYFxoB7ul1gEls8+p6tXXnqSomQkZbCos8haXOSmvhtEBl/5lLE46 LKTA== X-Forwarded-Encrypted: i=1; AJvYcCU9AV+SzhaZCsITaD7NwYIOXJR05Jsiu2ulIy0PjqosBjqWcnF3n8RDWv0KTerL3iFEfb9h0Ghc4B7r9UlL@vger.kernel.org, AJvYcCVCG5Rz5rQNibt4RBUrzTiRKeOF7xGmHDFleYDuKvnL8DCKBrhDWKkp0qnTW8ohn3uziXYb2sOCdVo=@vger.kernel.org, AJvYcCVbgCQ+xpVSQaTZz0yu1anTTBsj3AS38ImMd3Vj1fGGZmjcya/sokMttYvdOyEzMo27NvMvhqqZMoVGjpsCAjjN@vger.kernel.org X-Gm-Message-State: AOJu0Yyl6xJE53AIt123ozRJMFMOlZEIqcOU/OQS+etzgVjBnL5ieytZ 60DyPh9fgigKVQUZsj8oVa3zjagY+LhElRQ3sPOZY4CMYpLT+7NT X-Google-Smtp-Source: AGHT+IEooQZHxOiMQIn34HIP+DH8p3aE6At6BOsjxnDBiugb63EK8ejjNK/O5fpurmhQZP2JWmILNA== X-Received: by 2002:a05:6402:4311:b0:5cf:f82:eb65 with SMTP id 4fb4d7f45d1cf-5cf0f82eca8mr14928484a12.9.1731510679496; Wed, 13 Nov 2024 07:11:19 -0800 (PST) Received: from localhost (fwdproxy-lla-116.fbsv.net. [2a03:2880:30ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf03b7e9c1sm7150081a12.30.2024.11.13.07.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 07:11:18 -0800 (PST) From: Breno Leitao Date: Wed, 13 Nov 2024 07:10:54 -0800 Subject: [PATCH net-next 3/4] netconsole: docs: Add documentation for CPU number auto-population Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241113-netcon_cpu-v1-3-d187bf7c0321@debian.org> References: <20241113-netcon_cpu-v1-0-d187bf7c0321@debian.org> In-Reply-To: <20241113-netcon_cpu-v1-0-d187bf7c0321@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 , max@kutsevol.com, thepacketgeek@gmail.com, vlad.wing@gmail.com, davej@codemonkey.org.uk X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2825; i=leitao@debian.org; h=from:subject:message-id; bh=IpyXc0ozD1GMB+Il96IkWK5dAeJgnotpsHJ8YdD/teM=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnNMGNzGRw6kxr2xG4dDZWgxH4YZ0MO8P17DbTm zuXW0wPnA6JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZzTBjQAKCRA1o5Of/Hh3 bXu/D/9ZPm74waC8ijNe4fg4/CahtsYlyec/NF+SAZ9vDqSx4mlF5v9Z/qwc+Hp4lzlug3NTo1k MzvOCTWK+fn28Ny2ImckvQ3rrYgCFoHdRnvqGep6rC76ZVSiy1X9cAqJ9VyycvbDdGJdRsgh429 ZYu4nrTn3H2w/kYqt1xjhsIBKyabNY3oROeAMeFlmg4dnSy7QIdtocsdwIhEZs0vM+o+WzBHZCK VyiTURNjwKAgpt4kTVkli4yA+0ziwR97h4khTYoCUNqg8r8kXcArN6L7X88f8iQvg+h+dUBhSsp JVuUMK5aMAdote/BInKBMAJab60LcmY4jWq06qCmrs5GEffzN7Cja/ISyeGGN43af5l6O00P5zg eaPjcOt3Hes7byvM+6PZBuvqu2SZyaT3Bajj9bZCVbhVrxC1dGMfTYmg7lfJuxTWDq0Ai49pf0z O+9+SwHO+VE5T30RQAMEoQBL6J0KX4Zc+Hbd5UKY4qVghkR3IF6FrVUkfhvcPdmx/zTndqbRfY5 26Cr0ukcwtkUPK5wsuss1IDPo1XPJRMEHxXygq3MuLc4WjFRGS65K1j3v6tL2Y7GqbMRazfrXED DfEoCeVwoioYVL94BwVLOEV3zrFekhJ+xVfR/NGBbL16FcjLhFLFFnOIG1ws4nodvPu9cG+lPz1 U5hWPn8TV/mxb2w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Update the netconsole documentation to explain the new feature that allows automatic population of the CPU number in the userdata field. The key changes include introducing a new section titled "CPU number auto population in userdata", explaining how to enable the CPU number auto-population feature by writing to the "populate_cpu_nr" file in the netconsole configfs hierarchy. This documentation update ensures users are aware of the new CPU number auto-population functionality and how to leverage it for better demultiplexing and visibility of parallel netconsole output. Signed-off-by: Breno Leitao --- Documentation/networking/netconsole.rst | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst index d55c2a22ec7af0e687b76176c9171eb1b19013bd..a1b269196be390b5f88a6eca77f6676c67c05720 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -237,6 +237,50 @@ Delete `userdata` entries with `rmdir`:: It is recommended to not write user data values with newlines. +CPU number auto population in userdata +-------------------------------------- + +Inside the netconsole configfs hierarchy, there is a file called +`populate_cpu_nr` under the `userdata` directory. This file is used to enable or +disable the automatic CPU number population feature. This feature +automatically populate the CPU number that is sending the message in the +userdata field. + +To enable the CPU number auto-population:: + + echo 1 > /sys/kernel/config/netconsole/target1/userdata/populate_cpu_nr + +When this option is enabled, the netconsole messages will include an additional +line in the userdata field with the format `cpu=`. This allows the +receiver of the netconsole messages to easily differentiate and demultiplex +messages originating from different CPUs, which is particularly useful when +dealing with parallel log output. + +Example:: + + echo "This is a message" > /dev/kmsg + 12,607,22085407756,-;This is a message + cpu=42 + +In this example, the message was sent by CPU 42. + +.. note:: + + If the user has set a conflicting `cpu` key in the userdata dictionary, + both keys will be reported, with the kernel-populated entry appearing after + the user one. For example:: + + # User-defined CPU entry + mkdir -p /sys/kernel/config/netconsole/target1/userdata/cpu + echo "1" > /sys/kernel/config/netconsole/target1/userdata/cpu/value + + Output might look like:: + + 12,607,22085407756,-;This is a message + cpu=1 + cpu=42 # kernel-populated value + + Extended console: ================= From patchwork Wed Nov 13 15:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13873870 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 F2CFF201036; Wed, 13 Nov 2024 15:11:23 +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=1731510685; cv=none; b=YHy8NbPOkPGMn2ixNivEZHrVHqO+ucM368DesHX62OoqT1uQP/NyFXMwOiAqBmvPYoxyB3ibyY9250S4jUtymjpJu0a8ccD/30AH0TTdDuYK7SZufJyQ+aoeQGDUufxQ9tsDDboPK3leg4aOFL8nx3sF/9yJvIfHmtWAq9lzvW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731510685; c=relaxed/simple; bh=7wSSxIUiXUM5F3CnS/GS0ih6ZK6ssmZ3fx3f8y0jNi0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZzaqvfRx/jb+XDM15ZkPQDWC7maU9jqMnfDLNFuVnxw99MWJCBrnuJRZOa768nenrH7jLmda5fwXN0YuxYvyVhYP2Rkd0Y4o59cECHgKSsJtcPVLHLHY+v2tWQO9ph2pFdmHwuTf+lk3kJK4Mz7IoSqY00B2P3dampf2oMTikHg= 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-aa1f1f2d508so185377566b.2; Wed, 13 Nov 2024 07:11:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731510682; x=1732115482; 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=zxJL6/w7ib7tor6B/awKjwacI8QkLWn7spqQywUygr4=; b=T7hIDV4+icgtau/zZ/DMVhNWSUcjXpD6yNKrrTyCQh1JuIifz/GgBVwh4Ohmi/7Uaz 15E5Ni34rDzseG9DxuRLxlFUBJFuqpwO+j5DwpUVx+GiJdT80q2EAT33+5SnTTXwPW6q EdKWsfF20FTZaQ11V2PoplhxL9a7W2+AkAN7jlRYLKG++e6lyVB2MPJH1PaTPr4jlUEC 45/ZRpZmZaQc2F3V+TEyhYU68/BbXC4CmjiFpNUnv29kHMjVDpcHdHozG/7MBjt71zjw iJQGJnQ56zVT50NMfWxOit1T4TogWn/vFwQV81gjWtDnP/v6yLENpvdjtUBmF+Bv2G57 bPwQ== X-Forwarded-Encrypted: i=1; AJvYcCUYEoqF8+0qwDEI4DL8KKPobYd2DOebmCbE2wxd/mHsVGr6KmR0uN+ir3hN7LbX0kOx8nOEM2yTwlAckGdRuMbs@vger.kernel.org, AJvYcCVkFUgNHgMu0zF0uEXKbQzR0C647JqglOBtl+5Cb/Hh7NoqXVZSmnf8twdM9gJUOwZIbNl4LrHnUmX3s+CH@vger.kernel.org, AJvYcCWdolYDYnLssxrwbHPFhCIhKCcC0Nx4e3NegcjJguwGLTQNsRLD3kImSIHI7SvkOCh+mXdeGhOi0f0=@vger.kernel.org X-Gm-Message-State: AOJu0YyCxHhrpWiqxZaBoQCC7U8NWBM2JoWy4BUyu1jPT/z8ooPzhszL fjZWGlB3E9f0rMnxf3eb8FrE6WIHYaQs54u+zCj2S30Xhrlm6Qvb X-Google-Smtp-Source: AGHT+IEoLyfigi2UbiHSBtCcn9AV7B2W8zEBzkfRzr2dXQX1hG/gGL44SEj+d1F3HrwKO/03w2g9Ag== X-Received: by 2002:a17:907:944c:b0:a9a:8a4:e079 with SMTP id a640c23a62f3a-a9eeff44660mr2145146866b.31.1731510681944; Wed, 13 Nov 2024 07:11:21 -0800 (PST) Received: from localhost (fwdproxy-lla-002.fbsv.net. [2a03:2880:30ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf03c7cabbsm7293671a12.79.2024.11.13.07.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 07:11:21 -0800 (PST) From: Breno Leitao Date: Wed, 13 Nov 2024 07:10:55 -0800 Subject: [PATCH net-next 4/4] netconsole: selftest: Validate CPU number auto-population in userdata Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241113-netcon_cpu-v1-4-d187bf7c0321@debian.org> References: <20241113-netcon_cpu-v1-0-d187bf7c0321@debian.org> In-Reply-To: <20241113-netcon_cpu-v1-0-d187bf7c0321@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 , max@kutsevol.com, thepacketgeek@gmail.com, vlad.wing@gmail.com, davej@codemonkey.org.uk X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2328; i=leitao@debian.org; h=from:subject:message-id; bh=7wSSxIUiXUM5F3CnS/GS0ih6ZK6ssmZ3fx3f8y0jNi0=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnNMGOZOdLZzudSzkfczgpbLOO/6uj8tFPcG7Of HLb1ouaDDGJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZzTBjgAKCRA1o5Of/Hh3 belgD/9MXc6rZacHAL5a6Pw8kYf5u9hon846XtxERP1sNGQjSjmWiMP2V0KfSMLk5ZvHoFKKcQR bpP9ExABuvB3TKLEPd5Foldv7UOybHnj+255l5mHYh8zBBsDDlj2r0KSkegI0+dRyJnom7L87+e B7QJGapMQOZiXWoVeuFPb4dlp/ls0f/ZMyIynfJC4VV/G/mnAIPjdQYE9XiQK9b5ISbxGL1EYds zLZA9vmS9sw75WXjIGrXBX86UFxtK1pZ1vDqDYxA61YFjucv8fYw/gQrGZQ7DJMFLljNuur1Qcs KhEqfNOMCSLJ1/zQbFlCDrB3dvJJREFS02hY+q7bWnygKouaOsZVTY2l9qiZsiSg+FIKuJ3ilWI 3EXX3o163FxKuWTJOqRXv5/N9Pe5jEKYfhoQ6O12eYuDJoUKLj2pmx1GpxeG2zUdrJB+0GqFDWk U4m+hcSpOwcCXP3CLGfAC7DgmsIhYA5jmtXBQc8wpNt6UC/mZCQg/z1pqTF4sw/W71I4du91WO2 cZCFn76yqO+5ZgSSqnWM/JelQE0IYWjCGFVPDL+vBZi+jceioXYMZLl4S1tBGo+/FIwFNA1Z+9I x+5FnBSn27Hb8LXecNdZiaMt+bXo+8LpZFsxZmfYte/n3jIbvbww6kFfhbEJdSRE3fRyOdWzgVR 0gtaa+bvWxbtz2w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Expand the existing netconsole selftest to verify the functionality of the recently added CPU number auto-population feature in the netconsole userdata. The changes include enabling the "populate_cpu_nr" option on the netconsole target before sending the test data, and validating that the received data on the listener side contains a "cpu=" entry in the userdata, indicating that the CPU number was successfully auto-populated. This addition to the netconsole selftest ensures that the new CPU number auto-population feature works as expected and helps catch any regressions in this functionality. Signed-off-by: Breno Leitao --- tools/testing/selftests/drivers/net/netcons_basic.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/testing/selftests/drivers/net/netcons_basic.sh b/tools/testing/selftests/drivers/net/netcons_basic.sh index b175f4d966e5056ddb62e335f212c03e55f50fb0..92538a188f0696b3e54071d1d32c7b2e523db839 100755 --- a/tools/testing/selftests/drivers/net/netcons_basic.sh +++ b/tools/testing/selftests/drivers/net/netcons_basic.sh @@ -153,6 +153,16 @@ function set_user_data() { echo "${USERDATA_VALUE}" > "${VALUE_PATH}" } +function set_cpu_nr() { + if [[ ! -f "${NETCONS_PATH}""/userdata/populate_cpu_nr" ]] + then + echo "Populate CPU configfs path not available in ${NETCONS_PATH}/userdata/populate_cpu_nr" >&2 + exit "${ksft_skip}" + fi + + echo 1 > "${NETCONS_PATH}""/userdata/populate_cpu_nr" +} + function listen_port_and_save_to() { local OUTPUT=${1} # Just wait for 2 seconds @@ -185,6 +195,12 @@ function validate_result() { exit "${ksft_fail}" fi + if ! grep -q "cpu=[0-9]\+" "${TMPFILENAME}"; then + echo "FAIL: 'cpu=' not found in ${TMPFILENAME}" >&2 + cat "${TMPFILENAME}" >&2 + exit "${ksft_fail}" + fi + # Delete the file once it is validated, otherwise keep it # for debugging purposes rm "${TMPFILENAME}" @@ -254,6 +270,8 @@ set_network create_dynamic_target # Set userdata "key" with the "value" value set_user_data +# Auto populate CPU number +set_cpu_nr # Listed for netconsole port inside the namespace and destination interface listen_port_and_save_to "${OUTPUT_FILE}" & # Wait for socat to start and listen to the port.