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 2A4003858418 for ; Mon, 19 Sep 2022 13:46:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A4003858418 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=1663595185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dQTj4AUKndeYw0PT4lSEX1SEYpi9GPoXeCTz0j0g6r8=; b=SOY0/usX28vapChJ3KGnoFAOI3F0P43dD0g8b5NuDUJEAm1ofzSxsoMhnmDHB8aiO0gkrc RXMux4RyQcihH0EiNbabREA4dQIOOOlwchPxZAdo4lxwR22pfZz3wltKQjL1TRuEPHFw6C ORgQ80yh2hR9GFxRQh/dCLaLF9DmFIc= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-167-aidF4KjUMpaStK54jBxqUA-1; Mon, 19 Sep 2022 09:46:23 -0400 X-MC-Unique: aidF4KjUMpaStK54jBxqUA-1 Received: by mail-ed1-f70.google.com with SMTP id z9-20020a05640235c900b0044f0575e9ddso20256423edc.1 for ; Mon, 19 Sep 2022 06:46:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=dQTj4AUKndeYw0PT4lSEX1SEYpi9GPoXeCTz0j0g6r8=; b=45ZXqK5/O4papjv4bsyndYhcZjkAGD3SYdOWUzn3C5no2spWgMgXJV0pi4n/RLKUmU mnYDmX8Nk7Fisad0RR0VEM0BiwFzImflms2aUBFiOJ8QoSTDgbFxn6Dj/JgANd9PJEnJ 2pDz6yjekaM76Q6BFZY/EuLnT0oAkoS74VdEpwv02pYUoNrUbo/ccK3Raz6n/f9zDdFR DWU4N3KsqKArs0mTu+vA7zUlgJEZncyiQIdys5JcnWI5R8hosR8NkNf9PQfqg22VTkSl wXJcPf/EvsYIPg4CvdMzTQujJVjRAqm3Y1m3cLzfejUFGmVgxCI+6UqZV+rsBmn9ZOH7 8p4w== X-Gm-Message-State: ACrzQf39hTreCvV9DpA8X1AdEeb15OIbApMjTiBwg08PRtlnnAidbzOw GQdYNegldoUmNUm0MnhqRtdIk1ga534+iyaFPlaDUfVO4e2ZQHDMKcEzDnLC4CI3eCvdF/kSUil 1CrcSDmKKU5Izj0FxAA== X-Received: by 2002:a17:907:96ab:b0:779:b7d8:41ba with SMTP id hd43-20020a17090796ab00b00779b7d841bamr13106004ejc.449.1663595182206; Mon, 19 Sep 2022 06:46:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rIw5CFbvW4zZ+uE7X+4HUeIeCYcFmG+Eef2QQarhQMZTrFYEC0CBuIE3BV5OSsORlnsxcCw== X-Received: by 2002:a17:907:96ab:b0:779:b7d8:41ba with SMTP id hd43-20020a17090796ab00b00779b7d841bamr13105997ejc.449.1663595181992; Mon, 19 Sep 2022 06:46:21 -0700 (PDT) Received: from [192.168.188.47] (dynamic-077-006-064-152.77.6.pool.telefonica.de. [77.6.64.152]) by smtp.gmail.com with ESMTPSA id cf16-20020a0564020b9000b0044fc3c0930csm20165957edb.16.2022.09.19.06.46.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 06:46:21 -0700 (PDT) Message-ID: Date: Mon, 19 Sep 2022 15:46:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH v4] eliminate mutex in fast path of __register_frame To: Thomas Neumann , gcc-patches@gcc.gnu.org References: <2a4776b9-9271-bb3c-a626-d5ec22dae6f3@in.tum.de> From: Stephan Bergmann In-Reply-To: <2a4776b9-9271-bb3c-a626-d5ec22dae6f3@in.tum.de> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_LOTSOFHASH,KAM_SHORT,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP 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 16/09/2022 12:19, Thomas Neumann via Gcc-patches wrote: > The __register_frame/__deregister_frame functions are used to register > unwinding frames from JITed code in a sorted list. That list itself > is protected by object_mutex, which leads to terrible performance > in multi-threaded code and is somewhat expensive even if single-threaded. > There was already a fast-path that avoided taking the mutex if no > frame was registered at all. > > This commit eliminates both the mutex and the sorted list from > the atomic fast path, and replaces it with a btree that uses > optimistic lock coupling during lookup. This allows for fully parallel > unwinding and is essential to scale exception handling to large > core counts. I haven't debugged this in any way, nor checked whether it only impacts exactly my below scenario, but noticed the following: At least when building LibreOffice with Clang (16 trunk) with ASan and UBsan enabled against libstdc++ (with --gcc-toolchain and LD_LIBRARY_PATH to pick up a libstdc++ trunk build including this change at build and run-time), at least one of the LibreOffice tests executed during the build started to fail with > Thread 1 "cppunittester" received signal SIGABRT, Aborted. > __pthread_kill_implementation (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0)Downloading 0.00 MB source file /usr/src/debug/glibc-2.36-4.fc37.x86_64/nptl/pthread_kill.c > at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##nptl##pthread_kill.c:44 > 44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0; > (gdb) bt > #0 __pthread_kill_implementation (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##nptl##pthread_kill.c:44 > #1 0x00007ffff6dcdd33 in __pthread_kill_internal (signo=6, threadid=) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##nptl##pthread_kill.c:78 > #2 0x00007ffff6d7daa6 in __GI_raise (sig=sig@entry=6) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##signal##..##sysdeps##posix##raise.c:26 > #3 0x00007ffff6d677fc in __GI_abort () at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##stdlib##abort.c:79 > #4 0x00007ffff6f377e8 in __deregister_frame_info_bases (begin=) at ~/gcc/trunk/src/libgcc/unwind-dw2-fde.c:285 > #5 __deregister_frame_info_bases (begin=) at ~/gcc/trunk/src/libgcc/unwind-dw2-fde.c:223 > #6 0x00007fffc7c3b53f in __do_fini () at ~/lo/core/instdir/program/libcairo.so.2 > #7 0x00007ffff7fcda9e in _dl_fini () at ~/.cache/debuginfod_client/653dfb54d6e6d9c27c349f698a8af1ab86d5501d/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##elf##dl-fini.c:142 > #8 0x00007ffff6d7ff35 in __run_exit_handlers (status=0, listp=0x7ffff6f13840 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##stdlib##exit.c:113 > #9 0x00007ffff6d800b0 in __GI_exit (status=) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##stdlib##exit.c:143 > #10 0x00007ffff6d68517 in __libc_start_call_main (main=main@entry=0x5555556c9ef0 , argc=argc@entry=24, argv=argv@entry=0x7ffffffefbf8) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##csu##..##sysdeps##nptl##libc_start_call_main.h:74 > #11 0x00007ffff6d685c9 in __libc_start_main_impl (main=0x5555556c9ef0 , argc=24, argv=0x7ffffffefbf8, init=, fini=, rtld_fini=, stack_end=0x7ffffffefbe8) at ~/.cache/debuginfod_client/a6572cd46182057d3dbacf1685a12edab0e2eda1/source##usr##src##debug##glibc-2.36-4.fc37.x86_64##csu##..##csu##libc-start.c:381 > #12 0x00005555555f1575 in _start () and which went away again when locally reverting this "eliminate mutex in fast path of __register_frame".