The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=dcae0f7d7aa67ed6ec6b8da5e1b444a828898595

commit dcae0f7d7aa67ed6ec6b8da5e1b444a828898595
Author:     John Baldwin <[email protected]>
AuthorDate: 2026-04-27 19:05:54 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2026-05-27 13:45:26 +0000

    sys: Consistently use ptoa() with td_kstack_pages
    
    Suggested by:   kib
    Reviewed by:    kib, andrew (arm changes)
    Sponsored by:   AFRL, DARPA
    Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/23
---
 sys/amd64/amd64/machdep.c   | 2 +-
 sys/amd64/include/stack.h   | 2 +-
 sys/arm/include/stack.h     | 2 +-
 sys/arm64/include/stack.h   | 2 +-
 sys/powerpc/include/stack.h | 2 +-
 sys/riscv/include/stack.h   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 510c6d375a2d..dbad85096a1d 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1367,7 +1367,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
 
        thread0.td_kstack = (char *)physfree - kernphys + KERNSTART;
        thread0.td_kstack_pages = kstack_pages;
-       kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE;
+       kstack0_sz = ptoa(kstack_pages);
        bzero(thread0.td_kstack, kstack0_sz);
        cpu_thread_new_kstack(&thread0);
        physfree += kstack0_sz;
diff --git a/sys/amd64/include/stack.h b/sys/amd64/include/stack.h
index 765a8e78daed..7d821348be0e 100644
--- a/sys/amd64/include/stack.h
+++ b/sys/amd64/include/stack.h
@@ -12,7 +12,7 @@
 /* Get the current kernel thread stack usage. */
 #define GET_STACK_USAGE(total, used) do {                              \
        struct thread   *td = curthread;                                \
-       (total) = td->td_kstack_pages * PAGE_SIZE;                      \
+       (total) = ptoa(td->td_kstack_pages);                            \
        (used) = td_kstack_top(td) - (char *)&td;                       \
 } while (0)
 
diff --git a/sys/arm/include/stack.h b/sys/arm/include/stack.h
index 6af9418aba42..f6bc67dbe771 100644
--- a/sys/arm/include/stack.h
+++ b/sys/arm/include/stack.h
@@ -68,7 +68,7 @@ void unwind_module_unloaded(struct linker_file *);
 /* Get the current kernel thread stack usage. */
 #define        GET_STACK_USAGE(total, used) do {                               
\
        struct thread *td = curthread;                                  \
-       (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+       (total) = ptoa(td->td_kstack_pages) - sizeof(struct pcb);       \
        (used) = td->td_kstack + (total) - (char *)&td;                 \
 } while (0)
 
diff --git a/sys/arm64/include/stack.h b/sys/arm64/include/stack.h
index b89019fbbec6..0aa483e15e64 100644
--- a/sys/arm64/include/stack.h
+++ b/sys/arm64/include/stack.h
@@ -43,7 +43,7 @@ bool unwind_frame(struct thread *, struct unwind_state *);
 
 #define        GET_STACK_USAGE(total, used) do {                               
\
        struct thread *td = curthread;                                  \
-       (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+       (total) = ptoa(td->td_kstack_pages) - sizeof(struct pcb);       \
        (used) = td->td_kstack + (total) - (char *)&td;                 \
 } while (0)
 
diff --git a/sys/powerpc/include/stack.h b/sys/powerpc/include/stack.h
index 0fb9a929128b..533ff0fa2056 100644
--- a/sys/powerpc/include/stack.h
+++ b/sys/powerpc/include/stack.h
@@ -38,7 +38,7 @@ extern int end[];
 /* Get the current kernel thread stack usage. */
 #define        GET_STACK_USAGE(total, used) do {                               
\
        struct thread *td = curthread;                                  \
-       (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+       (total) = ptoa(td->td_kstack_pages) - sizeof(struct pcb);       \
        (used) = td->td_kstack + (total) - (char *)&td;                 \
 } while (0)
 
diff --git a/sys/riscv/include/stack.h b/sys/riscv/include/stack.h
index 7de9f05b567b..5669dcda6c67 100644
--- a/sys/riscv/include/stack.h
+++ b/sys/riscv/include/stack.h
@@ -53,7 +53,7 @@ bool unwind_frame(struct thread *, struct unwind_state *);
 /* Get the current kernel thread stack usage. */
 #define        GET_STACK_USAGE(total, used) do {                               
\
        struct thread *td = curthread;                                  \
-       (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+       (total) = ptoa(td->td_kstack_pages) - sizeof(struct pcb);       \
        (used) = td->td_kstack + (total) - (char *)&td;                 \
 } while (0)
 

Reply via email to