Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, John Garry <john.g.garry@oracle.com>,
	Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH v2 0/2] scsi: core: Optimize the SCSI printk() variants
Date: Mon, 31 Aug 2026 10:58:17 -0700	[thread overview]
Message-ID: <cover.1788198780.git.bvanassche@acm.org> (raw)

Hi Martin,

The SCSI logging functions currently allocate a temporary 128-byte
buffer via kmalloc(..., GFP_ATOMIC). This design has several drawbacks:
 - Runtime memory allocation and freeing overhead on logging paths.
 - Truncation of log messages to 127 characters.
 - Discarded log messages if the buffer allocation fails under memory
   pressure.

This patch series eliminates temporary buffer allocations from
scsi_logging.c by formatting messages directly using struct va_format
(%pV) and dev_printk(), as well as formatting hex buffers directly
with %*ph.

To ensure formatting and logging behavior remain free of regressions,
the first patch introduces a comprehensive KUnit test suite for the
SCSI logging functions. The second patch refactors scsi_logging.c to use
the direct formatting helpers.

Please consider applying this series.

Thanks,

Bart.

Changes compared to v1:
 - Expanded a single patch into a series of two patches by adding a
   patch with unit tests.
 - Restored a newline in a format string that was missing from v1.

Bart Van Assche (2):
  scsi: core: Add KUnit tests for scsi_logging.c
  scsi: core: Eliminate scsi_log_{reserve,release}_buffer()

 drivers/scsi/Kconfig             |   9 +
 drivers/scsi/scsi_logging.c      | 285 +++++++++------------
 drivers/scsi/scsi_logging_test.c | 422 +++++++++++++++++++++++++++++++
 3 files changed, 547 insertions(+), 169 deletions(-)
 create mode 100644 drivers/scsi/scsi_logging_test.c


             reply	other threads:[~2026-08-31 17:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 17:58 Bart Van Assche [this message]
2026-08-31 17:58 ` [PATCH v2 1/2] scsi: core: Add KUnit tests for scsi_logging.c Bart Van Assche
2026-08-31 20:05   ` sashiko-bot
2026-08-31 17:58 ` [PATCH v2 2/2] scsi: core: Eliminate scsi_log_{reserve,release}_buffer() Bart Van Assche

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=cover.1788198780.git.bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=john.g.garry@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox