From owner-dev-commits-src-all@freebsd.org Fri Jan 1 00:04:00 2021 Return-Path: Delivered-To: dev-commits-src-all@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 0BF594D57D6; Fri, 1 Jan 2021 00:04:00 +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 4D6QH36w8pz4ZNy; 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 DF8EE190FE; 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 10103xX8093748; 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 10103xp7093747; Fri, 1 Jan 2021 00:03:59 GMT (envelope-from git) Date: Fri, 1 Jan 2021 00:03:59 GMT Message-Id: <202101010003.10103xp7093747@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: 825d234144c5 - main - Don't check P_INMEM in kdb_thr_*(). 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: 825d234144c5006e81c752bda7b9bcc2f822707e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jan 2021 00:04:00 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=825d234144c5006e81c752bda7b9bcc2f822707e commit 825d234144c5006e81c752bda7b9bcc2f822707e Author: John Baldwin AuthorDate: 2021-01-01 00:01:12 +0000 Commit: John Baldwin CommitDate: 2021-01-01 00:01:12 +0000 Don't check P_INMEM in kdb_thr_*(). Not all debugger operations that enumerate threads require thread stacks to be resident in memory to be useful. Instead, push P_INMEM checks (if needed) into callers. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27827 --- sys/ddb/db_command.c | 5 ++++- sys/ddb/db_thread.c | 7 +++++-- sys/kern/subr_kdb.c | 15 +++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 1a836be335bf..1fa1cd1b7bb9 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -838,7 +838,10 @@ db_stack_trace(db_expr_t tid, bool hastid, db_expr_t count, char *modif) else pid = -1; db_printf("Tracing pid %d tid %ld td %p\n", pid, (long)td->td_tid, td); - db_trace_thread(td, count); + if (td->td_proc != NULL && (td->td_proc->p_flag & P_INMEM) == 0) + db_printf("--- swapped out\n"); + else + db_trace_thread(td, count); } static void diff --git a/sys/ddb/db_thread.c b/sys/ddb/db_thread.c index 780301a22106..e7619dc368fe 100644 --- a/sys/ddb/db_thread.c +++ b/sys/ddb/db_thread.c @@ -90,8 +90,11 @@ db_show_threads(db_expr_t addr, bool hasaddr, db_expr_t cnt, char *mod) (void *)thr->td_kstack); prev_jb = kdb_jmpbuf(jb); if (setjmp(jb) == 0) { - if (db_trace_thread(thr, 1) != 0) - db_printf("***\n"); + if (thr->td_proc->p_flag & P_INMEM) { + if (db_trace_thread(thr, 1) != 0) + db_printf("***\n"); + } else + db_printf("*** swapped out\n"); } kdb_jmpbuf(prev_jb); thr = kdb_thr_next(thr); diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 04b9b5a838df..576635e4a8dc 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -590,11 +590,9 @@ kdb_thr_first(void) for (i = 0; i <= pidhash; i++) { LIST_FOREACH(p, &pidhashtbl[i], p_hash) { - if (p->p_flag & P_INMEM) { - thr = FIRST_THREAD_IN_PROC(p); - if (thr != NULL) - return (thr); - } + thr = FIRST_THREAD_IN_PROC(p); + if (thr != NULL) + return (thr); } } return (NULL); @@ -606,7 +604,7 @@ kdb_thr_from_pid(pid_t pid) struct proc *p; LIST_FOREACH(p, PIDHASH(pid), p_hash) { - if (p->p_flag & P_INMEM && p->p_pid == pid) + if (p->p_pid == pid) return (FIRST_THREAD_IN_PROC(p)); } return (NULL); @@ -641,8 +639,9 @@ kdb_thr_next(struct thread *thr) return (NULL); p = LIST_FIRST(&pidhashtbl[hash]); } - if (p->p_flag & P_INMEM) - return (FIRST_THREAD_IN_PROC(p)); + thr = FIRST_THREAD_IN_PROC(p); + if (thr != NULL) + return (thr); } }