kiobuf setup overhead

Eric Barton (eric@bartonsoftware.com)
9 May 2001 10:08:55 +0100


I've noticed that alloc_kiovec() calls alloc_kiobuf_bhs(), which...

> int alloc_kiobuf_bhs(struct kiobuf * kiobuf)
> {
> int i;
>
> for (i = 0; i < KIO_MAX_SECTORS; i++)
> if (!(kiobuf->bh[i] = kmem_cache_alloc(bh_cachep, SLAB_KERNEL))) {
> while (i--) {
> kmem_cache_free(bh_cachep, kiobuf->bh[i]);
> kiobuf->bh[i] = NULL;
> }
> return -ENOMEM;
> }
> return 0;
> }

...where KIO_MAX_SECTORS is currently 1024. This makes a kiobuf quite a
heavy-weight object to allocate and free.

Was this high-overhead initialisation left in because kiobufs shouldn't be
allocated and freed at the drop of a hat in any case?

If not, allocating the kiobuf->bh[i], could be delayed until the number
required is known.

This would be beneficial for direct I/O in the scsi generic driver, which
currently allocates and frees a kiobuf on each read/write.

-- 

Cheers, Eric

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/