public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] selftests/resctrl: Bug fix and optimizations
@ 2023-08-24 12:41 Wieczor-Retman, Maciej
  2023-08-24 12:41 ` [PATCH 1/3] selftests/resctrl: Fix schemata write error check Wieczor-Retman, Maciej
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Wieczor-Retman, Maciej @ 2023-08-24 12:41 UTC (permalink / raw)
  To: linux-kernel, reinette.chatre, fenghua.yu; +Cc: ilpo.jarvinen

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


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

end of thread, other threads:[~2023-08-25  9:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 12:41 [PATCH 0/3] selftests/resctrl: Bug fix and optimizations Wieczor-Retman, Maciej
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox