From owner-dev-commits-src-main@freebsd.org Fri Jan 1 00:03:59 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DA65D4D5912; Fri, 1 Jan 2021 00:03:59 +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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D6QH35qVSz4ZTd; Fri, 1 Jan 2021 00:03:59 +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 BB5311935F; Fri, 1 Jan 2021 00:03:59 +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 10103x5I093714; Fri, 1 Jan 2021 00:03:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10103xVT093713; Fri, 1 Jan 2021 00:03:59 GMT (envelope-from git) Date: Fri, 1 Jan 2021 00:03:59 GMT Message-Id: <202101010003.10103xVT093713@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 3e06c7da020f - main - Use kdb_thr_* to iterate over threads consistently in DDB. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e06c7da020fadb8ffbfc26d634ccb321e7e22f7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jan 2021 00:03:59 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3e06c7da020fadb8ffbfc26d634ccb321e7e22f7 commit 3e06c7da020fadb8ffbfc26d634ccb321e7e22f7 Author: John Baldwin AuthorDate: 2021-01-01 00:01:35 +0000 Commit: John Baldwin CommitDate: 2021-01-01 00:01:35 +0000 Use kdb_thr_* to iterate over threads consistently in DDB. The "findstack", "show all trace", and "show active trace" commands were iterating over allproc to enumerate threads. This missed threads executing in exit1() after being removed from allproc. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27829 --- sys/ddb/db_command.c | 37 ++++++++++++++++++------------------- sys/ddb/db_ps.c | 11 ++++------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 1fa1cd1b7bb9..21ff75f78e6a 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -847,32 +847,31 @@ db_stack_trace(db_expr_t tid, bool hastid, db_expr_t count, char *modif) static void _db_stack_trace_all(bool active_only) { - struct proc *p; struct thread *td; jmp_buf jb; void *prev_jb; - FOREACH_PROC_IN_SYSTEM(p) { + for (td = kdb_thr_first(); td != NULL; td = kdb_thr_next(td)) { prev_jb = kdb_jmpbuf(jb); if (setjmp(jb) == 0) { - FOREACH_THREAD_IN_PROC(p, td) { - if (td->td_state == TDS_RUNNING) - db_printf("\nTracing command %s pid %d" - " tid %ld td %p (CPU %d)\n", - p->p_comm, p->p_pid, - (long)td->td_tid, td, - td->td_oncpu); - else if (active_only) - continue; - else - db_printf("\nTracing command %s pid %d" - " tid %ld td %p\n", p->p_comm, - p->p_pid, (long)td->td_tid, td); + if (td->td_state == TDS_RUNNING) + db_printf("\nTracing command %s pid %d" + " tid %ld td %p (CPU %d)\n", + td->td_proc->p_comm, td->td_proc->p_pid, + (long)td->td_tid, td, td->td_oncpu); + else if (active_only) + continue; + else + db_printf("\nTracing command %s pid %d" + " tid %ld td %p\n", td->td_proc->p_comm, + td->td_proc->p_pid, (long)td->td_tid, td); + if (td->td_proc->p_flag & P_INMEM) db_trace_thread(td, -1); - if (db_pager_quit) { - kdb_jmpbuf(prev_jb); - return; - } + else + db_printf("--- swapped out\n"); + if (db_pager_quit) { + kdb_jmpbuf(prev_jb); + return; } } kdb_jmpbuf(prev_jb); diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index da655d11da02..2e5e6332d6e8 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -512,7 +512,6 @@ void db_findstack_cmd(db_expr_t addr, bool have_addr, db_expr_t dummy3 __unused, char *dummy4 __unused) { - struct proc *p; struct thread *td; vm_offset_t saddr; @@ -523,12 +522,10 @@ db_findstack_cmd(db_expr_t addr, bool have_addr, db_expr_t dummy3 __unused, return; } - FOREACH_PROC_IN_SYSTEM(p) { - FOREACH_THREAD_IN_PROC(p, td) { - if (kstack_contains(td, saddr, 1)) { - db_printf("Thread %p\n", td); - return; - } + for (td = kdb_thr_first(); td != NULL; td = kdb_thr_next(td)) { + if (kstack_contains(td, saddr, 1)) { + db_printf("Thread %p\n", td); + return; } } }