linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@intel.com>
To: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org, fenghua.yu@intel.com,
	reinette.chatre@intel.com
Cc: ilpo.jarvinen@linux.intel.com
Subject: [PATCH v2 0/2] selftests/resctrl: Bug fix and optimizations
Date: Mon, 28 Aug 2023 11:56:06 +0200	[thread overview]
Message-ID: <cover.1693213468.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.

Rewrite write_schemata() to use syscalls instead of stdio functions to
interact with the schemata file.

Change sprintf() to snprintf() in write_schemata().

In case of write() returning an error pass the string acquired with
strerror() to the "reason" buffer.

Extend "reason" buffer by a factor of two so it can hold longer error
messages.

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.

Changelog v2:
- Change sprintf() to snprintf() in write_schemata().
- Redo write_schemata() with syscalls instead of stdio functions.
- Fix typos and missing dots in patch messages.
- Branch printf attribute patch to a separate series.

[v1] https://lore.kernel.org/all/cover.1692880423.git.maciej.wieczor-retman@intel.com/

Wieczor-Retman, Maciej (2):
  selftests/resctrl: Fix schemata write error check
  selftests/resctrl: Move run_benchmark() to a more fitting file

 tools/testing/selftests/resctrl/resctrl_val.c | 50 ++++++++++++
 tools/testing/selftests/resctrl/resctrlfs.c   | 76 ++++---------------
 2 files changed, 63 insertions(+), 63 deletions(-)


base-commit: 13eb52f6293dbda02890698d92f3d9913d8d5aeb
-- 
2.42.0


             reply	other threads:[~2023-08-28  9:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28  9:56 Wieczor-Retman, Maciej [this message]
2023-08-28  9:56 ` [PATCH v2 1/2] selftests/resctrl: Fix schemata write error check Wieczor-Retman, Maciej
2023-08-28 10:43   ` Ilpo Järvinen
2023-08-28 12:55     ` Maciej Wieczór-Retman
2023-08-30 20:49   ` Reinette Chatre
2023-08-31  8:06     ` Maciej Wieczór-Retman
2023-08-28  9:56 ` [PATCH v2 2/2] selftests/resctrl: Move run_benchmark() to a more fitting file Wieczor-Retman, Maciej
2023-08-28 10:47   ` Ilpo Järvinen
2023-08-30 20:51   ` Reinette Chatre
2023-08-31  8:43     ` 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.1693213468.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=linux-kselftest@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=shuah@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).