Re: [PATCH 1/1] IPC - Do not use a negative value to re-enable msgmni automatic recomputing

Andrew Morton
2008-07-22T10:41:17Z

On Fri, 04 Jul 2008 08:37:16 +0200 Nadia.Derbey@bull.net wrote:

> Resending after fixing the issues pointed out by Matt.
> Now applies to 2.6.26-rc8-mm1.
>
> [PATCH 01/01]
>
> This patch proposes an alternative to the "magical positive-versus-negative
> number trick" Andrew complained about last week in
> http://lkml.org/lkml/2008/6/24/418.
>
> This had been introduced with the patches that scale msgmni to the amount of
> lowmem. With these patches, msgmni has a registered notification routine
> that recomputes msgmni value upon memory add/remove or ipc namespace creation/
> removal.
>
> When msgmni is changed from user space (i.e. value written to the proc file),
> that notification routine is unregistered, and the way to make it registered
> back is to write a negative value into the proc file. This is the "magical
> positive-versus-negative number trick".
>
> To fix this, a new proc file is introduced: /proc/sys/kernel/auto_msgmni.
> This file acts as ON/OFF for msgmni automatic recomputing.
>
> With this patch, the process is the following:
> 1) kernel boots in "automatic recomputing mode"
> /proc/sys/kernel/msgmni contains the value that has been computed (depends
> on lowmem)
> /proc/sys/kernel/automatic_msgmni contains "1"
>
> 2) echo <val> > /proc/sys/kernel/msgmni
> . sets msg_ctlmni to <val>
> . de-activates automatic recomputing (i.e. if, say, some memory is added
> msgmni won't be recomputed anymore)
> . /proc/sys/kernel/automatic_msgmni now contains "0"
>
> 3) echo "0" > /proc/sys/kernel/automatic_msgmni
> . de-activates msgmni automatic recomputing
> this has the same effect as 2) except that msg_ctlmni's value stays
> blocked at its current value)
>
> 3) echo "1" > /proc/sys/kernel/automatic_msgmni
> . recomputes msgmni's value based on the current available memory size
> and number of ipc namespaces
> . re-activates automatic recomputing for msgmni.
>

Sigh. I suppose it's a bit better.

> ---
> include/linux/ipc_namespace.h | 3 +
> ipc/ipc_sysctl.c | 72 ++++++++++++++++++++++++++++++++++--------
> ipc/ipcns_notifier.c | 20 ++++++++---

Could we get this all documented for our poor users please?

Documentation/filesystems/proc.txt is probably the most appropriate
place.