From patchwork Tue Aug 8 17:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 132589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2281046vqr; Tue, 8 Aug 2023 10:32:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkkwN4yfcvWjP4Q6H3ZfuA5VU+HTxIijhRFouiWhzC1RHha8x9TnDB4VFJ7vubBfKnkypg X-Received: by 2002:a2e:9c53:0:b0:2b6:a804:4cc with SMTP id t19-20020a2e9c53000000b002b6a80404ccmr111993ljj.53.1691515929823; Tue, 08 Aug 2023 10:32:09 -0700 (PDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a3-20020a1709063a4300b00991f834e0b3si7597910ejf.194.2023.08.08.10.32.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 10:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iMfx3W8j; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DFC038582BC for ; Tue, 8 Aug 2023 17:32:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DFC038582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691515928; bh=DfLXBxGJb4P6ZnhXi1Ak6xEedhFrTX778WrZ+lJIsrQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=iMfx3W8jl3Bpxy9ORuwBlQ0uosf7zix0V7vFeGoXnNeUmU+CD1HGtFfWmheexVUZG kzp1XpZ/38c4qMmOEYtqcDuLjIBNK9fMibsvLaWaRFobQGz2X2Dnmlqf0uWtgkCoPP uhWcmiN5bvt5BUJ+NM/zkC9/1HcHlqj7ITK2/NBQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 9C7D03858D20 for ; Tue, 8 Aug 2023 17:31:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C7D03858D20 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 378DAg0c024387 for ; Tue, 8 Aug 2023 17:31:20 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s9cuenqmh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 08 Aug 2023 17:31:19 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 378GxHOB021366 for ; Tue, 8 Aug 2023 17:31:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvcumvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 08 Aug 2023 17:31:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jdGhU0NmDHOQnp6JnzH5uaubDNMDIml4hr1N3pzWIvYDV77Btua0iWXODRq0m7nirTQh4FEsXKzDy47WAEj/eIzZYC7NaUt2ADKJyasbaPuki2s1gbIYBUgNWXA+AJ7mPOhGYLjoUHd12o5YRYBEvJwgt649FkoRmvEWIo0jQID8X8ZTCRCL97kEZnr+8CoLXIIxIW7dJaDGanL2k/GQXQMXNcmlmDVOqNLXXbLetN5pyaxf8YnLqT+ROPk0zw6GAXdSscvFf2Dj5GZCn6hpM/8mN9vHBEQy8Pp+Mvz1IdqjBalNw80U0iQaKCXTlRlbIrT4POOqFLUpP0ZvCa/9kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DfLXBxGJb4P6ZnhXi1Ak6xEedhFrTX778WrZ+lJIsrQ=; b=PlaeQTALZaZVIkQap6kMqJJ2L97tSHH7UNYKtZ4mOC6Hi82dygNEb5ustLdOA7jqgnL1/hgcf80Toi9QboydDKwiqpxZuojgO2jI0MChHqLNVihGLzXiB7yZJzwXpPT3dUjb+MLuZ6mEHpZ3LeqtQrAkslwYGWHmo1u2Y1Mu9eyH8ALykJNKvDtRzUZW0tslP8NMOdcHrea62cwV6voTD8WI6oEKzrZD2zJHpPi0YRJviMmgsCBysQNilz6o5LEiOeAl3eA00GRVTSZp4ZpR1p8pNUPga34/YI0uhjSibegetV6Nbh88pEsx1RMye+b3dT0P5M26Fmg/BSLq1fgb3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BN6PR1001MB2340.namprd10.prod.outlook.com (2603:10b6:405:30::36) by MW6PR10MB7685.namprd10.prod.outlook.com (2603:10b6:303:248::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Tue, 8 Aug 2023 17:31:16 +0000 Received: from BN6PR1001MB2340.namprd10.prod.outlook.com ([fe80::661e:4d86:eea0:c04e]) by BN6PR1001MB2340.namprd10.prod.outlook.com ([fe80::661e:4d86:eea0:c04e%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 17:31:16 +0000 User-agent: mu4e 1.4.15; emacs 28.1 To: gcc-patches@gcc.gnu.org Cc: "Jose E. Marchesi" , david.faust@oracle.com, elena.zannoni@oracle.com Subject: [PATCH] bpf: Fixed GC mistakes in BPF builtins code. Date: Tue, 08 Aug 2023 18:31:10 +0100 Message-ID: <87y1ilqw4h.fsf@oracle.com> X-ClientProxiedBy: AM0PR06CA0090.eurprd06.prod.outlook.com (2603:10a6:208:fa::31) To BN6PR1001MB2340.namprd10.prod.outlook.com (2603:10b6:405:30::36) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR1001MB2340:EE_|MW6PR10MB7685:EE_ X-MS-Office365-Filtering-Correlation-Id: 156a968d-bc54-4ecc-e752-08db983544f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nILwumWCc1Ya5ay6x5eLZgIYufbmV/a942rSGRIDTIKNSfSgdZ11ZuORqfhR6K3He6DbCa1FBXma1qCrauxXYiz4DVDkDIf5SWP+yXu7ZdTud+ZlTiZ23gW4xNeM/3Ovw6k0w3DKNsoFPb5y/nhkCx04OQ21yZCGRxtWSAdJJK/4n5okVXsrfBm4G7C/aNe0nE5e9LCsJ/zSFo64ObP0JHVIBnEL0t3HEYByCJbAK3ItEuySDx2b+wsHRFkWlDfFTP2dQm2auewFb8sG2QkPPpRWug7NRyA2Go3DttMheyFchFe4DEQfia1YO02jPs6InvUIC26axW0Lc47iqppvYbhpX6PnGy9or6/2akChHGcPkjITwkzG5BbMBlmzxyKryBk2HFKr4S/pTX3v+0EkWjUbJI1/BWgN+FcuAsUmvr1CexyEgeYiOr8MbQmGb7uCC4Z7I1/TqbQTpZtzmx0cWPLKm0aUcqjOkFKZ7QaA96SqXgoSY49nxgG2twy6f8NX+C/MCubab3H3XvWy1f7cdrsPTp3GzDi2fQU8Hd1Y4Rn3YdLjzMng6uB4GCEHOAep X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR1001MB2340.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(136003)(376002)(346002)(366004)(396003)(451199021)(186006)(1800799003)(2906002)(41300700001)(316002)(44832011)(8676002)(8936002)(5660300002)(36756003)(86362001)(38100700002)(478600001)(2616005)(107886003)(6506007)(6486002)(6666004)(6512007)(83380400001)(4326008)(6916009)(66476007)(66556008)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0UKEUurwGF3xU09s6EAPLQdhyU9mPv28fTp8/tMzrl6228lBiUeekoRmD3yEmHn94zF2NPMQFXyGrOT7B1QptP5V25MeqU3osy5NnnaJJTXtjsJy1LkpPonIloAmDKx9zSBfxUNzu0SrzMCoX6YPNn6Tz2KRKu3ppXT1+Nrb4gXK41THdSgrII2igdgx1GJbYI4vqR4hs4u8UmG4SOqOA0+90rHwjgIhCeuuY7ppibe27CCNzQj7NpoQ2/M6sye/ajAlaqywjdHeRzDfknb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FWI1pA5lzPvLj7vtdDwcVSYbXwN+JhBqlycCrVg3+N9GYcPHN+UxMM/0IIf10pzFtXFh0hdwU9MYVzKJqmwvpWRpKrLGUTj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 156a968d-bc54-4ecc-e752-08db983544f3 X-MS-Exchange-CrossTenant-AuthSource: BN6PR1001MB2340.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 17:31:16.2345 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kjK97NvmPjGSEtoXvW8U76hfRiE/E/8Wn3fHIHdj4Pt75y8GcTowSGAOeczZhJfpWcOF/wnweJzE2DOlw8ajyW5YQ3uJ4xunmqya1yS44/0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR10MB7685 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_15,2023-08-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080156 X-Proofpoint-ORIG-GUID: 9-2JnQAlyYjKt4bT3gj-U1tu-xSbJot6 X-Proofpoint-GUID: 9-2JnQAlyYjKt4bT3gj-U1tu-xSbJot6 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Cupertino Miranda via Gcc-patches From: Cupertino Miranda Reply-To: Cupertino Miranda Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773683007669148081 X-GMAIL-MSGID: 1773683007669148081 Hi everyone, This patch fixes BPF CO-RE builtins support that missed information for garbage collector (GC). The BPF CO-RE implementation defines several data structures that keep builtin information throught all of the compilation flow aside from code. This intentionally avoids having the builtin calls arguments expressions/enum/types tree nodes within the compiling code in order to avoid the compiler to optimize those away, based on information in current compilation unit. CO-RE builtins are target kernel specific and very little can be infered from type inforamtion within the compilation unit. Fault was triggered when attempting to compile some BPF kernel big examples that revealed the lack of GC information. Patch also removes some spurious includes of header files. Best regards, Cupertino commit c71b5c604189d04664c5b5ee155326fa4b79808b Author: Cupertino Miranda Date: Tue Aug 8 11:12:00 2023 +0100 bpf: Fixed GC mistakes in BPF builtins code. This patches fixes problems with GC within the CO-RE builtins implementation. List of included headers was also reviseD. gcc/ChangeLog: * config/bpf/core-builtins.cc: Cleaned include headers. (struct cr_builtins): Added GTY. (cr_builtins_ref): Created. (builtins_data) Changed to GC root. (allocate_builtin_data): Changed. Included gt-core-builtins.h. * config/bpf/coreout.cc: (bpf_core_extra) Added GTY. (bpf_core_extra_ref): Created. (bpf_comment_info): Changed to GC root. (bpf_core_reloc_add, output_btfext_header, btf_ext_init): Changed. diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc index 575e63d8ea77..c3222b4c7804 100644 --- a/gcc/config/bpf/core-builtins.cc +++ b/gcc/config/bpf/core-builtins.cc @@ -22,52 +22,23 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" +#include "target.h" #include "rtl.h" -#include "regs.h" -#include "insn-config.h" -#include "insn-attr.h" -#include "recog.h" #include "output.h" -#include "alias.h" #include "tree.h" #include "stringpool.h" #include "attribs.h" -#include "varasm.h" -#include "stor-layout.h" -#include "calls.h" #include "function.h" -#include "explow.h" #include "memmodel.h" #include "emit-rtl.h" -#include "reload.h" -#include "tm_p.h" -#include "target.h" -#include "basic-block.h" #include "expr.h" -#include "optabs.h" -#include "bitmap.h" -#include "df.h" -#include "c-family/c-common.h" #include "diagnostic.h" -#include "builtins.h" -#include "predict.h" #include "langhooks.h" -#include "flags.h" - -#include "cfg.h" +#include "basic-block.h" #include "gimple.h" #include "gimple-iterator.h" #include "gimple-walk.h" #include "tree-pass.h" -#include "tree-iterator.h" - -#include "context.h" -#include "pass_manager.h" - -#include "gimplify.h" -#include "gimplify-me.h" - #include "plugin.h" #include "ctfc.h" @@ -159,37 +130,41 @@ along with GCC; see the file COPYING3. If not see as a builtin. */ -struct cr_builtins +struct GTY(()) cr_builtins { tree type; tree expr; tree default_value; rtx rtx_default_value; - enum btf_core_reloc_kind kind; /* Recovered from proper argument. */ + enum btf_core_reloc_kind kind; enum bpf_builtins orig_builtin_code; tree orig_arg_expr; }; +typedef struct cr_builtins *cr_builtins_ref; #define CORE_BUILTINS_DATA_EMPTY \ { NULL_TREE, NULL_TREE, NULL_TREE, NULL_RTX, BPF_RELO_INVALID, \ BPF_BUILTIN_UNUSED, NULL } /* Vector definition and its access function. */ -vec builtins_data; +static GTY(()) vec *builtins_data = NULL; static inline int allocate_builtin_data () { - struct cr_builtins data = CORE_BUILTINS_DATA_EMPTY; - int ret = builtins_data.length (); - builtins_data.safe_push (data); + if (builtins_data == NULL) + vec_alloc (builtins_data, 1); + + cr_builtins_ref data = ggc_cleared_alloc (); + int ret = builtins_data->length (); + vec_safe_push (builtins_data, data); return ret; } static inline struct cr_builtins * get_builtin_data (int index) { - return &builtins_data[index]; + return (*builtins_data)[index]; } typedef bool @@ -200,11 +175,12 @@ search_builtin_data (builtin_local_data_compare_fn callback, struct cr_builtins *elem) { unsigned int i; - for (i = 0; i < builtins_data.length (); i++) - if ((callback != NULL && (callback) (elem, &builtins_data[i])) - || (callback == NULL - && (builtins_data[i].orig_arg_expr == elem->orig_arg_expr))) - return (int) i; + if(builtins_data != NULL) + for (i = 0; i < builtins_data->length (); i++) + if ((callback != NULL && (callback) (elem, (*builtins_data)[i])) + || (callback == NULL + && ((*builtins_data)[i]->orig_arg_expr == elem->orig_arg_expr))) + return (int) i; return -1; } @@ -1392,3 +1368,5 @@ bpf_replace_core_move_operands (rtx *operands) } } } + +#include "gt-core-builtins.h" diff --git a/gcc/config/bpf/coreout.cc b/gcc/config/bpf/coreout.cc index b84585fb104e..0c5d166298fb 100644 --- a/gcc/config/bpf/coreout.cc +++ b/gcc/config/bpf/coreout.cc @@ -147,11 +147,12 @@ static char btf_ext_info_section_label[MAX_BTF_EXT_LABEL_BYTES]; static GTY (()) vec *bpf_core_sections; -struct bpf_core_extra { +struct GTY(()) bpf_core_extra { const char *accessor_str; tree type; }; -static hash_map bpf_comment_info; +typedef struct bpf_core_extra *bpf_core_extra_ref; +static GTY(()) hash_map *bpf_comment_info; /* Create a new BPF CO-RE relocation record, and add it to the appropriate CO-RE section. */ @@ -162,7 +163,7 @@ bpf_core_reloc_add (const tree type, const char * section_name, enum btf_core_reloc_kind kind) { bpf_core_reloc_ref bpfcr = ggc_cleared_alloc (); - struct bpf_core_extra *info = ggc_cleared_alloc (); + bpf_core_extra_ref info = ggc_cleared_alloc (); ctf_container_ref ctfc = ctf_get_tu_ctfc (); /* Buffer the access string in the auxiliary strtab. */ @@ -173,7 +174,7 @@ bpf_core_reloc_add (const tree type, const char * section_name, info->accessor_str = accessor; info->type = type; - bpf_comment_info.put (bpfcr, info); + bpf_comment_info->put (bpfcr, info); /* Add the CO-RE reloc to the appropriate section. */ bpf_core_section_ref sec; @@ -288,7 +289,7 @@ output_btfext_header (void) static void output_asm_btfext_core_reloc (bpf_core_reloc_ref bpfcr) { - struct bpf_core_extra **info = bpf_comment_info.get (bpfcr); + bpf_core_extra_ref *info = bpf_comment_info->get (bpfcr); gcc_assert (info != NULL); bpfcr->bpfcr_astr_off += ctfc_get_strtab_len (ctf_get_tu_ctfc (), @@ -365,6 +366,7 @@ btf_ext_init (void) btf_ext_label_num++); vec_alloc (bpf_core_sections, 1); + bpf_comment_info = hash_map::create_ggc (); } /* Output the entire .BTF.ext section. */