[Pvfs2-cvs] commit by slang in pvfs2/src/io/dev: pint-dev-shared.h pint-dev.c pint-dev.h

CVS commit program cvs at parl.clemson.edu
Mon Dec 4 01:18:25 EST 2006


Update of /projects/cvsroot/pvfs2/src/io/dev
In directory parlweb1:/tmp/cvs-serv2372/src/io/dev

Modified Files:
	pint-dev-shared.h pint-dev.c pint-dev.h 
Log Message:
merge of murali's kernel buffer size tuning options to HEAD.


Index: pint-dev-shared.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/dev/pint-dev-shared.h,v
diff -p -u -r1.18 -r1.19
--- pint-dev-shared.h	13 Sep 2006 20:22:50 -0000	1.18
+++ pint-dev-shared.h	4 Dec 2006 06:18:25 -0000	1.19
@@ -24,11 +24,11 @@
 #define PVFS_KERNEL_PROTO_VERSION ((PVFS2_VERSION_MAJOR * 10000) + \
   (PVFS2_VERSION_MINOR * 100) + PVFS2_VERSION_SUB)
 
-/* This is the number of discrete buffers we will break the mapped I/O
+/* This is the default number of discrete buffers we will break the mapped I/O
  * region into.  In some sense it governs the number of concurrent I/O
  * operations that we will allow
  */
-#define PVFS2_BUFMAP_DESC_COUNT    5
+#define PVFS2_BUFMAP_DEFAULT_DESC_COUNT    5
 
 /*
   by default, we assume each description size is 4MB; this value
@@ -44,14 +44,32 @@
 #define PVFS2_BUFMAP_DEFAULT_DESC_SHIFT 22 /* NOTE: 2^22 == 4MB */
 
 /* size of mapped buffer region to use for I/O transfers (in bytes) */
-#define PVFS2_BUFMAP_TOTAL_SIZE \
-(PVFS2_BUFMAP_DESC_COUNT * PVFS2_BUFMAP_DEFAULT_DESC_SIZE)
+#define PVFS2_BUFMAP_DEFAULT_TOTAL_SIZE \
+(PVFS2_BUFMAP_DEFAULT_DESC_COUNT * PVFS2_BUFMAP_DEFAULT_DESC_SIZE)
 
-#define PVFS2_READDIR_DESC_COUNT  5
+/* Sane maximum values for these parameters (128 MB) */
+#define PVFS2_BUFMAP_MAX_TOTAL_SIZE      (128 * (1024 * 1024))
+
+/* log to base 2 when we know that number is a power of 2 */
+static inline int LOG2(int number)
+{
+    int count = 0;
+    if (number == 0 || (number & (number - 1))) 
+    {
+        return -1;
+    }
+    while (number >>= 1)
+    {
+        count++;
+    }
+    return count;
+}
+
+#define PVFS2_READDIR_DEFAULT_DESC_COUNT  5
 #define PVFS2_READDIR_DEFAULT_DESC_SIZE  (128 * 1024)
 #define PVFS2_READDIR_DEFAULT_DESC_SHIFT 17
-#define PVFS2_READDIR_TOTAL_SIZE \
-(PVFS2_READDIR_DESC_COUNT * PVFS2_READDIR_DEFAULT_DESC_SIZE)
+#define PVFS2_READDIR_DEFAULT_TOTAL_SIZE \
+(PVFS2_READDIR_DEFAULT_DESC_COUNT * PVFS2_READDIR_DEFAULT_DESC_SIZE)
 
 /* pvfs2-client-core can cache readahead data up to this size in bytes */
 #define PVFS2_MMAP_RACACHE_MAX_SIZE ((loff_t)(8 * (1024 * 1024)))
@@ -66,7 +84,9 @@
 struct PVFS_dev_map_desc
 {
     void     *ptr;
-    int32_t  size; /* Changed to an int32_t for fixed size structure */
+    int32_t  total_size; 
+    int32_t  size;
+    int32_t  count;
 };
 
 #define PVFS_DEV_MAGIC 'k'

Index: pint-dev.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/dev/pint-dev.c,v
diff -p -u -r1.33 -r1.34
--- pint-dev.c	16 Oct 2006 15:54:56 -0000	1.33
+++ pint-dev.c	4 Dec 2006 06:18:25 -0000	1.34
@@ -27,6 +27,7 @@
 #include "gossip.h"
 #include "pint-dev.h"
 #include "pvfs2-dev-proto.h"
+#include "pvfs2-internal.h"
 
 static int setup_dev_entry(
     const char *dev_name);
@@ -41,6 +42,9 @@ static int32_t pdev_magic;
 static int32_t pdev_max_upsize;
 static int32_t pdev_max_downsize;
 
+int32_t pvfs2_bufmap_total_size, pvfs2_bufmap_desc_size;
+int32_t pvfs2_bufmap_desc_count, pvfs2_bufmap_desc_shift;
+
 /* PINT_dev_initialize()
  *
  * initializes the device management interface
@@ -147,34 +151,54 @@ void PINT_dev_finalize(void)
  *
  * returns 0 on success, -PVFS_error on failure
  */
