Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern kmem(9): Tweak branch predictions in fast paths.
details: https://anonhg.NetBSD.org/src/rev/8d898293dd54
branches: trunk
changeset: 374185:8d898293dd54
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Apr 09 08:50:20 2023 +0000
description:
kmem(9): Tweak branch predictions in fast paths.
diffstat:
sys/kern/subr_kmem.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diffs (62 lines):
diff -r f156f4c784f9 -r 8d898293dd54 sys/kern/subr_kmem.c
--- a/sys/kern/subr_kmem.c Sun Apr 09 08:28:24 2023 +0000
+++ b/sys/kern/subr_kmem.c Sun Apr 09 08:50:20 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kmem.c,v 1.87 2022/05/30 23:36:26 mrg Exp $ */
+/* $NetBSD: subr_kmem.c,v 1.88 2023/04/09 08:50:20 riastradh Exp $ */
/*
* Copyright (c) 2009-2020 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.87 2022/05/30 23:36:26 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.88 2023/04/09 08:50:20 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_kmem.h"
@@ -346,7 +346,7 @@ kmem_intr_zalloc(size_t size, km_flag_t
void *p;
p = kmem_intr_alloc(size, kmflags);
- if (p != NULL) {
+ if (__predict_true(p != NULL)) {
memset(p, 0, size);
}
return p;
@@ -406,8 +406,9 @@ kmem_alloc(size_t size, km_flag_t kmflag
{
void *v;
- KASSERTMSG((!cpu_intr_p() && !cpu_softintr_p()),
- "kmem(9) should not be used from the interrupt context");
+ KASSERT(!cpu_intr_p());
+ KASSERT(!cpu_softintr_p());
+
v = kmem_intr_alloc(size, kmflags);
if (__predict_true(v != NULL)) {
kmsan_mark(v, size, KMSAN_STATE_UNINIT);
@@ -426,8 +427,9 @@ kmem_zalloc(size_t size, km_flag_t kmfla
{
void *v;
- KASSERTMSG((!cpu_intr_p() && !cpu_softintr_p()),
- "kmem(9) should not be used from the interrupt context");
+ KASSERT(!cpu_intr_p());
+ KASSERT(!cpu_softintr_p());
+
v = kmem_intr_zalloc(size, kmflags);
KASSERT(v || (kmflags & KM_NOSLEEP) != 0);
return v;
@@ -440,8 +442,10 @@ kmem_zalloc(size_t size, km_flag_t kmfla
void
kmem_free(void *p, size_t size)
{
+
KASSERT(!cpu_intr_p());
KASSERT(!cpu_softintr_p());
+
kmem_intr_free(p, size);
kmsan_mark(p, size, KMSAN_STATE_INITED);
}
Home |
Main Index |
Thread Index |
Old Index