summaryrefslogtreecommitdiffstats
path: root/sys/cam/scsi
diff options
context:
space:
mode:
authoravatar <avatar@FreeBSD.org>2005-07-01 15:21:30 +0000
committeravatar <avatar@FreeBSD.org>2005-07-01 15:21:30 +0000
commitcd4bfad3f4ba5095161965b917d002ca6e2f0351 (patch)
tree147319ac765fa09f2f2ee982d5fabcc2832eae98 /sys/cam/scsi
parent7022c58ccbb4c7d5ef45d1d37b1d76e6d27c6e3b (diff)
downloadFreeBSD-src-cd4bfad3f4ba5095161965b917d002ca6e2f0351.zip
FreeBSD-src-cd4bfad3f4ba5095161965b917d002ca6e2f0351.tar.gz
- Providing fine-grained malloc statistic by replacing M_DEVBUF with
module-specific malloc types. These should help us to pinpoint the possible memory leakage in the future. - Implementing xpt_alloc_ccb_nowait() and replacing all malloc/free based CCB memory management with xpt_alloc_ccb[_nowait]/xpt_free_ccb. Hopefully this would be helpful if someday we move the CCB allocator to use UMA instead of malloc(). Encouraged by: jeffr, rwatson Reviewed by: gibbs, scottl Approved by: re (scottl)
Diffstat (limited to 'sys/cam/scsi')
-rw-r--r--sys/cam/scsi/scsi_low.c17
-rw-r--r--sys/cam/scsi/scsi_sa.c5
-rw-r--r--sys/cam/scsi/scsi_ses.c12
-rw-r--r--sys/cam/scsi/scsi_targ_bh.c32
4 files changed, 37 insertions, 29 deletions
diff --git a/sys/cam/scsi/scsi_low.c b/sys/cam/scsi/scsi_low.c
index 2249559..dc9a492 100644
--- a/sys/cam/scsi/scsi_low.c
+++ b/sys/cam/scsi/scsi_low.c
@@ -111,6 +111,7 @@ __FBSDID("$FreeBSD$");
#include <cam/cam_sim.h>
#include <cam/cam_debug.h>
#include <cam/cam_periph.h>
+#include <cam/cam_xpt_periph.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
@@ -144,6 +145,8 @@ __FBSDID("$FreeBSD$");
#define SCSI_LOW_DISK_LFLAGS 0x0000ffff
#define SCSI_LOW_DISK_TFLAGS 0xffff0000
+MALLOC_DEFINE(M_SCSILOW, "SCSI low", "SCSI low buffers");
+
/**************************************************************
* Declarations
**************************************************************/
@@ -394,8 +397,8 @@ scsi_low_translate_error_code(cb, tp)
* SCSI INTERFACE (XS)
**************************************************************/
#define SCSI_LOW_MINPHYS 0x10000
-#define SCSI_LOW_MALLOC(size) malloc((size), M_DEVBUF, M_NOWAIT)
-#define SCSI_LOW_FREE(pt) free((pt), M_DEVBUF)
+#define SCSI_LOW_MALLOC(size) malloc((size), M_SCSILOW, M_NOWAIT)
+#define SCSI_LOW_FREE(pt) free((pt), M_SCSILOW)
#define SCSI_LOW_ALLOC_CCB(flags) scsi_low_get_ccb((flags))
#define SCSI_LOW_XS_POLL_HZ 1000
@@ -884,8 +887,8 @@ scsi_low_target_open(link, cf)
/**************************************************************
* SCSI INTERFACE (CAM)
**************************************************************/
-#define SCSI_LOW_MALLOC(size) malloc((size), M_DEVBUF, M_NOWAIT)
-#define SCSI_LOW_FREE(pt) free((pt), M_DEVBUF)
+#define SCSI_LOW_MALLOC(size) malloc((size), M_SCSILOW, M_NOWAIT)
+#define SCSI_LOW_FREE(pt) free((pt), M_SCSILOW)
#define SCSI_LOW_ALLOC_CCB(flags) scsi_low_get_ccb()
static void scsi_low_poll_cam(struct cam_sim *);
@@ -955,7 +958,7 @@ scsi_low_cam_rescan_callback(periph, ccb)
{
xpt_free_path(ccb->ccb_h.path);
- free(ccb, M_DEVBUF);
+ xpt_free_ccb(ccb);
}
static void
@@ -963,7 +966,7 @@ scsi_low_rescan_bus_cam(slp)
struct scsi_low_softc *slp;
{
struct cam_path *path;
- union ccb *ccb = malloc(sizeof(union ccb), M_DEVBUF, M_WAITOK);
+ union ccb *ccb = xpt_alloc_ccb();
cam_status status;
bzero(ccb, sizeof(union ccb));
@@ -1412,7 +1415,7 @@ scsi_low_attach_cam(slp)
}
if (xpt_bus_register(slp->sl_si.sim, 0) != CAM_SUCCESS) {
- free(slp->sl_si.sim, M_DEVBUF);
+ free(slp->sl_si.sim, M_SCSILOW);
return ENODEV;
}
diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index 88ad7a2..f970cf9 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -101,6 +101,7 @@ __FBSDID("$FreeBSD$");
* Driver states
*/
+MALLOC_DEFINE(M_SCSISA, "SCSI sa", "SCSI sequential access buffers");
typedef enum {
SA_STATE_NORMAL, SA_STATE_ABNORMAL
@@ -1354,7 +1355,7 @@ sacleanup(struct cam_periph *periph)
xpt_print_path(periph->path);
printf("removing device entry\n");
- free(softc, M_DEVBUF);
+ free(softc, M_SCSISA);
}
static void
@@ -1420,7 +1421,7 @@ saregister(struct cam_periph *periph, void *arg)
}
softc = (struct sa_softc *)
- malloc(sizeof (*softc), M_DEVBUF, M_NOWAIT | M_ZERO);
+ malloc(sizeof (*softc), M_SCSISA, M_NOWAIT | M_ZERO);
if (softc == NULL) {
printf("saregister: Unable to probe new device. "
"Unable to allocate softc\n");
diff --git a/sys/cam/scsi/scsi_ses.c b/sys/cam/scsi/scsi_ses.c
index a25fd90..608290d 100644
--- a/sys/cam/scsi/scsi_ses.c
+++ b/sys/cam/scsi/scsi_ses.c
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
#include <opt_ses.h>
+MALLOC_DEFINE(M_SCSISES, "SCSI SES", "SCSI SES buffers");
+
/*
* Platform Independent Driver Internal Definitions for SES devices.
*/
@@ -120,8 +122,8 @@ static int safte_set_objstat(ses_softc_t *, ses_objstat *, int);
#define SES_DLOG if (0) ses_log
#endif
#define SES_VLOG if (bootverbose) ses_log
-#define SES_MALLOC(amt) malloc(amt, M_DEVBUF, M_NOWAIT)
-#define SES_FREE(ptr, amt) free(ptr, M_DEVBUF)
+#define SES_MALLOC(amt) malloc(amt, M_SCSISES, M_NOWAIT)
+#define SES_FREE(ptr, amt) free(ptr, M_SCSISES)
#define MEMZERO bzero
#define MEMCPY(dest, src, amt) bcopy(src, dest, amt)
@@ -250,7 +252,7 @@ sescleanup(struct cam_periph *periph)
xpt_print_path(periph->path);
printf("removing device entry\n");
- free(softc, M_DEVBUF);
+ free(softc, M_SCSISES);
}
static void
@@ -324,7 +326,7 @@ sesregister(struct cam_periph *periph, void *arg)
return (CAM_REQ_CMP_ERR);
}
- softc = malloc(sizeof (struct ses_softc), M_DEVBUF, M_NOWAIT);
+ softc = malloc(sizeof (struct ses_softc), M_SCSISES, M_NOWAIT);
if (softc == NULL) {
printf("sesregister: Unable to probe new device. "
"Unable to allocate softc\n");
@@ -359,7 +361,7 @@ sesregister(struct cam_periph *periph, void *arg)
break;
case SES_NONE:
default:
- free(softc, M_DEVBUF);
+ free(softc, M_SCSISES);
return (CAM_REQ_CMP_ERR);
}
diff --git a/sys/cam/scsi/scsi_targ_bh.c b/sys/cam/scsi/scsi_targ_bh.c
index 828cbbb..e755f2f 100644
--- a/sys/cam/scsi/scsi_targ_bh.c
+++ b/sys/cam/scsi/scsi_targ_bh.c
@@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$");
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
+MALLOC_DEFINE(M_SCSIBH, "SCSI bh", "SCSI blackhole buffers");
+
typedef enum {
TARGBH_STATE_NORMAL,
TARGBH_STATE_EXCEPTION,
@@ -276,7 +278,7 @@ targbhenlun(struct cam_periph *periph)
for (i = 0; i < MAX_ACCEPT; i++) {
struct ccb_accept_tio *atio;
- atio = (struct ccb_accept_tio*)malloc(sizeof(*atio), M_DEVBUF,
+ atio = (struct ccb_accept_tio*)malloc(sizeof(*atio), M_SCSIBH,
M_NOWAIT);
if (atio == NULL) {
status = CAM_RESRC_UNAVAIL;
@@ -286,7 +288,7 @@ targbhenlun(struct cam_periph *periph)
atio->ccb_h.ccb_descr = targbhallocdescr();
if (atio->ccb_h.ccb_descr == NULL) {
- free(atio, M_DEVBUF);
+ free(atio, M_SCSIBH);
status = CAM_RESRC_UNAVAIL;
break;
}
@@ -298,7 +300,7 @@ targbhenlun(struct cam_periph *periph)
status = atio->ccb_h.status;
if (status != CAM_REQ_INPROG) {
targbhfreedescr(atio->ccb_h.ccb_descr);
- free(atio, M_DEVBUF);
+ free(atio, M_SCSIBH);
break;
}
((struct targbh_cmd_desc*)atio->ccb_h.ccb_descr)->atio_link =
@@ -321,7 +323,7 @@ targbhenlun(struct cam_periph *periph)
for (i = 0; i < MAX_ACCEPT; i++) {
struct ccb_immed_notify *inot;
- inot = (struct ccb_immed_notify*)malloc(sizeof(*inot), M_DEVBUF,
+ inot = (struct ccb_immed_notify*)malloc(sizeof(*inot), M_SCSIBH,
M_NOWAIT);
if (inot == NULL) {
@@ -335,7 +337,7 @@ targbhenlun(struct cam_periph *periph)
xpt_action((union ccb *)inot);
status = inot->ccb_h.status;
if (status != CAM_REQ_INPROG) {
- free(inot, M_DEVBUF);
+ free(inot, M_SCSIBH);
break;
}
SLIST_INSERT_HEAD(&softc->immed_notify_slist, &inot->ccb_h,
@@ -409,7 +411,7 @@ targbhctor(struct cam_periph *periph, void *arg)
/* Allocate our per-instance private storage */
softc = (struct targbh_softc *)malloc(sizeof(*softc),
- M_DEVBUF, M_NOWAIT);
+ M_SCSIBH, M_NOWAIT);
if (softc == NULL) {
printf("targctor: unable to malloc softc\n");
return (CAM_REQ_CMP_ERR);
@@ -446,7 +448,7 @@ targbhdtor(struct cam_periph *periph)
default:
/* XXX Wait for callback of targbhdislun() */
tsleep(softc, PRIBIO, "targbh", hz/2);
- free(softc, M_DEVBUF);
+ free(softc, M_SCSIBH);
break;
}
}
@@ -576,7 +578,7 @@ targbhdone(struct cam_periph *periph, union ccb *done_ccb)
if (softc->state == TARGBH_STATE_TEARDOWN
|| atio->ccb_h.status == CAM_REQ_ABORTED) {
targbhfreedescr(descr);
- free(done_ccb, M_DEVBUF);
+ xpt_free_ccb(done_ccb);
return;
}
@@ -725,7 +727,7 @@ targbhdone(struct cam_periph *periph, union ccb *done_ccb)
break;
} else {
targbhfreedescr(desc);
- free(atio, M_DEVBUF);
+ free(atio, M_SCSIBH);
}
break;
}
@@ -737,7 +739,7 @@ targbhdone(struct cam_periph *periph, union ccb *done_ccb)
if (softc->state == TARGBH_STATE_TEARDOWN
|| done_ccb->ccb_h.status == CAM_REQ_ABORTED) {
printf("Freed an immediate notify\n");
- free(done_ccb, M_DEVBUF);
+ xpt_free_ccb(done_ccb);
} else {
/* Requeue for another immediate event */
xpt_action(done_ccb);
@@ -771,16 +773,16 @@ targbhallocdescr()
/* Allocate the targbh_descr structure */
descr = (struct targbh_cmd_desc *)malloc(sizeof(*descr),
- M_DEVBUF, M_NOWAIT);
+ M_SCSIBH, M_NOWAIT);
if (descr == NULL)
return (NULL);
bzero(descr, sizeof(*descr));
/* Allocate buffer backing store */
- descr->backing_store = malloc(MAX_BUF_SIZE, M_DEVBUF, M_NOWAIT);
+ descr->backing_store = malloc(MAX_BUF_SIZE, M_SCSIBH, M_NOWAIT);
if (descr->backing_store == NULL) {
- free(descr, M_DEVBUF);
+ free(descr, M_SCSIBH);
return (NULL);
}
descr->max_size = MAX_BUF_SIZE;
@@ -790,6 +792,6 @@ targbhallocdescr()
static void
targbhfreedescr(struct targbh_cmd_desc *descr)
{
- free(descr->backing_store, M_DEVBUF);
- free(descr, M_DEVBUF);
+ free(descr->backing_store, M_SCSIBH);
+ free(descr, M_SCSIBH);
}
OpenPOWER on IntegriCloud