-int PINT_dev_get_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc, int *size)
+int PINT_dev_get_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc,
+                                struct PINT_dev_params *params)
 {
     int i, ret = -1;
-    int page_count = 0;
-    long page_size = sysconf(_SC_PAGE_SIZE);
+    uint64_t page_size = sysconf(_SC_PAGE_SIZE), total_size;
     void *ptr = NULL;
     int ioctl_cmd[2] = {PVFS_DEV_MAP, 0};
 
     for (i = 0; i < ndesc; i++)
     {
+        total_size = params[i].dev_buffer_size * params[i].dev_buffer_count;
+        if (total_size < 0) 
+        {
+            gossip_err("Error:please provide sane values for device parameters.\n");
+            break;
+        }
+        if (total_size % page_size != 0) 
+        {
+            gossip_err("Error: total device buffer size must be a multiple of system page size.\n");
+            break;
+        }
+        if (total_size >= PVFS2_BUFMAP_MAX_TOTAL_SIZE)
+        {
+            gossip_err(
+                "Error: total size (%llu) of device "
+                "buffer must be < %d MB.\n",
+                llu(total_size), PVFS2_BUFMAP_MAX_TOTAL_SIZE);
+            break;
+        }
+        if (params[i].dev_buffer_size & (params[i].dev_buffer_size - 1))
+        {
+            gossip_err("Error: descriptor size must be a power of 2 (%llu)\n",
+                        llu(params[i].dev_buffer_size));
+            break;
+        }
         /* we would like to use a memaligned region that is a multiple
          * of the system page size
          */
-        page_count = (int)(size[i] / page_size);
-        if ((size[i] % page_size) != 0)
-        {
-            page_count++;
-        }
-
-        ptr = PINT_mem_aligned_alloc(
-            (page_count * page_size), page_size);
+        ptr = PINT_mem_aligned_alloc(total_size, page_size);
         if (!ptr)
         {
             desc[i].ptr = NULL;
             break;
         }
         desc[i].ptr  = ptr;
-        desc[i].size = (page_count * page_size);
+        desc[i].total_size = total_size;
+        desc[i].size = params[i].dev_buffer_size;
+        desc[i].count = params[i].dev_buffer_count;
 
         /* ioctl to ask driver to map pages if needed */
         if (ioctl_cmd[i] != 0)
@@ -184,6 +208,10 @@ int PINT_dev_get_mapped_regions(int ndes
             {
                 break;
             }
+            pvfs2_bufmap_desc_count = params[i].dev_buffer_count;
+            pvfs2_bufmap_desc_size  = params[i].dev_buffer_size;
+            pvfs2_bufmap_total_size = total_size;
+            pvfs2_bufmap_desc_shift = LOG2(pvfs2_bufmap_desc_size);
         }
     }
     if (i != ndesc) {
@@ -223,7 +251,7 @@ void PINT_dev_put_mapped_regions(int nde
 
 /* PINT_dev_get_mapped_buffer()
  *
- * returns a memory buffer of size PVFS2_BUFMAP_DEFAULT_DESC_SIZE
+ * returns a memory buffer of size (pvfs2_bufmap_desc_size)
  * matching the specified buffer_index given a PVFS_dev_map_desc
  *
  * returns a valid desc addr on success, NULL on failure
@@ -240,10 +268,10 @@ void *PINT_dev_get_mapped_buffer(
         return NULL;
 
     desc_count = (bm_type == BM_IO) ? 
-                PVFS2_BUFMAP_DESC_COUNT :
-                PVFS2_READDIR_DESC_COUNT;
+                pvfs2_bufmap_desc_count :
+                PVFS2_READDIR_DEFAULT_DESC_COUNT;
     desc_size  = (bm_type == BM_IO) ? 
-                PVFS2_BUFMAP_DEFAULT_DESC_SIZE : 
+                pvfs2_bufmap_desc_size : 
                 PVFS2_READDIR_DEFAULT_DESC_SIZE;
     ptr =  (char *) desc[bm_type].ptr;
     return ((desc && ptr &&

Index: pint-dev.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/dev/pint-dev.h,v
diff -p -u -r1.14 -r1.15
--- pint-dev.h	13 Sep 2006 20:22:51 -0000	1.14
+++ pint-dev.h	4 Dec 2006 06:18:25 -0000	1.15
@@ -29,6 +29,12 @@ enum PINT_dev_buffer_type
     PINT_DEV_EXT_ALLOC = 2
 };
 
+struct PINT_dev_params 
+{
+    uint32_t dev_buffer_count;
+    uint64_t dev_buffer_size;
+};
+
 int PINT_dev_initialize(
     const char* dev_name,
     int flags);
@@ -36,7 +42,7 @@ int PINT_dev_initialize(
 int PINT_dev_get_mapped_regions(
     int ndesc,
     struct PVFS_dev_map_desc *desc,
-    int *size);
+    struct PINT_dev_params *params);
 
 void PINT_dev_put_mapped_regions(
     int ndesc,



More information about the Pvfs2-cvs mailing list