netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/9] netconsole refactoring and warning fix
@ 2024-09-03 14:07 Breno Leitao
  2024-09-03 14:07 ` [PATCH net-next 1/9] net: netconsole: remove msg_ready variable Breno Leitao
                   ` (8 more replies)
  0 siblings, 9 replies; 21+ messages in thread
From: Breno Leitao @ 2024-09-03 14:07 UTC (permalink / raw)
  To: kuba, davem, edumazet, pabeni
  Cc: thepacketgeek, horms, netdev, linux-kernel, davej, thevlad, max

The netconsole driver was showing a warning related to userdata
information, depending on the message size being transmitted:

	------------[ cut here ]------------
	WARNING: CPU: 13 PID: 3013042 at drivers/net/netconsole.c:1122 write_ext_msg+0x3b6/0x3d0
	 ? write_ext_msg+0x3b6/0x3d0
	 console_flush_all+0x1e9/0x330
	 ...

Identifying the cause of this warning proved to be non-trivial due to:

 * The write_ext_msg() function being over 100 lines long
 * Extensive use of pointer arithmetic
 * Inconsistent naming conventions and concept application

The send_ext_msg() function grew organically over time:

 * Initially, the UDP packet consisted of a header and body
 * Later additions included release prepend and userdata
 * Naming became inconsistent (e.g., "body" excludes userdata, "header"
   excludes prepended release)

This lack of consistency made investigating issues like the above warning
more challenging than what it should be.

To address these issues, the following steps were taken:

 * Breaking down write_ext_msg() into smaller functions with clear scopes
 * Improving readability and reasoning about the code
 * Simplifying and clarifying naming conventions

Warning Fix
-----------

The warning occurred when there was insufficient buffer space to append
userdata. While this scenario is acceptable (as userdata can be sent in a
separate packet later), the kernel was incorrectly raising a warning.  A
one-line fix has been implemented to resolve this issue.

A self-test was developed to write messages of every possible length
This test will be submitted in a separate patchset

Breno Leitao (9):
  net: netconsole: remove msg_ready variable
  net: netconsole: split send_ext_msg_udp() function
  net: netconsole: separate fragmented message handling in send_ext_msg
  net: netconsole: rename body to msg_body
  net: netconsole: introduce variable to track body length
  net: netconsole: track explicitly if msgbody was written to buffer
  net: netconsole: extract release appending into separate function
  net: netconsole: split send_msg_fragmented
  net: netconsole: fix a wrong warning

 drivers/net/netconsole.c | 207 +++++++++++++++++++++++++--------------
 1 file changed, 134 insertions(+), 73 deletions(-)

-- 
2.43.5


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-09-06  8:48 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 14:07 [PATCH net-next 0/9] netconsole refactoring and warning fix Breno Leitao
2024-09-03 14:07 ` [PATCH net-next 1/9] net: netconsole: remove msg_ready variable Breno Leitao
2024-09-04 10:56   ` Simon Horman
2024-09-03 14:07 ` [PATCH net-next 2/9] net: netconsole: split send_ext_msg_udp() function Breno Leitao
2024-09-04 10:55   ` Simon Horman
2024-09-03 14:07 ` [PATCH net-next 3/9] net: netconsole: separate fragmented message handling in send_ext_msg Breno Leitao
2024-09-04 10:59   ` Simon Horman
2024-09-06  8:33     ` Breno Leitao
2024-09-03 14:07 ` [PATCH net-next 4/9] net: netconsole: rename body to msg_body Breno Leitao
2024-09-04 11:02   ` Simon Horman
2024-09-03 14:07 ` [PATCH net-next 5/9] net: netconsole: introduce variable to track body length Breno Leitao
2024-09-04 11:04   ` Simon Horman
2024-09-03 14:07 ` [PATCH net-next 6/9] net: netconsole: track explicitly if msgbody was written to buffer Breno Leitao
2024-09-04 11:07   ` Simon Horman
2024-09-06  8:37     ` Breno Leitao
2024-09-03 14:07 ` [PATCH net-next 7/9] net: netconsole: extract release appending into separate function Breno Leitao
2024-09-04 11:08   ` Simon Horman
2024-09-03 14:07 ` [PATCH net-next 8/9] net: netconsole: split send_msg_fragmented Breno Leitao
2024-09-04 11:16   ` Simon Horman
2024-09-06  8:48     ` Breno Leitao
2024-09-03 14:07 ` [PATCH net-next 9/9] net: netconsole: Fix a wrong warning Breno Leitao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).