kernel: Rewrite B_DEBUG_SPINLOCK_CONTENTION.

* Replace count_low/count_high with bigtime_t fields plus an int32.
   sizeof(spinlock) is now 32 bytes with the debug option enabled.

 * Adjust and clean up all spinlock code to use the new fields.

 * Fold DEBUG_SPINLOCK_LATENCIES into the new code. Remove the bootloader
   option and other flags for it (these were not compiled in by default.)

The new code should be much easier to understand and also more powerful.
However, the information transmitted to userland isn't as useful now;
the KDL command output will have the interesting information.

(Things could be reworked to transmit more interesting information to
userland again if desired, but as this code clearly hadn't been compiled
for many years, as it referred to global spinlocks that have been gone
for a very long time.)

Change-Id: I2cb34078bfdc7604f288a297b6cd1aa7ff9cc512
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6943
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Augustin Cavalier
2023-09-23 18:41:04 +00:00
committed by waddlesplash
parent ef9e2f627b
commit 76681bd900
7 changed files with 112 additions and 158 deletions
+9 -5
View File
@@ -21,15 +21,19 @@ typedef ulong cpu_status;
#if B_DEBUG_SPINLOCK_CONTENTION
typedef struct {
int32 lock;
int32 count_low;
int32 count_high;
int32 failed_try_acquire;
bigtime_t total_wait;
bigtime_t total_held;
bigtime_t last_acquired;
} spinlock;
# define B_SPINLOCK_INITIALIZER { 0, 0, 0 }
# define B_SPINLOCK_INITIALIZER { 0, 0, 0, 0, 0 }
# define B_INITIALIZE_SPINLOCK(spinlock) do { \
(spinlock)->lock = 0; \
(spinlock)->count_low = 0; \
(spinlock)->count_high = 0; \
(spinlock)->failed_try_acquire = 0; \
(spinlock)->total_wait = 0; \
(spinlock)->total_held = 0; \
(spinlock)->last_acquired = 0; \
} while (false)
#else
typedef struct {
-3
View File
@@ -20,8 +20,5 @@
#define B_SAFEMODE_4_GB_MEMORY_LIMIT "4gb_memory_limit"
#define B_SAFEMODE_256_TB_MEMORY_LIMIT "256tb_memory_limit"
#if DEBUG_SPINLOCK_LATENCIES
# define B_SAFEMODE_DISABLE_LATENCY_CHECK "disable_latency_check"
#endif
#endif /* _SYSTEM_SAFEMODE_DEFS_H */
+1 -2
View File
@@ -13,8 +13,7 @@
typedef struct spinlock_contention_info {
uint64 thread_spinlock_counter;
uint64 team_spinlock_counter;
bigtime_t thread_creation_spinlock;
} spinlock_contention_info;