[Midnightbsd-cvs] src [8245] trunk/sys/cam/cam_xpt.c: use separate malloc buckets for CAM devices, CCBs and paths

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Sep 17 17:33:14 EDT 2016


Revision: 8245
          http://svnweb.midnightbsd.org/src/?rev=8245
Author:   laffer1
Date:     2016-09-17 17:33:14 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
use separate malloc buckets for CAM devices, CCBs and paths

Modified Paths:
--------------
    trunk/sys/cam/cam_xpt.c

Modified: trunk/sys/cam/cam_xpt.c
===================================================================
--- trunk/sys/cam/cam_xpt.c	2016-09-17 21:32:52 UTC (rev 8244)
+++ trunk/sys/cam/cam_xpt.c	2016-09-17 21:33:14 UTC (rev 8245)
@@ -78,6 +78,9 @@
 
 /* Datastructures internal to the xpt layer */
 MALLOC_DEFINE(M_CAMXPT, "CAM XPT", "CAM XPT buffers");
+MALLOC_DEFINE(M_CAMDEV, "CAM DEV", "CAM devices");
+MALLOC_DEFINE(M_CAMCCB, "CAM CCB", "CAM CCBs");
+MALLOC_DEFINE(M_CAMPATH, "CAM path", "CAM paths");
 
 /* Object for defering XPT actions to a taskqueue */
 struct xpt_task {
@@ -3397,7 +3400,7 @@
 	struct	   cam_path *path;
 	cam_status status;
 
-	path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_NOWAIT);
+	path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_NOWAIT);
 
 	if (path == NULL) {
 		status = CAM_RESRC_UNAVAIL;
@@ -3405,7 +3408,7 @@
 	}
 	status = xpt_compile_path(path, perph, path_id, target_id, lun_id);
 	if (status != CAM_REQ_CMP) {
-		free(path, M_CAMXPT);
+		free(path, M_CAMPATH);
 		path = NULL;
 	}
 	*new_path_ptr = path;
@@ -3422,7 +3425,7 @@
 	cam_status status;
 	int	   need_unlock = 0;
 
-	path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_WAITOK);
+	path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_WAITOK);
 
 	if (path_id != CAM_BUS_WILDCARD) {
 		bus = xpt_find_bus(path_id);
@@ -3437,7 +3440,7 @@
 		xpt_release_bus(bus);
 	}
 	if (status != CAM_REQ_CMP) {
-		free(path, M_CAMXPT);
+		free(path, M_CAMPATH);
 		path = NULL;
 	}
 	*new_path_ptr = path;
@@ -3540,7 +3543,7 @@
 
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_free_path\n"));
 	xpt_release_path(path);
-	free(path, M_CAMXPT);
+	free(path, M_CAMPATH);
 }
 
 void
@@ -4376,7 +4379,7 @@
 {
 	union ccb *new_ccb;
 
-	new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_ZERO|M_WAITOK);
+	new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK);
 	return (new_ccb);
 }
 
@@ -4385,7 +4388,7 @@
 {
 	union ccb *new_ccb;
 
-	new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_ZERO|M_NOWAIT);
+	new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT);
 	return (new_ccb);
 }
 
@@ -4392,7 +4395,7 @@
 void
 xpt_free_ccb(union ccb *free_ccb)
 {
-	free(free_ccb, M_CAMXPT);
+	free(free_ccb, M_CAMCCB);
 }
 
 
@@ -4544,7 +4547,7 @@
 		device = NULL;
 	} else {
 		device = (struct cam_ed *)malloc(sizeof(*device),
-						 M_CAMXPT, M_NOWAIT|M_ZERO);
+						 M_CAMDEV, M_NOWAIT|M_ZERO);
 	}
 
 	if (device != NULL) {
@@ -4557,13 +4560,13 @@
 		device->sim = bus->sim;
 		/* Initialize our queues */
 		if (camq_init(&device->drvq, 0) != 0) {
-			free(device, M_CAMXPT);
+			free(device, M_CAMDEV);
 			return (NULL);
 		}
 		if (cam_ccbq_init(&device->ccbq,
 				  bus->sim->max_dev_openings) != 0) {
 			camq_fini(&device->drvq);
-			free(device, M_CAMXPT);
+			free(device, M_CAMDEV);
 			return (NULL);
 		}
 		SLIST_INIT(&device->asyncs);
@@ -4616,7 +4619,7 @@
 		camq_fini(&device->drvq);
 		cam_ccbq_fini(&device->ccbq);
 		xpt_release_target(device->target);
-		free(device, M_CAMXPT);
+		free(device, M_CAMDEV);
 	} else
 		device->refcount--;
 }



More information about the Midnightbsd-cvs mailing list