From nobody Sat Sep 17 08:23:08 2022 X-Original-To: dev-commits-src-all@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 4MV3q02F1Rz4bv2n; Sat, 17 Sep 2022 08:23:08 +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 4MV3q01n3Qz3d98; Sat, 17 Sep 2022 08:23:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663402988; 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=Kt0qbTUUebQbywGKKwPGM/sMYT+htjK8wwg6o+Kf0Po=; b=T1Mb7gi95KBy79Dm8gnPG1wTn2qkkB5N1OXJDj5oe9HeGIdgelOBQGZ7G0kjyzMD8fyoS1 r125oPxtL0Xhm00qVMVubFRF0ZRR2GHHTOn913FRFWqNnOOAsDXspUUaRCqWlY9H63CkHg zJ97/xQ7KzMD9J+qI/xqx1+HSILzGqFjZ8MgYWgnEvRlVAjrQYrjH8eYeBUfLKmaFiTqSW V0lzbTTEzxBIWwEoArTNNT99mAlm+nD7S3ZiNnNcYn7y01Yz7G3FPt8cb7b492SEa9lRsk 4Jw6AEetz2SZ2DfC+6qqOj0JkhcJvsDUV/sYt6iEU42eMYfPJHoxzyx3yyzikw== 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 4MV3q00qTmzfNY; Sat, 17 Sep 2022 08:23:08 +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 28H8N8gW021513; Sat, 17 Sep 2022 08:23:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28H8N8YQ021512; Sat, 17 Sep 2022 08:23:08 GMT (envelope-from git) Date: Sat, 17 Sep 2022 08:23:08 GMT Message-Id: <202209170823.28H8N8YQ021512@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: bb239328034e - main - ktrace: make ktr_tid a long not intptr_t (NFC) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb239328034eb4055fd2624cb9de6a105fc629ea Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663402988; 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=Kt0qbTUUebQbywGKKwPGM/sMYT+htjK8wwg6o+Kf0Po=; b=B+rc6e1q8lkMnckfBp7STeGFLCWFmeSafWyCnSsoe5g98E/qZIL0eQSNA6GivYfrLpQFkE ObD23f5HTKuN7GuCtvD6Q33K/hYuXith3XgDcokTlZNZcG8kBvaRE8hR8D3vkaHZ6yMRX6 /+C6ec0g2vKLHWsYlXZMDsg6jrOw4BbAm1QBv/u/UaJ0jjPa6x6qsMJrQgS41HOAdJqAQ4 71oEgIOTFM6mSwRCK7svthkfFNTNlsjvtBL9Oc61CoVqJBt22pDWUP6rlOpBIqOOWRxSyO cqPrzCuoSqqpePgawA/IHjEXq7AbPKgOmHFTk19x/Xe2h/FDSUQNPSVPRj+zwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663402988; a=rsa-sha256; cv=none; b=jvPCVx2VecI1huKN8kI2uzx6wjStQQLrGpZzlYpo6NbAXZigMHtm2tiJ/wMGkStahmQJ9Q STRPFoPK4TjcgrHRy9niMSEvCGqOV0zEprjlERnkUyLQUXDajRBSbbDM2aZkEdyOR42WKm uQMRjGOFdIhzZ+u3gyv1igvTmn//lTM0dACqwElegD8sSxaKu8rD4vBaEkGcrg7tU2MO+i AcWOOIBtYPHGRA19elFGzXrp4uLDRnrgcl0SAakxGydT+K/td+LigA3DntIey6Zs2VcFMu wMf8mWuhr1Oq5Gto2XCOojsvgg4N0+jvAljsVoddzAktsZQxPWG+q2F+Ar1cwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=bb239328034eb4055fd2624cb9de6a105fc629ea commit bb239328034eb4055fd2624cb9de6a105fc629ea Author: Brooks Davis AuthorDate: 2022-09-17 08:21:32 +0000 Commit: Brooks Davis CommitDate: 2022-09-17 08:21:59 +0000 ktrace: make ktr_tid a long not intptr_t (NFC) Long ago, ktr_tid was ktr_buffer which pointed to the buffer following the header and was used internally in the kernel. Use was removed in efbbbf570d70b and it was repurposed as ktr_kid in c6854c347f4d8. For ABI reasons, it stayed an intptr_t rather than becoming an lwpid_t at the time. Since it doesn't hold a pointer any more (unless you have a ktrace.out from 2005), change the type to long which is alwasy the same size on all supported architectures. Add a suggestion to change the type to lwpid_t (__int32_t) on a future ABI break. Remove most remaining references to ktr_buffer, retaing a comment in kdump.c explaining why negative values are treated as 0. While here, accept that pid_t and lwpid_t are of type int and simplify casts in printf. This changed was motivated by CheriBSD where intptr_t is 16-bytes in the pure-capability ABI. Reviewed by: kib, markj Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D36599 --- lib/libc/sys/ktrace.2 | 2 +- sys/sys/ktrace.h | 5 +++-- usr.bin/kdump/kdump.c | 17 ++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2 index ffe967e35ed8..543f6f6ebba2 100644 --- a/lib/libc/sys/ktrace.2 +++ b/lib/libc/sys/ktrace.2 @@ -109,7 +109,7 @@ struct ktr_header { pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN+1]; /* command name */ struct timeval ktr_time; /* timestamp */ - intptr_t ktr_tid; /* was ktr_buffer */ + long ktr_tid; /* thread id */ }; .Ed .Pp diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index ed5c6c11eaf2..ae6d0ed5d361 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -58,7 +58,7 @@ struct ktr_header_v0 { pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN + 1];/* command name */ struct timeval ktr_time; /* timestamp */ - intptr_t ktr_tid; /* was ktr_buffer */ + long ktr_tid; /* thread id */ }; struct ktr_header { @@ -68,7 +68,8 @@ struct ktr_header { pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN + 1];/* command name */ struct timespec ktr_time; /* timestamp */ - intptr_t ktr_tid; /* thread id */ + /* XXX: make ktr_tid an lwpid_t on next ABI break */ + long ktr_tid; /* thread id */ int ktr_cpu; /* cpu id */ }; diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 75fb5bd8c1d3..bff2920c6aa5 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -449,15 +449,15 @@ main(int argc, char *argv[]) ktr_header.ktr_type &= ~KTR_DROP; if (!drop_logged && threads) { printf( - "%6jd %6jd %-8.*s Events dropped.\n", - (intmax_t)ktr_header.ktr_pid, + "%6d %6d %-8.*s Events dropped.\n", + ktr_header.ktr_pid, ktr_header.ktr_tid > 0 ? - (intmax_t)ktr_header.ktr_tid : 0, + (lwpid_t)ktr_header.ktr_tid : 0, MAXCOMLEN, ktr_header.ktr_comm); drop_logged = 1; } else if (!drop_logged) { - printf("%6jd %-8.*s Events dropped.\n", - (intmax_t)ktr_header.ktr_pid, MAXCOMLEN, + printf("%6d %-8.*s Events dropped.\n", + ktr_header.ktr_pid, MAXCOMLEN, ktr_header.ktr_comm); drop_logged = 1; } @@ -724,12 +724,11 @@ dumpheader(struct ktr_header *kth, u_int sv_flags) * negative tid's as 0. */ if (threads) - printf("%6jd %6jd %-8.*s ", (intmax_t)kth->ktr_pid, - kth->ktr_tid > 0 ? (intmax_t)kth->ktr_tid : 0, + printf("%6d %6d %-8.*s ", kth->ktr_pid, + kth->ktr_tid > 0 ? (lwpid_t)kth->ktr_tid : 0, MAXCOMLEN, kth->ktr_comm); else - printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN, - kth->ktr_comm); + printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN, kth->ktr_comm); if (timestamp) { if (version == KTR_VERSION0) dumptimeval((struct ktr_header_v0 *)kth);