Re: [RFC] should physmem be cgroup-aware?

Collin Funk <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
Lasse Collin <[email protected]> writes:

> On 2026-08-20 Pádraig Brady wrote:
>> Re syscall overhead, it's unfortunate, but I don't see a way around
>> that at present.
>
> The syscall count in get_cgroup2_cpu_quota could be reduced by 25 % by
> avoiding stdio. With glibc, fopen + getline + fclose is four syscalls:
> openat + fstat + read + close. Using open + read + close would need only
> three.
>
>> I do note that sort(1) uses both nproc() and physmem_total(), which
>> suggests a shared or cached interface may be useful, but that can
>> come at a later stage.
>
> One could cache the mount point and the cgroup path from
> /proc/self/cgroup. It would typically save 4-5 syscalls. I don't know
> if it's worth the extra code.

Agreed, it probably isn't worth the extra effort.

It would be nice to not duplicate code though. From my initial look at
implementing things yesterday I was thinking of putting cgroup2_mount
and the part of get_cgroup2_cpu_quota that reads "/proc/self/cgroup"
into a separate header/file.

> "sort /dev/null" (coreutils 9.11) makes over 40 rt_sigaction syscalls,
> so in sort(1) the cgroup related syscalls aren't so large portion of
> the total syscall count.

Yeah. I assume you probably knew already, but that is so we properly
clean up the temporary files. The slower start up time is nicer than
leaving junk on the file system. :)

Collin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.