mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@intel.com>
To: linux-kernel@vger.kernel.org, reinette.chatre@intel.com,
	fenghua.yu@intel.com
Cc: ilpo.jarvinen@linux.intel.com
Subject: [PATCH 0/3] selftests/resctrl: Bug fix and optimizations
Date: Thu, 24 Aug 2023 14:41:23 +0200	[thread overview]
Message-ID: <cover.1692880423.git.maciej.wieczor-retman@intel.com> (raw)

Write_schemata() uses fprintf() to write a bitmask into a schemata file
inside resctrl FS. It checks fprintf() return value but it doesn't check
fclose() return value. Error codes from fprintf() such as write errors,
are flushed back to the user only after fclose() is executed which means
any invalid bitmask can be written into the schemata file.

Save fclose() return value so it can be returned at the end of the
function.

Add a perror() call after fprintf() so if any error occurs the error
message is more verbose

Kselftest.h declares many variadic functions that can print some
formatted message while also executing selftest logic. These
declarations don't have any compiler mechanism to verify if passed
arguments are valid in comparison with format specifiers used in
printf() calls.

Add a __printf() macro similiar to other tools in the kernel.

Add __printf() attributes to function definitions inside kselftest.h that
use printing

The resctrlfs.c file defines functions that interact with the resctrl FS
while resctrl_val.c file defines functions that perform measurements on
the cache. Run_benchmark() fits logically into the second file before
resctrl_val() function that uses it.

Move run_benchmark() from resctrlfs.c to resctrl_val.c just before
resctrl_val() function definition.

Series is based on kselftest next branch

Wieczor-Retman, Maciej (3):
  selftests/resctrl: Fix schemata write error check
  selftests/resctrl: Move run_benchmark() to a more fitting file
  selftests: Add printf attribute to ksefltest prints

 tools/testing/selftests/kselftest.h           | 18 +++---
 tools/testing/selftests/resctrl/resctrl_val.c | 52 ++++++++++++++++
 tools/testing/selftests/resctrl/resctrlfs.c   | 60 ++-----------------
 3 files changed, 68 insertions(+), 62 deletions(-)


base-commit: 13eb52f6293dbda02890698d92f3d9913d8d5aeb
-- 
2.42.0


             reply	other threads:[~2023-08-24 12:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 12:41 Wieczor-Retman, Maciej [this message]
2023-08-24 12:41 ` [PATCH 1/3] selftests/resctrl: Fix schemata write error check Wieczor-Retman, Maciej
2023-08-24 12:52   ` Ilpo Järvinen
2023-08-25  6:25     ` Maciej Wieczór-Retman
2023-08-25  8:43       ` Ilpo Järvinen
2023-08-25  8:50         ` Maciej Wieczór-Retman
2023-08-24 12:41 ` [PATCH 2/3] selftests/resctrl: Move run_benchmark() to a more fitting file Wieczor-Retman, Maciej
2023-08-24 12:56   ` Ilpo Järvinen
2023-08-25  6:26     ` Maciej Wieczór-Retman
2023-08-24 12:41 ` [PATCH 3/3] selftests: Add printf attribute to ksefltest prints Wieczor-Retman, Maciej
2023-08-24 13:10   ` Ilpo Järvinen
2023-08-25  6:34     ` Maciej Wieczór-Retman
2023-08-25  8:28       ` Ilpo Järvinen
2023-08-25  9:05         ` Maciej Wieczór-Retman
2023-08-25  9:14           ` Ilpo Järvinen
2023-08-25  9:16             ` Maciej Wieczór-Retman

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.1692880423.git.maciej.wieczor-retman@intel.com \
    --to=maciej.wieczor-retman@intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reinette.chatre@intel.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

all inboxes | Powered by JetHome®