Module Name:    src
Committed By:   uwe
Date:           Tue Jul 16 16:48:54 UTC 2024

Modified Files:
        src/sys/uvm: uvm_map.c

Log Message:
uvm_findspace_invariants: don't repeat the message three times

The topdown and bottomup messages were exactly the same and sh3 printf
hack added the third copy.  Restructure the code so that there's only
one message and make the message more obvious - the topdown condition
in the assertions was confusing b/c it's inverted (!topdown || ...
means it's the topdown map).

PR 51254


To generate a diff of this commit:
cvs rdiff -u -r1.412 -r1.413 src/sys/uvm/uvm_map.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/uvm/uvm_map.c
diff -u src/sys/uvm/uvm_map.c:1.412 src/sys/uvm/uvm_map.c:1.413
--- src/sys/uvm/uvm_map.c:1.412	Mon Jul 15 12:51:50 2024
+++ src/sys/uvm/uvm_map.c	Tue Jul 16 16:48:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.412 2024/07/15 12:51:50 riastradh Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.413 2024/07/16 16:48:54 uwe Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.412 2024/07/15 12:51:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.413 2024/07/16 16:48:54 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pax.h"
@@ -1776,32 +1776,30 @@ uvm_findspace_invariants(struct vm_map *
     vaddr_t hint, struct vm_map_entry *entry, int line)
 {
 	const int topdown = map->flags & VM_MAP_TOPDOWN;
+	const int hint_location_ok =
+		topdown ? hint <= orig_hint
+			: hint >= orig_hint;
+
+#if !(defined(__sh3__) && defined(DIAGNOSTIC)) /* XXXRO: kern/51254 */
+#define UVM_FINDSPACE_KASSERTMSG KASSERTMSG
+
+#else  /* sh3 && DIAGNOSTIC */
+/* like KASSERTMSG but make it not fatal */
+#define UVM_FINDSPACE_KASSERTMSG(e, msg, ...)			\
+		(__predict_true((e)) ? (void)0 :		\
+		    printf(__KASSERTSTR msg "\n",		\
+			"weak diagnostic ", #e,			\
+			__FILE__, __LINE__, ## __VA_ARGS__))
+#endif
 
-	KASSERTMSG( topdown || hint >= orig_hint,
-	    "map=%p hint=%#"PRIxVADDR" orig_hint=%#"PRIxVADDR
-	    " length=%#"PRIxVSIZE" uobj=%p uoffset=%#llx align=%"PRIxVSIZE
-	    " flags=%#x entry=%p (uvm_map_findspace line %d)",
-	    map, hint, orig_hint,
-	    length, uobj, (unsigned long long)uoffset, align,
-	    flags, entry, line);
-#ifndef __sh3__ /* XXXRO: kern/51254 */
-	KASSERTMSG(!topdown || hint <= orig_hint,
-	    "map=%p hint=%#"PRIxVADDR" orig_hint=%#"PRIxVADDR
-	    " length=%#"PRIxVSIZE" uobj=%p uoffset=%#llx align=%"PRIxVSIZE
+	UVM_FINDSPACE_KASSERTMSG(hint_location_ok,
+	    "%s map=%p hint=%#" PRIxVADDR " %s orig_hint=%#" PRIxVADDR
+	    " length=%#" PRIxVSIZE " uobj=%p uoffset=%#llx align=%" PRIxVSIZE
 	    " flags=%#x entry=%p (uvm_map_findspace line %d)",
-	    map, hint, orig_hint,
+	    topdown ? "topdown" : "bottomup",
+	    map, hint, topdown ? ">" : "<", orig_hint,
 	    length, uobj, (unsigned long long)uoffset, align,
 	    flags, entry, line);
-#else
-	if (__predict_false(!(!topdown || hint <= orig_hint)))
-		printf("map=%p hint=%#"PRIxVADDR" orig_hint=%#"PRIxVADDR
-		    " length=%#"PRIxVSIZE" uobj=%p"
-		    " uoffset=%#llx align=%"PRIxVSIZE
-		    " flags=%#x entry=%p (uvm_map_findspace line %d)\n",
-		    map, hint, orig_hint,
-		    length, uobj, (unsigned long long)uoffset, align,
-		    flags, entry, line);
-#endif
 }
 
 /*

Reply via email to