public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] Make the SCSI mempool allocations variable
@ 2004-03-09 19:02 James Bottomley
  2004-03-10  6:21 ` Jeremy Higdon
  2004-03-10 10:07 ` Jeremy Higdon
  0 siblings, 2 replies; 5+ messages in thread
From: James Bottomley @ 2004-03-09 19:02 UTC (permalink / raw)
  To: Jeremy Higdon, mpm; +Cc: SCSI Mailing List

Based on Jeremy's request to increase max_phys_segments, this is the way
to do it (SCSI_MAX_PHYS_SEGMENTS) is the value that gets set as the
queue's max_phys_segments.

I have to say that when I tried raising it to 256 and hammering a 10GB
ext2 filesystem, I still didn't generate any >128 segment requests, so
I'm dubious that raising it has any benefit at all, but feel free to try
it and publish the figures.

I did wonder if lowering it might help improve the memory footprint for
some embedded systems, so I set it up to be lowered as far as 32.

James

===== drivers/scsi/scsi_lib.c 1.120 vs edited =====
--- 1.120/drivers/scsi/scsi_lib.c	Mon Feb 23 08:21:36 2004
+++ edited/drivers/scsi/scsi_lib.c	Tue Mar  9 12:04:55 2004
@@ -24,7 +24,7 @@
 #include "scsi_logging.h"
 

-#define SG_MEMPOOL_NR		5
+#define SG_MEMPOOL_NR		(sizeof(scsi_sg_pools)/sizeof(struct scsi_host_sg_pool))
 #define SG_MEMPOOL_SIZE		32
 
 struct scsi_host_sg_pool {
@@ -34,9 +34,27 @@
 	mempool_t	*pool;
 };
 
+#if (SCSI_MAX_PHYS_SEGMENTS < 32)
+#error SCSI_MAX_PHYS_SEGMENTS is too small
+#endif
+
 #define SP(x) { x, "sgpool-" #x } 
-struct scsi_host_sg_pool scsi_sg_pools[SG_MEMPOOL_NR] = { 
-	SP(8), SP(16), SP(32), SP(64), SP(MAX_PHYS_SEGMENTS)
+struct scsi_host_sg_pool scsi_sg_pools[] = { 
+	SP(8),
+	SP(16),
+	SP(32),
+#if (SCSI_MAX_PHYS_SEGMENTS > 32)
+	SP(64),
+#if (SCSI_MAX_PHYS_SEGMENTS > 64)
+	SP(128),
+#if (SCSI_MAX_PHYS_SEGMENTS > 128)
+	SP(256),
+#if (SCSI_MAX_PHYS_SEGMENTS > 256)
+#error SCSI_MAX_PHYS_SEGMENTS is too large
+#endif
+#endif
+#endif
+#endif
 }; 	
 #undef SP
 
@@ -558,12 +576,21 @@
 	case 17 ... 32:
 		cmd->sglist_len = 2;
 		break;
+#if (SCSI_MAX_PHYS_SEGMENTS > 32)
 	case 33 ... 64:
 		cmd->sglist_len = 3;
 		break;
-	case 65 ... MAX_PHYS_SEGMENTS:
+#if (SCSI_MAX_PHYS_SEGMENTS > 64)
+	case 65 ... 128:
 		cmd->sglist_len = 4;
 		break;
+#if (SCSI_MAX_PHYS_SEGMENTS  > 128)
+	case 129 ... 256:
+		cmd->sglist_len = 5;
+		break;
+#endif
+#endif
+#endif
 	default:
 		return NULL;
 	}
@@ -1285,7 +1312,7 @@
 	blk_queue_prep_rq(q, scsi_prep_fn);
 
 	blk_queue_max_hw_segments(q, shost->sg_tablesize);
-	blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
+	blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS);
 	blk_queue_max_sectors(q, shost->max_sectors);
 	blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
 	blk_queue_segment_boundary(q, shost->dma_boundary);
===== include/scsi/scsi.h 1.17 vs edited =====
--- 1.17/include/scsi/scsi.h	Wed Feb 11 01:49:41 2004
+++ edited/include/scsi/scsi.h	Tue Mar  9 12:44:40 2004
@@ -10,6 +10,12 @@
 
 #include <linux/types.h>
 
+/*
+ *	The maximum sg list length SCSI can cope with
+ *	(currently must be a power of 2 between 32 and 256)
+ */
+#define SCSI_MAX_PHYS_SEGMENTS	MAX_PHYS_SEGMENTS
+
 
 /*
  *	SCSI command lengths


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-11  6:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-09 19:02 [RFC] Make the SCSI mempool allocations variable James Bottomley
2004-03-10  6:21 ` Jeremy Higdon
2004-03-10 10:07 ` Jeremy Higdon
2004-03-10 15:29   ` James Bottomley
2004-03-11  6:38     ` Jeremy Higdon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox