From nobody Tue Nov 30 15:16:17 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BDC3B18B659B; Tue, 30 Nov 2021 15:16:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3Qm21ZDJz3J5Q; Tue, 30 Nov 2021 15:16:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0F34E185D6; Tue, 30 Nov 2021 15:16:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AUFGH3e048210; Tue, 30 Nov 2021 15:16:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AUFGHQw048209; Tue, 30 Nov 2021 15:16:17 GMT (envelope-from git) Date: Tue, 30 Nov 2021 15:16:17 GMT Message-Id: <202111301516.1AUFGHQw048209@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 8bc792b3845e - main - i386: take pcb and fpu area into account in GET_STACK_USAGE List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8bc792b3845ecf64145fda7964a7b5cc54dea777 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638285378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=urA1qLyuf+d7u5z1HDDu3Zp6f2R7zPuWQTRfCgOyHCU=; b=DR+ESbSjZUMgZgCY/0fEyMVFiGoH/YSmh4yeHByqjSQBqg6xSn5qG5eWsbgw/w8nB7XxEK GbMMFA0iZpttV+7xfyXFCAATEnjKKKmusZUYNTtqJLh3Mupt3yjQ0NYWDF/hp49uGzReeG fMHvAuY+NIsQwzM3DCh3CDSVzeTJ99xUEQ6Ti6XABijR88sMTnY9SObW9345RkuRH8PA+m iYqGRFCGaP7ceKgakL65N4LpLLxO5hvgFLZgkgJla4I1je5RwR3FjeOJN4jojhS9TLzAD7 j54T50Dt/H3sAQBhkqNixXUkfXewKHSRUTNJtRpPxQaGiViup/AnJ7wxYavN5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638285378; a=rsa-sha256; cv=none; b=p6rPfsMFqubX2Mpmg4cTuX+0rXIMXkyJlGqNqcRW5G7zK9EcnHXOuzRKOREIySigXmbiir gnFsNnAT0m7YsqXw1RS1UZMObz2VXRVOvu+ZcfFcOeEEmntdVf7Q2kyaekobnI6USuk50t Ae+uYulJNgl9YH39kbt/aC3EwDSq+sMEt9+YauDvOEvuhOtVA0rvbITDIJOPnBVCUd26AJ H/BrqWO2yQZ/poAxEptaRXu/EQImw8sHMNe1AYKNu52etITbZYJws3bvtd5Z00vR0YKtxa k+puJ/44U7XfwHbCnCAc2l05WEQOG1L47lQeKWmQTE/5r8e5MjI7UkG3F2Z4rg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8bc792b3845ecf64145fda7964a7b5cc54dea777 commit 8bc792b3845ecf64145fda7964a7b5cc54dea777 Author: Mitchell Horne AuthorDate: 2021-11-25 15:54:33 +0000 Commit: Mitchell Horne CommitDate: 2021-11-30 15:03:46 +0000 i386: take pcb and fpu area into account in GET_STACK_USAGE On this platform, the pcb and FPU save area are allocated from the top of each kernel stack, so they should be excluded from the calculation of the total and used stack sizes. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32581 --- sys/i386/include/proc.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/i386/include/proc.h b/sys/i386/include/proc.h index 76e1ac611474..26149a6640cd 100644 --- a/sys/i386/include/proc.h +++ b/sys/i386/include/proc.h @@ -71,13 +71,13 @@ struct syscall_args { #ifdef _KERNEL +#include + /* 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; \ - (used) = (char *)td->td_kstack + \ - td->td_kstack_pages * PAGE_SIZE - \ - (char *)&td; \ + (total) = (vm_offset_t)get_pcb_td(td) - td->td_kstack; \ + (used) = (vm_offset_t)get_pcb_td(td) - (vm_offset_t)&td; \ } while (0) void set_user_ldt(struct mdproc *);