All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] [bugfix] loop.c
@ 2007-03-23 14:04 Tomas M
  2007-03-23 14:18 ` Jiri Kosina
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Tomas M @ 2007-03-23 14:04 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 966 bytes --]

I posted this yesterday but it seems people didn't understand the real 
goal of my patch. So I will explain once more again:

This is a bugfix for loop.c block driver, as it currently allocates more 
memory then it needs, without any further use.

If 'max_loop=255' parameter is given, the loop.c driver allocates this 
amount of memory:

   kmalloc(max_loop * sizeof(struct loop_device))

But in this case, (max_loop * sizeof) is greater than 65536, and thus 
kmalloc must allocate the next bigger size (which is 128KB of RAM).

Unfortunately the loop.c driver doesn't allow users to use bigger 
max_loop then 255 (for reasons which are completely obsolete) so the 
rest of memory is *unused*.

This patch doesn't fix unused memory in the case of max_loop=255, but 
rather it allows user to specify bigger max_loop (up to 455 on 386), so 
  the user can fully use all the memory, which would be allocated anyway.

Thank you for your consideration

Tomas M
slax.org

[-- Attachment #2: loop.c.diff --]
[-- Type: text/x-patch, Size: 1048 bytes --]

--- linux/drivers/block/loop.c_old	2007-03-23 14:27:04.000000000 +0000
+++ linux/drivers/block/loop.c	2007-03-23 14:31:18.098458759 +0000
@@ -1358,7 +1358,7 @@
  * And now the modules code and kernel interface.
  */
 module_param(max_loop, int, 0);
-MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-256)");
+MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (455/355 on x86/x86_64)");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
 
@@ -1402,9 +1402,9 @@
 {
 	int	i;
 
-	if (max_loop < 1 || max_loop > 256) {
-		printk(KERN_WARNING "loop: invalid max_loop (must be between"
-				    " 1 and 256), using default (8)\n");
+	if (max_loop < 1) {
+		printk(KERN_WARNING "loop: invalid max_loop (must be at least 1"
+				    ", using default (8)\n");
 		max_loop = 8;
 	}
 
@@ -1465,7 +1465,7 @@
 	kfree(loop_dev);
 out_mem1:
 	unregister_blkdev(LOOP_MAJOR, "loop");
-	printk(KERN_ERR "loop: ran out of memory\n");
+	printk(KERN_ERR "loop: ran out of memory for max_loop=%d\n", max_loop);
 	return -ENOMEM;
 }
 

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

end of thread, other threads:[~2007-03-23 23:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-23 14:04 [patch] [bugfix] loop.c Tomas M
2007-03-23 14:18 ` Jiri Kosina
2007-03-23 14:19 ` Eric Dumazet
2007-03-23 14:25   ` Jiri Kosina
2007-03-23 14:51     ` Eric Dumazet
2007-03-23 19:50       ` Michael Tokarev
2007-03-23 23:18         ` Jiri Kosina
2007-03-23 14:33   ` William Lee Irwin III
2007-03-23 14:36   ` Al Viro
2007-03-23 14:48     ` Eric Dumazet
2007-03-23 14:56       ` Al Viro
2007-03-23 14:41 ` Christoph Hellwig
2007-03-23 14:49   ` Al Viro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.