revert the previous that the mbstat is located on the stack.
ok claudio
-/* $OpenBSD: kern_sysctl.c,v 1.417 2023/07/07 16:27:46 bluhm Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.418 2023/07/16 03:01:31 yasuoka Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
case KERN_MBSTAT: {
extern struct cpumem *mbstat;
uint64_t counters[MBSTAT_COUNT];
- struct mbstat *mbs;
+ struct mbstat mbs;
unsigned int i;
- int ret;
- mbs = malloc(sizeof(*mbs), M_TEMP, M_WAITOK | M_ZERO);
+ memset(&mbs, 0, sizeof(mbs));
counters_read(mbstat, counters, MBSTAT_COUNT);
for (i = 0; i < MBSTAT_TYPES; i++)
- mbs->m_mtypes[i] = counters[i];
+ mbs.m_mtypes[i] = counters[i];
- mbs->m_drops = counters[MBSTAT_DROPS];
- mbs->m_wait = counters[MBSTAT_WAIT];
- mbs->m_drain = counters[MBSTAT_DRAIN];
+ mbs.m_drops = counters[MBSTAT_DROPS];
+ mbs.m_wait = counters[MBSTAT_WAIT];
+ mbs.m_drain = counters[MBSTAT_DRAIN];
- ret = sysctl_rdstruct(oldp, oldlenp, newp, mbs, sizeof(*mbs));
- free(mbs, M_TEMP, sizeof(*mbs));
- return (ret);
+ return (sysctl_rdstruct(oldp, oldlenp, newp,
+ &mbs, sizeof(mbs)));
}
case KERN_MSGBUFSIZE:
case KERN_CONSBUFSIZE: {
-/* $OpenBSD: mbuf.h,v 1.260 2023/07/07 14:17:34 yasuoka Exp $ */
+/* $OpenBSD: mbuf.h,v 1.261 2023/07/16 03:01:31 yasuoka Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
/* length to m_copy to copy all */
#define M_COPYALL 1000000000
+#define MBSTAT_TYPES MT_NTYPES
+#define MBSTAT_DROPS (MBSTAT_TYPES + 0)
+#define MBSTAT_WAIT (MBSTAT_TYPES + 1)
+#define MBSTAT_DRAIN (MBSTAT_TYPES + 2)
+#define MBSTAT_COUNT (MBSTAT_TYPES + 3)
+
/*
* Mbuf statistics.
* For statistics related to mbuf and cluster allocations, see also the
u_long m_drops; /* times failed to find space */
u_long m_wait; /* times waited for space */
u_long m_drain; /* times drained protocols for space */
- u_long m_mtypes[256]; /* type specific mbuf allocations */
+ u_long m_mtypes[MBSTAT_COUNT];
+ /* type specific mbuf allocations */
};
-#define MBSTAT_TYPES MT_NTYPES
-#define MBSTAT_DROPS (MBSTAT_TYPES + 0)
-#define MBSTAT_WAIT (MBSTAT_TYPES + 1)
-#define MBSTAT_DRAIN (MBSTAT_TYPES + 2)
-#define MBSTAT_COUNT (MBSTAT_TYPES + 3)
-
#include <sys/mutex.h>
struct mbuf_list {
-/* $OpenBSD: mbuf.c,v 1.44 2023/07/07 14:17:35 yasuoka Exp $ */
+/* $OpenBSD: mbuf.c,v 1.45 2023/07/16 03:01:31 yasuoka Exp $ */
/* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */
/*
};
int nmbtypes = sizeof(mbstat.m_mtypes) / sizeof(u_long);
-bool seen[256]; /* "have we seen this type yet?" */
+bool seen[MBSTAT_COUNT]; /* "have we seen this type yet?" */
/*
* Print mbuf statistics.
struct mbtypes *mp;
size_t size;
- if (nmbtypes != 256) {
+ if (nmbtypes != MBSTAT_COUNT) {
fprintf(stderr,
"%s: unexpected change to mbstat; check source\n",
__progname);