Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Dec 2021 18:19:38 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: eb1ad1b3b93e - stable/12 - arm64, powerpc: fix calculation of 'used' in GET_STACK_USAGE
Message-ID:  <202112071819.1B7IJcre048453@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by mhorne:

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

commit eb1ad1b3b93ece25a049ce8efe73bc6caff1fd3d
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-11-30 15:15:44 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-12-07 18:15:58 +0000

    arm64, powerpc: fix calculation of 'used' in GET_STACK_USAGE
    
    We do not consider the space reserved for the pcb to be part of the
    total kstack size, so it should not be included in the calculation of
    the used stack size.
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit b02908b051c897117ebbc3dcb55848383b17c435)
---
 sys/arm64/include/proc.h   | 4 +---
 sys/powerpc/include/proc.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/arm64/include/proc.h b/sys/arm64/include/proc.h
index 52d60b00dcfb..2dcd3760714d 100644
--- a/sys/arm64/include/proc.h
+++ b/sys/arm64/include/proc.h
@@ -61,9 +61,7 @@ struct syscall_args {
 #define	GET_STACK_USAGE(total, used) do {				\
 	struct thread *td = curthread;					\
 	(total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb);	\
-	(used) = (char *)td->td_kstack +				\
-	    td->td_kstack_pages * PAGE_SIZE -				\
-	    (char *)&td;						\
+	(used) = td->td_kstack + (total) - (vm_offset_t)&td;		\
 } while (0)
 
 #endif
diff --git a/sys/powerpc/include/proc.h b/sys/powerpc/include/proc.h
index d01b6cda4dcd..c86d935f471b 100644
--- a/sys/powerpc/include/proc.h
+++ b/sys/powerpc/include/proc.h
@@ -70,9 +70,7 @@ struct syscall_args {
 #define	GET_STACK_USAGE(total, used) do {				\
 	struct thread *td = curthread;					\
 	(total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb);	\
-	(used) = (char *)td->td_kstack +				\
-	    td->td_kstack_pages * PAGE_SIZE -				\
-	    (char *)&td;						\
+	(used) = td->td_kstack + (total) - (vm_offset_t)&td;		\
 } while (0)
 #endif
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112071819.1B7IJcre048453>