[LTP] [PATCH v2 0/2] Fix Integer Overflow and Thread Safety in Record Counting
Vishal Chourasia
vishalc@linux.ibm.com
Tue Aug 15 11:30:46 CEST 2023
I am writing to present a patch set that addresses a significant issue we've
observed in our 64-bit systems. We noticed an integer overflow bug affecting our
results, which has prompted this set of changes.
Key Changes:
- Type Selection for Record Counting: We've shifted from using `unsigned int` to
`uintptr_t` for tracking record counts. This is crucial, especially on 64-bit
systems, to avoid potential integer overflows that can jeopardize the accuracy
of our results.
- Thread Safety for Record Counting: Previously, the design used a global
`records_read` variable to accumulate counts from different threads. This
approach didn't employ locks, posing potential race conditions. In this patch,
we've rectified this by introducing a thread-local variable, `records_thread`,
to individually store the record count of each thread. The accumulated total
is then fetched safely during thread joining.
Rationale:
These changes stem from our observations on certain 64-bit systems. The integer
overflow bug, combined with potential race conditions due to the unguarded
global variable, was impacting the integrity of our results. By switching to
`uintptr_t`, we ensure adequate space to hold larger counts typical for 64-bit
systems. Additionally, by introducing the thread-local variable and removing the
global counter, we've added a level of safety against concurrent access issues.
This patch set ensures the robustness and accuracy of our system, particularly
in multi-threaded environments on 64-bit platforms.
Thank you for your time and consideration. I am open to any feedback and will
gladly make any necessary modifications.
Changes in v2:
- Replaced mutex synchronization for global records_read updates with inherent
serialization offered by pthread_join.
- Link to v1: https://lore.kernel.org/all/20230814061810.2297146-1-vishalc@linux.ibm.com/
Vishal Chourasia (2):
Enhance Thread Safety in Record Counting
ebizzy: prevent integer overflow in 64-bit systems
utils/benchmark/ebizzy-0.3/ebizzy.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
--
2.39.3
More information about the ltp
mailing list