From: Aurelien Jarno <aurelien@aurel32.net>
To: Siddhesh Poyarekar <siddhesh@sourceware.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
'GNU C Library' <libc-alpha@sourceware.org>,
nicolas@freedelity.be
Subject: Re: [PATCH] realloc: Return unchanged if request is within usable size
Date: Tue, 4 Jul 2023 18:08:32 +0200 [thread overview]
Message-ID: <ZKREAO1eEPmyBFnY@aurel32.net> (raw)
In-Reply-To: <b7b332fb-76fb-2c8e-366b-c94f67628702@sourceware.org>
Hi,
On 2023-07-04 07:17, Siddhesh Poyarekar via Libc-alpha wrote:
> On 2023-07-03 18:02, Aurelien Jarno wrote:
> > This actually breaks the KDE Plasma Desktop, and more precisely
> > plasmashell when used with long configuration files [1] [2]. This commit
> > causes the virtual memory allocation to increase from ~2GB to ~11GB in
> > my testcase, while the resident memory basically stays stable. In turns
> > this prevent the clone syscall to work with the default kernel
> > overcommit configuration.
> >
> > At this stage, I haven't identified the allocation pattern nor the
> > corresponding code in plasmashell.
>
> I had dismissed this in a recent bug report[1] but I'm obviously wrong. I
> think I could make this conditional on usable - bytes being within 2 *
> SIZE_T for heap allocations (thus only catering for expansions) and within
> trim_threshold for mmap'd allocations to reduce the fragmentation.
Just another datapoint that can be helpful: setting
glibc.malloc.trim_threshold to 128K (the initial value, but fixed) also
workarounds the issue. So it seems the issue is a combination of the
dynamic adjustment of trim_threshold and this change to realloc.
> > Besides tweaking the configuration files, possible workarounds are
> > defining the glibc.malloc.trim_threshold GLIBC tunable to a low value
> > (for instance 128) or changing the vm.overcommit_memory kernel
> > configuration to 1. I guess the latter doesn't work on 32-bit
> > architectures though.
>
> Right, the trim_threshold change was what I had suggested, but if it's
> impacting more than the odd application, the default behaviour is
> problematic. I'll try to post a fix today.
Great, thanks a lot.
Regards,
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://aurel32.net
next prev parent reply other threads:[~2023-07-04 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 9:22 Wilco Dijkstra
2022-11-28 14:13 ` Siddhesh Poyarekar
2022-12-06 12:45 ` Wilco Dijkstra
2022-12-06 18:41 ` Siddhesh Poyarekar
2023-07-03 22:02 ` Aurelien Jarno
2023-07-04 11:17 ` Siddhesh Poyarekar
2023-07-04 16:08 ` Aurelien Jarno [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-11-25 20:09 Siddhesh Poyarekar
2022-11-25 20:40 ` Andreas Schwab
2022-11-28 14:23 ` Siddhesh Poyarekar
2022-11-28 14:29 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZKREAO1eEPmyBFnY@aurel32.net \
--to=aurelien@aurel32.net \
--cc=Wilco.Dijkstra@arm.com \
--cc=libc-alpha@sourceware.org \
--cc=nicolas@freedelity.be \
--cc=siddhesh@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).