git: 9a19595cad92 - main - proc: s/short/int lock-related counters
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 May 2023 20:11:20 UTC
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9a19595cad9247902fbdadbb2b8fe61bb3a1dab1 commit 9a19595cad9247902fbdadbb2b8fe61bb3a1dab1 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2023-05-18 19:45:33 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2023-05-18 19:57:38 +0000 proc: s/short/int lock-related counters short is small enough that it can overflow in practice for certain cases and then trigger wrong asserts. One known example is vfs namecache resize which grabs all locks at once. Reported by: gallatin Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/kern_thread.c | 6 +++--- sys/sys/proc.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 283606bf4a8b..b62bfafa58be 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -89,7 +89,7 @@ _Static_assert(offsetof(struct thread, td_flags) == 0x108, "struct thread KBI td_flags"); _Static_assert(offsetof(struct thread, td_pflags) == 0x114, "struct thread KBI td_pflags"); -_Static_assert(offsetof(struct thread, td_frame) == 0x4b0, +_Static_assert(offsetof(struct thread, td_frame) == 0x4b8, "struct thread KBI td_frame"); _Static_assert(offsetof(struct thread, td_emuldata) == 0x6c0, "struct thread KBI td_emuldata"); @@ -109,9 +109,9 @@ _Static_assert(offsetof(struct thread, td_flags) == 0x9c, "struct thread KBI td_flags"); _Static_assert(offsetof(struct thread, td_pflags) == 0xa8, "struct thread KBI td_pflags"); -_Static_assert(offsetof(struct thread, td_frame) == 0x30c, +_Static_assert(offsetof(struct thread, td_frame) == 0x314, "struct thread KBI td_frame"); -_Static_assert(offsetof(struct thread, td_emuldata) == 0x350, +_Static_assert(offsetof(struct thread, td_emuldata) == 0x358, "struct thread KBI td_emuldata"); _Static_assert(offsetof(struct proc, p_flag) == 0x6c, "struct proc KBI p_flag"); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 54d586b06525..6af221db056f 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -272,10 +272,10 @@ struct thread { volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */ u_char td_tsqueue; /* (t) Turnstile queue blocked on. */ u_char td_stopsched; /* (k) Scheduler stopped. */ - short td_locks; /* (k) Debug: count of non-spin locks */ - short td_rw_rlocks; /* (k) Count of rwlock read locks. */ - short td_sx_slocks; /* (k) Count of sx shared locks. */ - short td_lk_slocks; /* (k) Count of lockmgr shared locks. */ + int td_locks; /* (k) Debug: count of non-spin locks */ + int td_rw_rlocks; /* (k) Count of rwlock read locks. */ + int td_sx_slocks; /* (k) Count of sx shared locks. */ + int td_lk_slocks; /* (k) Count of lockmgr shared locks. */ struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */ const char *td_lockname; /* (t) Name of lock blocked on. */ LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */