vmalloc for zlib workspace

Jörn Engel joern at wohnheim.fh-wedel.de
Mon May 26 05:40:50 EDT 2003


On Sat, 24 May 2003 02:02:46 +0900, matsunaga wrote:
> >
> > int __init jffs2_zlib_init(void)
> > {
> > if (WORKSPACESIZE < zlib_deflate_workspacesize())
> > BUG();
> > if (WORKSPACESIZE < zlib_inflate_workspacesize())
> > BUG();
> > return 0;
> > }
> 
> That's great idea too ;-)

Thanks!

> We only have to check the size in init routine.

Actually, we could even go a bit further.  zlib itself could have a
single workspace and a mutex.  Then we would add the following code to
zlib_deflateInit2_():
	if (strm->workspace)
		mem = (deflate_workspace *) strm->workspace;
	else {
		down(&zlib_workspace_sem);
		mem = zlib_workspace;
	}

And this little feller to zlib_deflateEnd():
	up (&zlib_workspace_sem);

The same for inflate, of course, both using the same workspace and
semaphore.

Now every subsystem using zlib can reuse the same workspace, jffs2
anole would save one, a big fat system (TM) with jffs2, cramfs, ppp
and additional patches would save quite a bit more.  And those systems
do exist, no kidding.

And users that want to scale to 64 CPUs and use zlib concurrently on
all of them can still provide their own workspace.

Comments?

Jörn

-- 
A victorious army first wins and then seeks battle.
-- Sun Tzu



More information about the linux-mtd mailing list