From patchwork Tue Sep 27 07:49:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 1488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp243710wrt; Tue, 27 Sep 2022 03:04:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4KHttpZmSDf6KgD72GK1KR/8KlnzeK3dhGQqsb2BPzLMdTHA/gKi07r0phqq8iSe/pKtGe X-Received: by 2002:a05:6402:2b8b:b0:43a:5475:f1ae with SMTP id fj11-20020a0564022b8b00b0043a5475f1aemr26899713edb.363.1664273082788; Tue, 27 Sep 2022 03:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664273082; cv=none; d=google.com; s=arc-20160816; b=W+BvpYKVLM33L0uVFcNyixgnOowPdT801k6Tn55Rhu7aOWRTT001ryrqk2BsTTCMHj D0c/086/hgvX3W6HE6r2EdmoFDg3VYszPbfrxetjTWHkSgMM75kQjj30zbFg7OTzsBxw rNwbigRq6vUYouNB5Xppl6dOfY+Mh/fiq1Ce6hz9lvEK8DnY2OC3yCadgpEcGpowL4pY DyjzmaBYfLxrZks5bQTG3KlPIeMLOGbMJ+zX3lRpnXt3+eOHk7sT1+9Z1Gj0PA6gS98d VN0Fss+64vYQFbDvvmAyFXEuY1prlXdGGn3oDfSFDeiZzSVQ8vzJsJBWzETyCXF78Gj9 4akg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dmarc-filter :delivered-to; bh=OHJ7FfiglUcuKH2KPYGqtxbtzIuTNqHsaBAfTNVtP6s=; b=NaT6v2cH/lHJOHUsDNku4w6ON/Hi9wIdOG2+fUzqKpY2qdSILHADORotTmemd6lzp2 CC4qRoKoGLd9L1XWqu0j5nagcjwbibi+aW9mVGaglEMxFS7V5sZ5K4OqkraKcAW2xoM+ VFBBdzSBEalStnnAplNLLBAkVLxY9LtKiFHizWJlDSJSahwCtMTSRgQU8qXKZEJZvArx vN+cvHXT6Voc8hSsAtE3AUZP9ZtI2rxqCg0cAMEzlTBaz30ru5zlnSyBC3vumDgLauqK WGv8rnXXOTP88QGDzJKwvZdfKRFehJQfWX8Q7A1BwWVayn1Tc8tEXBky2jAJDWFVG+hN cI3g== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f16-20020a0564021e9000b00453b9f11bb1si1378379edf.206.2022.09.27.03.04.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 03:04:42 -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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA6323857C46 for ; Tue, 27 Sep 2022 10:04:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 77AA93858D39 for ; Tue, 27 Sep 2022 10:04:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77AA93858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx_2uOyjJjT7UiAA--.62195S2; Tue, 27 Sep 2022 18:04:01 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org, mliska@suse.cz, dmalcolm@redhat.com Subject: [PATCH v2] LoongArch: Libvtv add loongarch support. Date: Tue, 27 Sep 2022 15:49:29 +0800 Message-Id: <20220927074928.804896-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Dx_2uOyjJjT7UiAA--.62195S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXr4ruFWxKFyrAw4DAr4kXrb_yoW5Jw4DpF W3Aw1Ivr4DGr1xC395try7Xws7CwsxGF4Iga4IgrW8CrWUCa4kWF92yrZ5GFWIq3yxZFWY gF1Sq398Cay5A3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk214x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE-syl42xK 82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGw C20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48J MIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMI IF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU5sjjDUUUU X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 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: , Cc: qijingwen , xuchenghua@loongson.cn, Lulu Cheng , i@xen0n.name Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745116812123631708?= X-GMAIL-MSGID: =?utf-8?q?1745116812123631708?= v1 - > v2: 1. When the macro __loongarch_lp64 is defined, the VTV_PAGE_SIZE is set to 64K. 2. In the vtv_malloc.cc file __vtv_malloc_init function, it does not check whether VTV_PAGE_SIZE is equal to the system page size, if the macro __loongarch_lp64 is defined. All regression tests of libvtv passed. === libvtv Summary === # of expected passes 176 But I haven't tested the performance yet. ----------------------------------- Co-Authored-By: qijingwen include/ChangeLog: * vtv-change-permission.h (defined): (VTV_PAGE_SIZE): Under the loongarch64 architecture, set VTV_PAGE_SIZE to 64K. libvtv/ChangeLog: * configure.tgt: Add loongarch support. * vtv_malloc.cc (defined): If macro __loongarch_lp64 is defined, then don't check whether VTV_PAGE_SIZE is the same as the system page size. --- include/vtv-change-permission.h | 4 ++++ libvtv/configure.tgt | 3 +++ libvtv/vtv_malloc.cc | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/include/vtv-change-permission.h b/include/vtv-change-permission.h index 70bdad92bca..64e419c29d5 100644 --- a/include/vtv-change-permission.h +++ b/include/vtv-change-permission.h @@ -48,6 +48,10 @@ extern void __VLTChangePermission (int); #else #if defined(__sun__) && defined(__svr4__) && defined(__sparc__) #define VTV_PAGE_SIZE 8192 +/* LoongArch architecture 64-bit system supports 4k,16k and 64k + page size, which is set to the maximum value here. */ +#elif defined(__loongarch_lp64) +#define VTV_PAGE_SIZE 65536 #else #define VTV_PAGE_SIZE 4096 #endif diff --git a/libvtv/configure.tgt b/libvtv/configure.tgt index aa2a3f675b8..6cdd1e97ab1 100644 --- a/libvtv/configure.tgt +++ b/libvtv/configure.tgt @@ -50,6 +50,9 @@ case "${target}" in ;; x86_64-*-darwin[1]* | i?86-*-darwin[1]*) ;; + loongarch*-*-linux*) + VTV_SUPPORTED=yes + ;; *) ;; esac diff --git a/libvtv/vtv_malloc.cc b/libvtv/vtv_malloc.cc index 67c5de6d4e9..45804b8d7f8 100644 --- a/libvtv/vtv_malloc.cc +++ b/libvtv/vtv_malloc.cc @@ -212,6 +212,11 @@ __vtv_malloc_init (void) #if defined (__CYGWIN__) || defined (__MINGW32__) if (VTV_PAGE_SIZE != sysconf_SC_PAGE_SIZE()) +#elif defined (__loongarch_lp64) + /* I think that under the LoongArch 64-bit system, VTV_PAGE_SIZE is set + to the maximum value of 64K supported by the system, so there is no + need to judge here. */ + if (false) #else if (VTV_PAGE_SIZE != sysconf (_SC_PAGE_SIZE)) #endif