[svn-commits] sruffell: linux/trunk r7681 - /linux/trunk/drivers/dahdi/dahdi-base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 11 17:20:06 CST 2009


Author: sruffell
Date: Fri Dec 11 17:20:02 2009
New Revision: 7681

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7681
Log:
dahdi-base: Reduce the max allocation size in dahdi_reallocbufs.

Lower the maximum contiguous chunk that DAHDI asks for from
DAHDI_MAX_BUFFER_SIZE*2 to DAHDI_MAX_BUFFER_SIZE. With 4K pages, this can allow
the kernel to try a little harder to find the memory it needs since the request
goes from order 4 to order 3.

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=7681&r1=7680&r2=7681
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Fri Dec 11 17:20:02 2009
@@ -946,9 +946,12 @@
 	data[len - 1] = (fcs >> 8) & 0xff;
 }
 
-static int dahdi_reallocbufs(struct dahdi_chan *ss, int j, int numbufs)
-{
-	unsigned char *newbuf, *oldbuf;
+static int dahdi_reallocbufs(struct dahdi_chan *ss, int blocksize, int numbufs)
+{
+	unsigned char *newtxbuf = NULL;
+	unsigned char *newrxbuf = NULL;
+	unsigned char *oldtxbuf = NULL;
+	unsigned char *oldrxbuf = NULL;
 	unsigned long flags;
 	int x;
 
@@ -960,25 +963,32 @@
 		numbufs = DAHDI_MAX_NUM_BUFS;
 
 	/* We need to allocate our buffers now */
-	if (j) {
-		if (!(newbuf = kcalloc(j * 2, numbufs, GFP_KERNEL)))
+	if (blocksize) {
+		newtxbuf = kzalloc(blocksize * numbufs, GFP_KERNEL);
+		if (NULL == newtxbuf)
 			return -ENOMEM;
-	} else
-		newbuf = NULL;
-
-	/* Now that we've allocated our new buffer, we can safely
+		newrxbuf = kzalloc(blocksize * numbufs, GFP_KERNEL);
+		if (NULL == newrxbuf) {
+			kfree(newtxbuf);
+			return -ENOMEM;
+		}
+	}
+
+	/* Now that we've allocated our new buffers, we can safely
  	   move things around... */
 
 	spin_lock_irqsave(&ss->lock, flags);
 
-	ss->blocksize = j; /* set the blocksize */
-	oldbuf = ss->readbuf[0]; /* Keep track of the old buffer */
+	ss->blocksize = blocksize; /* set the blocksize */
+	oldrxbuf = ss->readbuf[0]; /* Keep track of the old buffer */
+	oldtxbuf = ss->writebuf[0];
 	ss->readbuf[0] = NULL;
 
-	if (newbuf) {
+	if (newrxbuf) {
+		BUG_ON(NULL == newtxbuf);
 		for (x = 0; x < numbufs; x++) {
-			ss->readbuf[x] = newbuf + x * j;
-			ss->writebuf[x] = newbuf + (numbufs + x) * j;
+			ss->readbuf[x] = newrxbuf + x * blocksize;
+			ss->writebuf[x] = newtxbuf + x * blocksize;
 		}
 	} else {
 		for (x = 0; x < numbufs; x++) {
@@ -997,7 +1007,7 @@
 
 	/* Keep track of where our data goes (if it goes
 	   anywhere at all) */
-	if (newbuf) {
+	if (newrxbuf) {
 		ss->inreadbuf = 0;
 		ss->inwritebuf = 0;
 	} else {
@@ -1021,8 +1031,8 @@
 
 	spin_unlock_irqrestore(&ss->lock, flags);
 
-	if (oldbuf)
-		kfree(oldbuf);
+	kfree(oldtxbuf);
+	kfree(oldrxbuf);
 
 	return 0;
 }




More information about the svn-commits mailing list