[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071024023512.GW27248@parisc-linux.org>
Date: Tue, 23 Oct 2007 20:35:12 -0600
From: Matthew Wilcox <matthew@....cx>
To: Eric St-Laurent <ericstl34@...patico.ca>
Cc: torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org,
Matthew Wilcox <willy@...ux.intel.com>
Subject: Re: [PATCH 1/4] stringbuf: A string buffer implementation
On Tue, Oct 23, 2007 at 10:19:06PM -0400, Eric St-Laurent wrote:
> I don't know if copy-on-write semantics are really useful for current
> in-kernel uses, but I've coded and used a C++ string class like this in
> the past:
CoW isn't in the slightest bit helpful. The point of these is to
provide an accumulator, therefore the majority of accesses to these
stringbufs are writes.
> Multiple string objects can share the same data, by increasing the nrefs
> count, a new data is allocated if the string is modified and nrefs > 1.
If we were trying to get rid of char * throughout the kernel, that might
make some sense; stringbufs have a more limited target though.
> Even without copy-on-write semantics and reference counting, I think
> this approach is better because it uses 1 less "object" and allocation:
>
> struct string - "handle" (pointer really) to string data
> struct string_data - string data
>
> versus:
>
> struct stringbuf *sb - pointer to string object
> struct stringbuf - string object
> char *s (member of stringbuf) - string data
I think you missed the part of the patch where I said that the stringbuf
is normally allocated on the stack or as part of some other structure.
The only thing that should be allocated is the string itself.
--
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."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists