Opened 15 years ago

Closed 13 years ago

#114 closed enhancement (fixed)

memory reservation feature needed

Reported by: pippijn Owned by: Jakub Jermář
Priority: major Milestone: 0.5.0
Component: helenos/kernel/generic Version: mainline
Keywords: allocation, malloc, memory, suggestion Cc: martin@…, jakub@…
Blocker for: Depends on:
See also:

Description

The following code works:

main(){ while (malloc (1024 * 1024)); }

but the next code does not:

main(){ while (memset (malloc (1024 * 1024), 0, 1024 * 1024)); }

The full test code I was using is attached.

Attachments (1)

malloc_test.c (280 bytes ) - added by pippijn 15 years ago.
malloc+memset test

Download all attachments as: .zip

Change History (10)

by pippijn, 15 years ago

Attachment: malloc_test.c added

malloc+memset test

comment:1 by Martin Decky, 15 years ago

And what should be the expected behaviour? In the first example you might be allocating 1 MB chunks (actually the kernel just commits the memory to you), but since you never touch most of the memory, the memory won't be actually assigned to you.

In the second example you actually force the kernel to assign the physical memory to you (in the page fault handler which gets triggered once you touch the memory using memset()). The physical memory runs out and your task gets blocked in the kernel, waiting for any physical memory to be released (by other tasks or possibly the kernel itself).

There has been some discussion recently how to allow the user to modify this kernel behaviour with respect to memory overcommit and deferred blocking in the page fault handler (see the long thread in our mailing list: http://lists.modry.cz/cgi-bin/private/helenos-devel/2009-August/005717.html).

BTW: Isn't there still an unrelated bug in your second code? When the malloc() returns NULL, you should not pass this NULL to memset(). Or am I missing something?

comment:2 by Martin Decky, 15 years ago

Cc: martin@… added

comment:3 by Jakub Jermář, 15 years ago

Cc: jakub@… added

comment:4 by Jakub Jermář, 15 years ago

Summary: memory allocation seems to be brokenmemory reservation feature needed
Type: defectenhancement

I am changing the synopsis and the type of this ticket as this is definitely not a bug, but a call for implementing memory reservations.

comment:5 by Jakub Jermář, 15 years ago

Milestone: 0.4.20.5.0

comment:6 by Jakub Jermář, 15 years ago

Keywords: suggestion added

comment:7 by Jakub Jermář, 14 years ago

Owner: set to Jakub Jermář
Status: newassigned

comment:8 by Jakub Jermář, 14 years ago

Milestone: 0.4.30.5.0

comment:9 by Jakub Jermář, 13 years ago

Resolution: fixed
Status: assignedclosed

Fixed in changeset:mainline,926.

Please log bugs against the implementation or suggestions on how to further improve it as separate ticket.

Note: See TracTickets for help on using tickets.