Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 May 2021 17:14:15 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3e7a11ca21f3 - main - vm_object_set_memattr(): handle all object types without listing them explicitly
Message-ID:  <202105131714.14DHEF6k063352@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3e7a11ca21f3a7948c50f27de5b2159f0bb56672

commit 3e7a11ca21f3a7948c50f27de5b2159f0bb56672
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-05-07 18:19:30 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-05-13 17:10:35 +0000

    vm_object_set_memattr(): handle all object types without listing them explicitly
    
    This avoids the need to know all existing object types in advance, by the
    cost of loosing the assert that unknown object type is handled in a sane
    manner.
    
    Reviewed by:    markj
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D30168
---
 sys/vm/vm_object.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 735ab603a09b..1aa05093f93a 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -330,24 +330,12 @@ vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr)
 {
 
 	VM_OBJECT_ASSERT_WLOCKED(object);
-	switch (object->type) {
-	case OBJT_DEFAULT:
-	case OBJT_DEVICE:
-	case OBJT_MGTDEVICE:
-	case OBJT_PHYS:
-	case OBJT_SG:
-	case OBJT_SWAP:
-	case OBJT_SWAP_TMPFS:
-	case OBJT_VNODE:
-		if (!TAILQ_EMPTY(&object->memq))
-			return (KERN_FAILURE);
-		break;
-	case OBJT_DEAD:
+
+	if (object->type == OBJT_DEAD)
 		return (KERN_INVALID_ARGUMENT);
-	default:
-		panic("vm_object_set_memattr: object %p is of undefined type",
-		    object);
-	}
+	if (!TAILQ_EMPTY(&object->memq))
+		return (KERN_FAILURE);
+
 	object->memattr = memattr;
 	return (KERN_SUCCESS);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105131714.14DHEF6k063352>