From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7D44B3858D38 for ; Wed, 12 Oct 2022 20:48:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D44B3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665607704; 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: in-reply-to:in-reply-to:references:references; bh=rtnc0lBfqgoNK055lOBcbEsqKjvx8F/83C2hE4t3LU0=; b=T9m57JrdkObxSBAV3ZSlyOsSKdQibRi9gQ3fseW9SR3Gtd5CXh/Hh7iYS2+z5Mo5DIYRlE ELsibfnmKyUJrLTyoUAly44NiOg8P/J0YnhGcWkqXw6FatU3MkSG4Ho7I4EfRgi0lj0TZb IQRN+ZuFvBsW6BDWL3ZQXR7e56+yVGk= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-589-bLTy7x0VN1G7IMzn6A-Dew-1; Wed, 12 Oct 2022 16:48:22 -0400 X-MC-Unique: bLTy7x0VN1G7IMzn6A-Dew-1 Received: by mail-qk1-f197.google.com with SMTP id u7-20020a05620a0c4700b006ee526183fcso6255698qki.8 for ; Wed, 12 Oct 2022 13:48:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rtnc0lBfqgoNK055lOBcbEsqKjvx8F/83C2hE4t3LU0=; b=Jij8YtE/BRj0OVjghjVx1cnVRR7b09bJL9z/ObFyWjMhkiZj7nBmQ7K3eZGfK1JNXJ OTPG1JJOQ6Og3uYLt3AZ/kUrCVOxPq236+CYurCzrjRAoCCxpHBA+tgzQOpM7McOiI/L QTAcuitBgDVwYL2hNlIn20wHr4ykt2ncUDuzs+CYiAGZL+G5eyMea8FvSoRY09Q64XBT WKuRl4DXPc8xYFRjkTJesT2iNd6IcCNd3IwbxA7u+ZnKb5JrhW9s2xFqtz6fKxCFl+4A 6J3+Sl7dYZvneNd2Ga6Gj/ffCYSqDY19YAAhRjbxeEM2vT3esJ5NIjwy0V6iy+GmqQrc lsgw== X-Gm-Message-State: ACrzQf37GYaVQ+hRjlsljrzsiKNfEAT2YuOUO1yCOW8bIdoj9gWm5fR/ VPdQH/jVRWQ3BAePkxkLz5Xcg9wCOOXevubUVZRyrFVfxLquiICueurD8IuatahxuRhr49TrWy9 MTxy9Wzs8pe2g3re6Zp7GgzvmUEoq8Qk= X-Received: by 2002:a05:622a:653:b0:39c:289c:6dec with SMTP id a19-20020a05622a065300b0039c289c6decmr9155385qtb.165.1665607701885; Wed, 12 Oct 2022 13:48:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/kr4QExYBZZ3QrdnxlGL1KeyNzV0qKbcVpsOlmCcKffeOF6oohErMbvwYogutnaTgSYtKHfTHDgyWL65e/ks= X-Received: by 2002:a05:622a:653:b0:39c:289c:6dec with SMTP id a19-20020a05622a065300b0039c289c6decmr9155374qtb.165.1665607701657; Wed, 12 Oct 2022 13:48:21 -0700 (PDT) MIME-Version: 1.0 References: <019f1d36fd8e730634ae4a764b2c56b6eb59b673.camel@espressif.com> In-Reply-To: <019f1d36fd8e730634ae4a764b2c56b6eb59b673.camel@espressif.com> From: Jonathan Wakely Date: Wed, 12 Oct 2022 21:48:10 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Configurable exception emergency pool size To: Alexey Lapshin Cc: "libstdc++@gcc.gnu.org" , Ivan Grokhotkov , Alexey Gerenkov , Anton Maklakov X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham 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 Wed, 12 Oct 2022 at 20:30, Alexey Lapshin via Libstdc++ wrote: > > From 8b27091310d2857880d8733a05813ca92a5a3e6f Mon Sep 17 00:00:00 2001 > From: Alexey Gerenkov > Date: Thu, 16 Nov 2017 15:06:35 +0300 > Subject: [PATCH] libstdc++: Configurable exception emergency pool size This patch won't apply to trunk because of https://gcc.gnu.org/g:637e3668fdc17c4e226538fb14f9fab225433d01 Please take a look at that (and the follow up in 23c3cbaed36f6d2f3a7a64f6ebda69329723514b) and decide if you still want to change anything. In any case, I think some targets don't support __attribute((weak)) so any change like that would have to make it conditional (possibly on __GXX_WEAK__ but I'm not sure if that's the right check). > --- > libstdc++-v3/libsupc++/eh_alloc.cc | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++- > v3/libsupc++/eh_alloc.cc > index 68f319869f9..6503041c20a 100644 > --- a/libstdc++-v3/libsupc++/eh_alloc.cc > +++ b/libstdc++-v3/libsupc++/eh_alloc.cc > @@ -50,12 +50,13 @@ extern "C" void *memset (void *, int, std::size_t); > > using namespace __cxxabiv1; > > -// ??? How to control these parameters. > - > // Guess from the size of basic types how large a buffer is > reasonable. > // Note that the basic c++ exception header has 13 pointers and 2 > ints, > // so on a system with PSImode pointers we're talking about 56 bytes > // just for overhead. > +// To fix this: > +// Implement C function __cxx_eh_arena_size_get() in your codebase > which > +// returns size (size_t) for buffer to allocate. > > #if INT_MAX == 32767 > # define EMERGENCY_OBJ_SIZE 128 > @@ -73,6 +74,12 @@ using namespace __cxxabiv1; > # define EMERGENCY_OBJ_COUNT 4 > #endif > > +extern "C" __attribute__((weak)) size_t __cxx_eh_arena_size_get(void) > +{ > + return EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT > + + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception); > +} > + > namespace __gnu_cxx > { > void __freeres(); > @@ -116,11 +123,8 @@ namespace > > pool::pool() > { > - // Allocate the arena - we could add a GLIBCXX_EH_ARENA_SIZE > environment > - // to make this tunable. > - arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT > - + EMERGENCY_OBJ_COUNT * sizeof > (__cxa_dependent_exception)); > - arena = (char *)malloc (arena_size); > + arena_size = __cxx_eh_arena_size_get(); > + arena = arena_size ? (char *)malloc (arena_size) : NULL; > if (!arena) > { > // If the allocation failed go without an emergency pool. > -- > 2.34.1 >