Module Name: src
Committed By: rin
Date: Sun May 31 23:24:20 UTC 2020
Modified Files:
src/sys/kern: kern_timeout.c
Log Message:
Stop allocating buffers dynamically in a DDB session, in order not to
disturb on-going debugged state of kernel datastructures.
Since DDB is running on 1 CPU at a time, static buffers are enough.
Increase in BSS section is:
52552 for amd64 (LP64)
9152 for m68k (ILP32)
Requested by thorpej@ and mrg@.
Also suggested by ryo@.
Thanks!
To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/kern/kern_timeout.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_timeout.c
diff -u src/sys/kern/kern_timeout.c:1.63 src/sys/kern/kern_timeout.c:1.64
--- src/sys/kern/kern_timeout.c:1.63 Sun May 31 09:59:37 2020
+++ src/sys/kern/kern_timeout.c Sun May 31 23:24:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_timeout.c,v 1.63 2020/05/31 09:59:37 rin Exp $ */
+/* $NetBSD: kern_timeout.c,v 1.64 2020/05/31 23:24:20 rin Exp $ */
/*-
* Copyright (c) 2003, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.63 2020/05/31 09:59:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.64 2020/05/31 23:24:20 rin Exp $");
/*
* Timeouts are kept in a hierarchical timing wheel. The c_time is the
@@ -102,9 +102,11 @@ __KERNEL_RCSID(0, "$NetBSD: kern_timeout
#include <ddb/db_interface.h>
#include <ddb/db_access.h>
#include <ddb/db_cpu.h>
-#include <ddb/db_command.h>
#include <ddb/db_sym.h>
#include <ddb/db_output.h>
+
+static struct callout_cpu ccb;
+static struct cpu_info cib;
#endif
#define BUCKETS 1024
@@ -835,9 +837,8 @@ db_show_callout_bucket(struct callout_cp
void
db_show_callout(db_expr_t addr, bool haddr, db_expr_t count, const char *modif)
{
- struct callout_cpu *cc, *ccp;
- struct cpu_info *ci, *cip;
- const size_t ccs = sizeof(*cc), cis = sizeof(*ci);
+ struct callout_cpu *cc;
+ struct cpu_info *ci;
int b;
#ifndef CRASH
@@ -845,40 +846,25 @@ db_show_callout(db_expr_t addr, bool had
#endif
db_printf(" ticks wheel arg func\n");
- ccp = db_alloc(ccs);
- if (ccp == NULL) {
- db_printf("%s: cannot allocate callout_cpu\n", __func__);
- return;
- }
- cip = db_alloc(cis);
- if (cip == NULL) {
- db_free(ccp, ccs);
- db_printf("%s: cannot allocate cpu_info\n", __func__);
- return;
- }
-
/*
* Don't lock the callwheel; all the other CPUs are paused
* anyhow, and we might be called in a circumstance where
* some other CPU was paused while holding the lock.
*/
for (ci = db_cpu_first(); ci != NULL; ci = db_cpu_next(ci)) {
- db_read_bytes((db_addr_t)ci, cis, (char *)cip);
- cc = cip->ci_data.cpu_callout;
- db_read_bytes((db_addr_t)cc, ccs, (char *)ccp);
- db_show_callout_bucket(ccp, &cc->cc_todo, &ccp->cc_todo);
+ db_read_bytes((db_addr_t)ci, sizeof(cib), (char *)&cib);
+ cc = cib.ci_data.cpu_callout;
+ db_read_bytes((db_addr_t)cc, sizeof(ccb), (char *)&ccb);
+ db_show_callout_bucket(&ccb, &cc->cc_todo, &ccb.cc_todo);
}
for (b = 0; b < BUCKETS; b++) {
for (ci = db_cpu_first(); ci != NULL; ci = db_cpu_next(ci)) {
- db_read_bytes((db_addr_t)ci, cis, (char *)cip);
- cc = cip->ci_data.cpu_callout;
- db_read_bytes((db_addr_t)cc, ccs, (char *)ccp);
- db_show_callout_bucket(ccp, &cc->cc_wheel[b],
- &ccp->cc_wheel[b]);
+ db_read_bytes((db_addr_t)ci, sizeof(cib), (char *)&cib);
+ cc = cib.ci_data.cpu_callout;
+ db_read_bytes((db_addr_t)cc, sizeof(ccb), (char *)&ccb);
+ db_show_callout_bucket(&ccb, &cc->cc_wheel[b],
+ &ccb.cc_wheel[b]);
}
}
-
- db_free(ccp, ccs);
- db_free(cip, cis);
}
#endif /* DDB */