public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] Fix Integer Overflow and Thread Safety in Record Counting
@ 2023-08-15  9:30 Vishal Chourasia
  2023-08-15  9:30 ` [LTP] [PATCH v2 1/2] Enhance " Vishal Chourasia
  2023-08-15  9:30 ` [LTP] [PATCH v2 2/2] ebizzy: prevent integer overflow in 64-bit systems Vishal Chourasia
  0 siblings, 2 replies; 10+ messages in thread
From: Vishal Chourasia @ 2023-08-15  9:30 UTC (permalink / raw)
  To: ltp, chris, chrubis, gaowanlong, pvorel, raj.khem, tdavies
  Cc: Vishal Chourasia

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2023-09-07 10:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-15  9:30 [LTP] [PATCH v2 0/2] Fix Integer Overflow and Thread Safety in Record Counting Vishal Chourasia
2023-08-15  9:30 ` [LTP] [PATCH v2 1/2] Enhance " Vishal Chourasia
2023-08-21 12:30   ` Cyril Hrubis
2023-08-15  9:30 ` [LTP] [PATCH v2 2/2] ebizzy: prevent integer overflow in 64-bit systems Vishal Chourasia
2023-08-21 13:24   ` Cyril Hrubis
2023-08-29  9:37     ` Vishal Chourasia
2023-08-29 10:03     ` Vishal Chourasia
2023-08-29 10:13       ` [LTP] [PATCH v3] " Vishal Chourasia
2023-09-06  8:51         ` Cyril Hrubis
2023-09-07 10:42           ` Richard Palethorpe

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