Page MenuHomeFreeBSD

netlink: Optimize growing the snl_writer message buffer
Needs ReviewPublic

Authored by jhb on Wed, Dec 10, 3:32 PM.

Details

Summary

Optimize the case that the current write buffer grown by
snl_realloc_msg_buffer is allocated at the end of the associated
snl_state's current linear buffer if the linear buffer has room for
the new size. In that case, simply reuse the existing space in
the linear buffer by bumping the offset of the linear buffer for
the updated size.

Sponsored by: AFRL, DARPA

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69160
Build 66043: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Wed, Dec 10, 3:32 PM
sys/netlink/netlink_snl.h
126

It is debatable if this should be zeroing any padding due to rounding up the length of the previous allocation. That padding should have already been zeroed by the previous lb_allocz or lb_extendz which is why I went with the simple approach here.

Actually, I just looked and lb_allocz doesn't do an explicit memset but instead depends on the original calloc anyway, so maybe I should drop the memset entirely.

sys/netlink/netlink_snl.h
126

I don't think this API/KPI provides any guarantees that allocated memory is zeroed. As consumer fills a message, they are supposed to fill it in a non-sparse manner.

sys/netlink/netlink_snl.h
126

I think the 'z' in lb_allocz does imply zeroing, and the way it works today is that lb_init uses calloc for its backing store when it is first allocated.