All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomas M <tomas@slax.org>
To: linux-kernel@vger.kernel.org
Subject: [patch] [bugfix] loop.c
Date: Fri, 23 Mar 2007 15:04:54 +0100	[thread overview]
Message-ID: <4603DE86.1090009@slax.org> (raw)

[-- 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;
 }
 

             reply	other threads:[~2007-03-23 14:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-23 14:04 Tomas M [this message]
2007-03-23 14:18 ` [patch] [bugfix] loop.c 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4603DE86.1090009@slax.org \
    --to=tomas@slax.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.