From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from black.elm.relay.mailchannels.net (black.elm.relay.mailchannels.net [23.83.212.19]) by sourceware.org (Postfix) with ESMTPS id AAA753857BB3 for ; Tue, 4 Jul 2023 11:18:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AAA753857BB3 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=sourceware.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 02DE1500FCB; Tue, 4 Jul 2023 11:18:07 +0000 (UTC) Received: from pdx1-sub0-mail-a286.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4253E501485; Tue, 4 Jul 2023 11:18:06 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1688469486; a=rsa-sha256; cv=none; b=3vjN6qTnXemTZYr13jmtEmEiuET6hy6pSQJ3JuGi+bNS3HLsKIPqLmRSB1OTlanAh6fHUK jDo4mX3ZZOFbWzo5hanlOZWm9s2o+9SW06/a3MxHajEmMahaDo0XE2Nf7AvaYQyRRKaYbq zK9+pISa9g3ysYJTiumUPs1HJ6bVX5iwuqM/mr4llRA6RHZUtfGdR/Um9r1cHnK8GdkojV VmNiQKxOVpbdcLWAx1oH3bjfrcSd1zQbKYQfS5b/cK4YXboBNb3dKaSKZMb/17sGfgowp9 GoFxrMRV6RHnEn6wt1qM9mh4UcKimBgpb0LMR8uFYYWGlMolpEMFVfW1S98F4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1688469486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CTZMidw2Hhb243brwbEWc86aNCDnYpDrnWbGtU/PV8g=; b=KvkRjJbQd9/raoR3D/ZcaYYNKimraJpCKYg7tu945ep7UNeXIaIF3Zyc6xBbHEBwxtHWkp YcOlY6HQ0ehbw2V/gWDDaiDbqdybov7lx4cv3BRAbXxPOoVaxF+4AlhYrPj8zrjIY41U+s gAYGeQC4jVi46prd9rItL1WHHU0dxqKgDo+DELARYjOFoy7iZxDyUhWEIO6OgHDfxlGsSE /g4PmSXv3QYbUlrkHxVwkY5yQhlemOv9EC/Xt4TFbLHeo3X1Xx4rZ/CZ8XTcMw4HWwXhG/ hrRanIWcvbFwR4NL4MXzvYeqdOS36Bb+cawQSB7QiHUp7GpuPegqE5bc8CaKOg== ARC-Authentication-Results: i=1; rspamd-85899d6fcc-j5s7l; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MC-Copy: stored-urls X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Slimy-Suffer: 4ac48c8507654826_1688469486586_397534248 X-MC-Loop-Signature: 1688469486586:3283269867 X-MC-Ingress-Time: 1688469486586 Received: from pdx1-sub0-mail-a286.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.49.251 (trex/6.9.1); Tue, 04 Jul 2023 11:18:06 +0000 Received: from [192.168.0.182] (unknown [174.91.45.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a286.dreamhost.com (Postfix) with ESMTPSA id 4QwKz15nshzNw; Tue, 4 Jul 2023 04:18:05 -0700 (PDT) Message-ID: Date: Tue, 4 Jul 2023 07:17:54 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] realloc: Return unchanged if request is within usable size To: Wilco Dijkstra , 'GNU C Library' References: <3cc4e7f1-fa60-edf7-c31b-a3ba34ae4eab@sourceware.org> Content-Language: en-US From: Siddhesh Poyarekar Cc: nicolas@freedelity.be In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1166.1 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. > 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. Thanks, Sid [1] https://sourceware.org/bugzilla/show_bug.cgi?id=30579