Kernel SysV IPC defaults.

Chris Smith chris at nfluid.co.uk
Wed Mar 3 09:40:14 PST 2004


Hi all.
Probably no one has ever noticed, but if you look at the default ipc settings 
for message queues as defined by default are screwy.
(ipcs -T if you want to have a look).

Consider  MSGMAX (max bytes in a message) and MSGMNB (max bytes in a queue)
The defaults are MSGMAX > MSGMNB, which is clearly backwards.

I forget what the default kernel values actually are as I've recompiled the 
kernel to sort them out for my server, but it's something like MSGMAX = 4096 
and MSGMNB = 2048.

I ported my middleware a while ago to freebsd, but it failed to run as it was 
trying to put messages of 4096 bytes into a queue that can only contain at 
most 2048 bytes _in total_ for all messages in the queue.
Basically it allows someone to put half a message in a queue. Hehe :o)

I had to put a kludge in my middleware to use the smaller of MSGMAX and MSGMNB 
as the maximum message size - however this is terribly inefficient as it 
effectively means that you can only have one message in a queue at any one 
time, which defeats the point of having a queue, and makes the middelware 
perform extremely poorly.

The reason for emailing you is that for all my porting effort, you cannot use 
my middleware out-of-the-box on freebsd without a kernel rebuild - which is a 
shame, and has put people off.

The fix to this is to alter the two defaults in the relevent header file to 
more sensible values.  I wouldn't advocate making them too big, as it's 
sensless 'reserving' kernel space for something that is (I admit) rarely used 
- but values of msgmax 2048 or 4096 and msgmnb 4096 or 8192 seem sensible (if 
msgmnb is at least twice msgmax).
If you're going to use the middleware in anger, you'd tune your kernel by 
rebuilding anyway - but as it is, users are not getting this far!

Regards,
Chris
-- 
Chris Smith
  Technical Architect - netFluid Technology Ltd.
  "Internet Technologies, Distributed Systems and Tuxedo Consultancy"
  E: chris at nfluid.co.uk  W: http://www.nfluid.co.uk


More information about the freebsd-hackers mailing list