mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re:  ipc - msg : memory usage too big ?
@ 2002-10-03 16:39 Manfred Spraul
  2002-10-03 17:38 ` ipc - msg : a race bug ? (kernel 2.4.19) Cedric Roux
  0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2002-10-03 16:39 UTC (permalink / raw)
  To: Cedric Roux, linux-kernel

> If it is seen as a problem, a solution might be to add
> the memory overhead usage into the queue size, or add a
> variable that counts the real memory used, and limits it
> to a reasonable amount.
> 

The limit in the number of messages was added a few years ago, older 
linux kernels [2.0, early 2.2] contain no limit at all :-(

The implementation was choosen to avoid breaking apps that relied on the 
old behaviour: by default send x-byte messages, but if the queue is 
full, send a 0-byte, msgtype > 0 message that notifies a supervisor 
process that the queue is full.

SUS permits a global system imposed limit on the number of messages, but 
IMHO 9 MB is not excessive [actually, 16*9MB, once for each queue] - 
root can reduce the limit further, if users abuse it.

--
	Manfred


^ permalink raw reply	[flat|nested] 3+ messages in thread
* ipc - msg : memory usage too big ?
@ 2002-10-03 14:51 Cedric Roux
  0 siblings, 0 replies; 3+ messages in thread
From: Cedric Roux @ 2002-10-03 14:51 UTC (permalink / raw)
  To: linux-kernel

Hi kernel hackers,

While looking into msg.c, I noticed that in
sys_msgsnd, there is the test :

        if(msgsz + msq->q_cbytes > msq->q_qbytes ||
                1 + msq->q_qnum > msq->q_qbytes) {

so that you can send a message only if ressources won't
be exhausted.

The second case means I can send at most MSGMNB messages
to a queue, which is by default 16384.

Now suppose we send messages of length 0 (only type is used).

Knowing that load_msg calls :

        msg = (struct msg_msg *) kmalloc (sizeof(*msg) + alen, GFP_KERNEL);

it will result in allocating 36 bytes of memory (suppose we
are on a ia32) per message.

We have 16 queues by default, so if we use the 16 queues this way,
we have :
16 * 36 * 16384 = 9437184, more than 9 MB used.

I hope I am right :-)

Don't you think it is far beyond the 256 KB someone is
expected to be used at maximum for the msg stuff ?

If it is seen as a problem, a solution might be to add
the memory overhead usage into the queue size, or add a
variable that counts the real memory used, and limits it
to a reasonable amount.

Cédric.

PS: I am not on the kernel mailing list, so CC is welcome. (I know it is 
bad practice.)
-- 
main(){int i,j;{printf("\n      Who did you say ? Sierpinski ?      \n");}
for(i=0;i<80;i++){for(j=0;j<80;j++)printf("%c",i&j?'.':' ');printf("\n");}
printf("\n   Life is a beach - George Sand (1804-1876)  \n\n"); return 0;}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-03 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-03 16:39 ipc - msg : memory usage too big ? Manfred Spraul
2002-10-03 17:38 ` ipc - msg : a race bug ? (kernel 2.4.19) Cedric Roux
  -- strict thread matches above, loose matches on Subject: below --
2002-10-03 14:51 ipc - msg : memory usage too big ? Cedric Roux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®