All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kernel-team@meta.com, max@kutsevol.com, thepacketgeek@gmail.com
Subject: Re: [PATCH net-next v2 3/5] netconsole: add support for sysdata and CPU population
Date: Fri, 17 Jan 2025 18:35:20 -0800	[thread overview]
Message-ID: <20250117183520.11d93f4d@kernel.org> (raw)
In-Reply-To: <20250117-terrestrial-clam-of-satiation-cf312f@leitao>

On Fri, 17 Jan 2025 03:02:40 -0800 Breno Leitao wrote:
> > Looks like previously all the data was on the stack, now we have a mix.  
> 
> Not sure I followed. The data ({userdata,extradata}_complete) was always
> inside nt field, which belongs to target_list.

I mean the buffer we use for formatting. Today it's this:

	static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
	int header_len, msgbody_len;
	const char *msgbody;

right? I missed that "static" actually so it's not on the stack, 
it's in the .bss section.

> > Maybe we can pack all the bits of state into a struct for easier
> > passing around, but still put it on the stack?  
> 
> It depends on what state you need here. We can certainly pass runtime
> (aka sysdata in this patchset) data in the stack, but doing the same for
> userdata would require extra computation in runtime. In other words, the
> userdata_complete and length are calculated at configfs update time
> today, and only read during runtime, and there is no connection between
> configfs and runtime (write_ext_msg()) except through the stack.
> 
> 
> On the other side, if we want to have extradata_complete in the stack, I
> still think that userdata will need to be in the stack, and create a
> buffer in runtime's frame and copy userdata + sysdata at run time, doing
> an extra copy. 
> 
> Trying to put this in code, this is what I thought:
> 
> 	/* Copy to the stack (buf) the userdata string + sysdata */
> 	static void append_runtime_sysdata(struct netconsole_target *nt, char *buf) {
> 		if (!(nt->sysdata_fields & CPU_NR))
> 			return;
> 
> 		return scnprintf(buf,  MAX_EXTRADATA_ENTRY_LEN * MAX_EXTRADATA_ITEMS,
> 				  "%s cpu=%u\n", nt->userdata_complete, raw_smp_processor_id());
> 	}
> 
> 	/* Move complete string in the stack and send from there */
> 	static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
> 				     int msg_len) {
> 		...
> 	#ifdef CONFIG_NETCONSOLE_DYNAMIC
> 		struct char buf[MAX_EXTRADATA_ENTRY_LEN * MAX_EXTRADATA_ITEMS];
> 		extradata_len = append_runtime_sysdata(nt, buf);
> 	#endif
> 
> 		send_msg_{no}_fragmentation(nt, msg, buf, extradata_len, release_len)
> 		...
> 	}

My thinking was to handle it like the release.
Print it at the send_msg_no_fragmentation() stage directly 
into the static buffer. Does that get hairy coding-wise?

  reply	other threads:[~2025-01-18  2:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15 13:35 [PATCH net-next v2 0/5] netconsole: Add support for CPU population Breno Leitao
2025-01-15 13:35 ` [PATCH net-next v2 1/5] netconsole: Rename userdata to extradata Breno Leitao
2025-01-15 13:35 ` [PATCH net-next v2 2/5] netconsole: Helper to count number of used entries Breno Leitao
2025-01-15 13:35 ` [PATCH net-next v2 3/5] netconsole: add support for sysdata and CPU population Breno Leitao
2025-01-17  1:44   ` Jakub Kicinski
2025-01-17 11:02     ` Breno Leitao
2025-01-18  2:35       ` Jakub Kicinski [this message]
2025-01-20 17:30         ` Breno Leitao
2025-01-20 19:06           ` Jakub Kicinski
2025-01-24 15:28             ` Breno Leitao
2025-01-15 13:35 ` [PATCH net-next v2 4/5] netconsole: selftest: test for sysdata CPU Breno Leitao
2025-01-15 13:35 ` [PATCH net-next v2 5/5] netconsole: docs: Add documentation for CPU number auto-population Breno Leitao
2025-01-15 22:56   ` Randy Dunlap
2025-01-16  9:31     ` Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250117183520.11d93f4d@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=max@kutsevol.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=thepacketgeek@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.