Diary
Just random thoughts.
The content of this page is highly volatile. I don't want to give each day and each thought a permalink. Some of these thoughts may grow to articles, some never won't. Thus, comments and webmentions will never be implemented for this page. But for archived pages, well, they might be.
Archives
2026-10-04
Phew, page allocator is more complicated than bitmap sub-allocator. More execution paths, more tests to do.
Alloc and grow are ready, shrink, free, and dump to go.
Two important points that make this allocator look efficient:
-
mremapcan re-map to a reserved block of memory. Moreover, the destination may contain committed pages -- they will be freed. This behavor is described on the man page. -
What is more important, it's
MREMAP_DONTUNMAPflag which makes possible "graceful free", keeping the memory reserved. Without this flagmremapwould leave a hole in a big page. That's not good in a multi-threaded environment.
Page allocator reserves so called big pages which are equal to huge pages. Although huge pages are not used directly, I bear them in mind.
♡♡♡
The amount of good humans does not increase. The opposite is always true. It's like entropy.
Yet another -1 last weekend.
That's sad.
I tried to be nice but they didn't get it. I should not have to, wish I let my organism out to bite them, but I did not want to catch bad karma and get stuck in this shithole for next three lives.
2026-10-01
If source code produces binaries that software developers distribute to bring food on their tables, the source code is the means of production for a developer.
Open source is a way to exproptiate those means of production thus bringing software developers down to slaves and the only thing they can sell is labor.
Some may object, take open source, make binaries, sell, make money. It's like clay, sculpt anything you want. Well, clay is not free, strictly speaking. Even water is not free nowadays. Moreover, following one popular license, if you make anything from free clay, those things must be free too. The only way to make money is to sculpt free things from free clay for someone.
It's a perfect slavery!
Of course it's a shitty analogy. Developers including me love taking such analogies out of thin air. Especially from fields in which they have neither comprehension nor skills.
Anyway, it smells so.
Some jurisdictions place the equal sign between source code and literary work. That not quite correct. Literary work is consumed by readers. By humans. Source code is beyond of comprehension of most of them. It's for machines. It can be written in a human-readable way but, heck, only few are able to do that.
Just thoughts. When it came to the end I started to guess.
♡♡♡
Sometimes windows API looks more consistent than unix mess. But I don't know if windows does not behaves the same way.
In unix the memory is allocated with mmap using anonymous mappings,
and pages are cleaned as expected. They contain only zeros.
But what if a page was reclaimed and then committed back again?
It stays dirty and needs explicit cleaning!
Unless the mapping was destroyed by munmap and then mmaped back again.
But that's troublesome approach if we need to decommit a hole that should stay reserved.
Say, we decommit a page in a reserved region.
Another thread may call mmap and break everything.
A man page on madvice explains this:
MADV_FREE: The kernel can thus free these pages, but the freeing could be delayed until memory pressure occurs. For each of the pages that has been marked to be freed but has not yet been freed, the free operation will be canceled if the caller writes into the page.
So, this sequence brings the same dirty page back into the addess space:
mprotect(page, 4096, PROT_NONE);
madvise(page, 4096, MADV_FREE);
mprotect(page, 4096, PROT_READ | PROT_WRITE);Actually, the page stayed in.
A couple of (ir)relevant links, more or less:
- https://stackoverflow.com/questions/2782628/any-way-to-reserve-but-not-commit-memory-in-linux
- https://unix.stackexchange.com/questions/405883/can-an-application-explicitly-commit-and-decommit-memory
And as a note for myself, do not forget about madvise when you'll get to thansparent huge pages.