From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: xry111@xry111.site, xuchenghua@loongson.cn, i@xen0n.name, Lulu Cheng , qijingwen 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.31.1