From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id 07B0B382CA55 for ; Sun, 18 Sep 2022 09:00:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07B0B382CA55 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DyFqdgGF+JcI9W4h+5BCgRDnjty70JfxFDXIbSFGpU0=; b=F/pj7RC+JNSt0mE5v54hzQM8h1 DCl59tQmQOHtzDStWmCqIQIyH6DnLBk5SfQ8Rqxogtmj+J+nftBV8nz/DwXU0usxGaS1mR9vjNv3J l3MYhBH0EwgnjI/iZSjZarYrofytljuZsKHJKatS8wWXxyTspNIECbKiplYzbtuF3DX8ieAXsqt9S 38KDVRKjFpTbIQMmIY7rbmsyEO/c9S9S9J6lNFQRKdir0UEo6BQEpQSkqyLUn78Et9cpq212GqlNp i97+1DhgoBGS9UvRyItCDrQPgjPMt/KHH/ZRSCMlLNbGUT1hGnLUJkP4mB4AQYTONzyrTgKUFu/dU ANdvWqdQ==; Received: from [95.87.234.74] (port=59398 helo=localhost) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oZq9c-00045j-GY; Sun, 18 Sep 2022 11:59:58 +0300 Date: Sun, 18 Sep 2022 11:59:54 +0300 From: Dimitar Dimitrov To: Thomas Neumann Cc: gcc-patches@gcc.gnu.org, Jason Merrill , Florian Weimer , Jakub Jelinek , Jonathan Wakely Subject: Re: [PATCH v4] eliminate mutex in fast path of __register_frame Message-ID: References: <2a4776b9-9271-bb3c-a626-d5ec22dae6f3@in.tum.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2a4776b9-9271-bb3c-a626-d5ec22dae6f3@in.tum.de> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,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 Fri, Sep 16, 2022 at 12:19:36PM +0200, 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. > > Changes since v3: > - Avoid code duplication by adding query mode to classify_object_over_fdes > - Adjust all comments as requested > > libgcc/ChangeLog: > > * unwind-dw2-fde.c (release_registered_frames): Cleanup at shutdown. > (__register_frame_info_table_bases): Use btree in atomic fast path. > (__deregister_frame_info_bases): Likewise. > (_Unwind_Find_FDE): Likewise. > (base_from_object): Make parameter const. > (classify_object_over_fdes): Add query-only mode. > (get_pc_range): Compute PC range for lookup. > * unwind-dw2-fde.h (last_fde): Make parameter const. > * unwind-dw2-btree.h: New file. > --- > libgcc/unwind-dw2-btree.h | 953 ++++++++++++++++++++++++++++++++++++++ > libgcc/unwind-dw2-fde.c | 195 ++++++-- > libgcc/unwind-dw2-fde.h | 2 +- > 3 files changed, 1098 insertions(+), 52 deletions(-) > create mode 100644 libgcc/unwind-dw2-btree.h > Hi Thomas, This patch broke avr and pru-elf cross builds: gcc/libgcc/unwind-dw2-fde.c:680:28: error: unknown type name ‘uintptr_t’ 680 | uintptr_t *range) Should uintptr_t be replaced with __UINTPTR_TYPE__? Such change fixes the above broken builds for me. But I'm not sure how valid it is for that part of libgcc. Other embedded targets like arm-none-eabi are not broken because they overwrite LIB2ADDEH, and consequently unwind-dw2-fde.c is not built for them. Regards, Dimitar