Skip to content

selftests/resctrl: Bug fix and optimization

Maciej Wieczor-Retman linux-kselftest lkml 10 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest posting 2/22 patches 0 repliesNew
  2. v7 posting 1/22 patches 0 repliesSuperseded
  3. v62 patches 2 repliesSuperseded
Earlier versions · 7
VersionPostedPatchesRepliesStatus
v52 patches2 repliesSuperseded
v42 patches7 repliesSuperseded
v3 posting 3/32 patches10 repliesSuperseded
v3 posting 2/32 patches0 repliesSuperseded
v3 posting 1/30 of 2 patches0 repliesSuperseded
v22 patches7 repliesSuperseded
v13 patches12 repliesSuperseded

Changes in v7 from the cover letter

- Add label for non-empty schema error case to Patch 1/2. (Reinette)
- Add Reinette's reviewed-by tag to Patch 1/2.

Patches in v7 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2selftests/resctrl: Fix schemata write error checktools/testing/selftests/resctrl/resctrlfs.c+26 -150 replies
2/2selftests/resctrl: Move run_benchmark() to a more fitting filetools/testing/selftests/resctrl/resctrl.h tools/testing/selftests/resctrl/resctrl_val.c tools/testing/selftests/resctrl/resctrlfs.c+50 -530 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchIlpo JärvinenReinette Chatre
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH RESEND v7 0/2] selftests/resctrl: Bug fix and optimization

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 defines functions that interact with the resctrl FS while resctrl_val.c defines functions that perform measurements on the cache. Run_benchmark() fits logically into the second file before resctrl_val() 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.

Patch series is based on [1] which is based on [2] which are based on kselftest next branch.

Resend v7:
- Resending because I forgot to add the base commit.

Changelog v7:
- Add label for non-empty schema error case to Patch 1/2. (Reinette)
- Add Reinette's reviewed-by tag to Patch 1/2.

Changelog v6:
- Align schema_len error checking with typical snprintf format. (Reinette)
- Initialize schema string for early return eventuality. (Reinette)

Changelog v5:
- Add Ilpo's reviewed-by tag to Patch 1/2.
- Reword patch messages slightly.
- Add error check to schema_len variable.

Changelog v4:
- Change git signature from Wieczor-Retman Maciej to Maciej Wieczor-Retman.
- Rebase onto [1] which is based on [2]. (Reinette)
- Add fcntl.h explicitly to provide glibc backward compatibility. (Reinette)

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)
- Add 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/[email protected]/
[v2] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/all/[email protected]/
[v4] https://lore.kernel.org/all/[email protected]/
[v5] https://lore.kernel.org/all/[email protected]/
[v6] https://lore.kernel.org/all/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Maciej Wieczor-Retman (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   | 93 ++++++-------------
 3 files changed, 76 insertions(+), 68 deletions(-)

base-commit: f3d3a8b5cf771ed2c6692a457dbc17f389f97f53

Signature · 1 line
2.42.0