linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND v3 0/2] selftests/resctrl: Bug fix and optimization
@ 2023-09-01 13:41 Wieczor-Retman Maciej
  2023-09-01 13:42 ` [PATCH RESEND v3 1/2] selftests/resctrl: Fix schemata write error check Wieczor-Retman Maciej
  2023-09-01 13:42 ` [PATCH RESEND v3 2/2] selftests/resctrl: Move run_benchmark() to a more fitting file Wieczor-Retman Maciej
  0 siblings, 2 replies; 13+ messages in thread
From: Wieczor-Retman Maciej @ 2023-09-01 13:41 UTC (permalink / raw)
  To: shuah, fenghua.yu, reinette.chatre
  Cc: ilpo.jarvinen, linux-kernel, linux-kselftest

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 buffered and 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 file
operations to avoid the buffering.

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 and remove
redundant part of the kernel-doc comment. Make run_benchmark() static
and remove it from the header file.

Series is based on kselftest next branch.

Changelog v3:
- Use snprintf() return value instead of strlen() in write_schemata().
  (Ilpo)
- Make run_benchmark() static and remove it from the header file.
  (Reinette)
- Added Ilpo's reviewed-by tag to Patch 2/2.
- Patch messages and cover letter rewording.

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/
[v2] https://lore.kernel.org/all/cover.1693213468.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.h     |  1 -
 tools/testing/selftests/resctrl/resctrl_val.c | 50 ++++++++++++
 tools/testing/selftests/resctrl/resctrlfs.c   | 78 ++++---------------
 3 files changed, 64 insertions(+), 65 deletions(-)


base-commit: 9b1db732866bee060b9bca9493e5ebf5e8874c48
-- 
2.42.0


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

end of thread, other threads:[~2023-09-15  8:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-01 13:41 [PATCH RESEND v3 0/2] selftests/resctrl: Bug fix and optimization Wieczor-Retman Maciej
2023-09-01 13:42 ` [PATCH RESEND v3 1/2] selftests/resctrl: Fix schemata write error check Wieczor-Retman Maciej
2023-09-11 16:59   ` Reinette Chatre
2023-09-12  6:32     ` Maciej Wieczór-Retman
2023-09-12 16:00       ` Reinette Chatre
2023-09-13  5:59         ` Maciej Wieczór-Retman
2023-09-13 18:49           ` Reinette Chatre
2023-09-14  6:01             ` Maciej Wieczór-Retman
2023-09-14 15:14               ` Reinette Chatre
2023-09-15  8:16                 ` Maciej Wieczór-Retman
2023-09-01 13:42 ` [PATCH RESEND v3 2/2] selftests/resctrl: Move run_benchmark() to a more fitting file Wieczor-Retman Maciej
2023-09-11 16:59   ` Reinette Chatre
2023-09-12  6:34     ` Maciej Wieczór-Retman

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).