Re: [PATCH 1/4] stringbuf: A string buffer implementation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Matthew Wilcox
Date: Wednesday, October 24, 2007 - 7:02 am

On Wed, Oct 24, 2007 at 03:21:06PM +0200, Florian Weimer wrote:

I don't.  Strings should never be as long as 2GB.  To put this in
perspective, the *entire* Encyclopaedia Britannica (all 32 volumes)
is estimated at being 1GB of text.

While it would be a fair criticism that I haven't put a check for
overrunning 2GB in the code, the implementation relies on a single
continuous buffer from kmalloc, and that's currently limited to 33554432
bytes (32MB).  I don't foresee kmalloc's maximum size going up by 7
orders of magnitude -- and if it did, fragmentation would prevent you
from ever getting it.

So, I might consider a change to set -E2BIG instead of -ENOMEM if we
pass KMALLOC_MAX_SIZE, but I do think this criticism is rather straining
at gnats.

Also, 'alloc' can be an errno, and that is signalled by a negative number.
Yes, we could do something like if (sb->alloc > (unsigned)-4095) like
the mmap code does, but given the points above, it's just not worth doing.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/4] stringbuf: A string buffer implementation, Matthew Wilcox, (Tue Oct 23, 2:12 pm)
[PATCH 2/4] isdn: Use stringbuf, Matthew Wilcox, (Tue Oct 23, 2:12 pm)
[PATCH 3/4] sound: Use stringbuf, Matthew Wilcox, (Tue Oct 23, 2:12 pm)
[PATCH 4/4] partitions: Fix non-atomic printk, Matthew Wilcox, (Tue Oct 23, 2:12 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Linus Torvalds, (Tue Oct 23, 4:43 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Matthew Wilcox, (Tue Oct 23, 6:49 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Eric St-Laurent, (Tue Oct 23, 7:19 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Matthew Wilcox, (Tue Oct 23, 7:30 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Matthew Wilcox, (Tue Oct 23, 7:35 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Andrew Morton, (Tue Oct 23, 7:45 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Eric St-Laurent, (Tue Oct 23, 7:48 pm)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Florian Weimer, (Wed Oct 24, 6:21 am)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Matthew Wilcox, (Wed Oct 24, 7:02 am)
Re: [PATCH 3/4] sound: Use stringbuf, Takashi Iwai, (Wed Oct 24, 7:18 am)
Re: [PATCH 3/4] sound: Use stringbuf, Takashi Iwai, (Wed Oct 24, 7:50 am)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Matthew Wilcox, (Wed Oct 24, 8:30 am)
Re: [PATCH 3/4] sound: Use stringbuf, Matthew Wilcox, (Wed Oct 24, 9:01 am)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Pavel Machek, (Sat Oct 27, 12:31 am)
Re: [PATCH 1/4] stringbuf: A string buffer implementation, Denys Vlasenko, (Tue Oct 30, 8:26 am)