2.4.24 extra CPU cycles in scsi.c

From: Richard B. Johnson
Date: Thu Feb 19 2004 - 11:23:56 EST



When looking through various modules that I use, trying to
find out where some memory seems to be leaking, I found a
couple of unrelated things in scsi.c.

The code sets a structure-member to NULL, then releases the
pointer to that structure. A few CPU cycles being thrown away.
Since I was reviewing the whole file, I also got rid of the
spurious casts when calling kfree().



--- linux-2.4.24/drivers/scsi/scsi.c.orig Thu Feb 19 10:45:20 2004
+++ linux-2.4.24/drivers/scsi/scsi.c Thu Feb 19 11:01:47 2004
@@ -314,11 +314,7 @@
void scsi_release_request(Scsi_Request * req)
{
if( req->sr_command != NULL )
- {
scsi_release_command(req->sr_command);
- req->sr_command = NULL;
- }
-
kfree(req);
}

@@ -1449,7 +1445,7 @@
spin_lock_irqsave(&device_request_lock, flags);
for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCnext) {
SDpnt->device_queue = SCnext = SCpnt->next;
- kfree((char *) SCpnt);
+ kfree(SCpnt);
}
SDpnt->has_cmdblocks = 0;
SDpnt->queue_depth = 0;
@@ -1550,7 +1546,7 @@
max_scsi_hosts = n+1;
}
else
- kfree((char *) shn);
+ kfree(shn);
}
}

@@ -1845,7 +1841,7 @@
HBA_ptr->host_queue = scd->next;
}
blk_cleanup_queue(&scd->request_queue);
- kfree((char *) scd);
+ kfree(scd);
} else {
goto out;
}
@@ -2164,7 +2160,7 @@
blk_cleanup_queue(&SDpnt->request_queue);
/* Next free up the Scsi_Device structures for this host */
shpnt->host_queue = SDpnt->next;
- kfree((char *) SDpnt);
+ kfree(SDpnt);

}
}


Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/