From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com [IPv6:2607:f8b0:4864:20::a2b]) by sourceware.org (Postfix) with ESMTPS id 025673857361 for ; Tue, 11 Oct 2022 20:58:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 025673857361 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-vk1-xa2b.google.com with SMTP id o28so3467822vkn.11 for ; Tue, 11 Oct 2022 13:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YIw+eNs/cyxl1N6IUTj6qj/rxy8pXKrlC4LyQrOCz50=; b=QCgH2QEplMtbZ6E2q5jQCRlVUcMytf/CRvrIMlGvmOXUNoHJ3EjW9Ona0I+cwdBFtz 7Te9ahphScWD4ja+a+rSpikeeRMqoaPy4+939nsjdyoENIuOMEX1aGLMvn7OUACBi7gl PaGobVYGDvo0L1FCKHpDPb65GP2CNK3fB28c9i4laa8Is6DPogEs5SUp0H8HZ6+VGZYy gWDPsLDGc4EaxM5NiHYnRbCSy+Z0caIsAbl8rZNXSstWgZ3ZJqvoo6WClCREGHqmWdAO jbL7sq2A+PdgvJnTQ1LYYqAEIIr6HLjhEwgqdD/pSnCJFBuBzEArkF/HzmbxjZBNDN0J ngKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YIw+eNs/cyxl1N6IUTj6qj/rxy8pXKrlC4LyQrOCz50=; b=s2NS7/Ko75BFh7gHJ6aqMDtbTSht28lT6IVKfRt1Fl8sEPW6sHdHOMvwnbR5ex2+s5 /gvISH/K+fg3LTd6GHJjGqm6fc8cym3mSGppoJQlvWvJ/qpZp4azmIb+JdZTUCwUFSVk nTfLxtTM6ZQKXJ6LPVWlOaw3Ii2dHHusDNc1tGso0UYcfLNYSa/iuCmCBV7K69Jw2eKu mQENNBT82nCMRxRIBGIX6EEKX28kJkNf+tsmloQ/JqltX41K1n0rJ9LOSmtDq2M0ZRnU QyVib96yo1fjISIYDXdEe4SZBiE+PKdQqUBxjAO6CXb6a7XkFN3OsnMzkiVyk5OM+U57 hnwA== X-Gm-Message-State: ACrzQf11c9u7GELug6kRoPC0ANswPfaHwFtd5Qk/iVrIsXLrckaFzOB9 vo0qC5mrKIpRgbWhm3iLh1SLoEPxFuiC+gzq0vaX5g== X-Google-Smtp-Source: AMsMyM6J82ecBgAbqgsuQ7m7W296UHwWdayqo6ykYQJwg6GBpyYnkfgr4dkgf7pFvjXLGGoAW1g0W/smcbdmwTGbcWY= X-Received: by 2002:a1f:45d5:0:b0:3ab:b549:2d5d with SMTP id s204-20020a1f45d5000000b003abb5492d5dmr6556236vka.4.1665521885326; Tue, 11 Oct 2022 13:58:05 -0700 (PDT) MIME-Version: 1.0 References: <20220927074928.804896-1-chenglulu@loongson.cn> In-Reply-To: <20220927074928.804896-1-chenglulu@loongson.cn> From: Caroline Tice Date: Tue, 11 Oct 2022 13:57:54 -0700 Message-ID: Subject: Re: [PATCH v2] LoongArch: Libvtv add loongarch support. To: Lulu Cheng Cc: GCC Patches , mliska@suse.cz, David Malcolm , qijingwen , xuchenghua@loongson.cn, i@xen0n.name Content-Type: multipart/alternative; boundary="0000000000005784e605eac88887" X-Spam-Status: No, score=-23.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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: --0000000000005784e605eac88887 Content-Type: text/plain; charset="UTF-8" I think that if VTV_PAGE_SIZE is not set to the actual size being used by the system, it could result in some unexpected failures. I believe the right thing to do in this case, since the size may vary, is to get the actual size being used by the system and use that in the definition of VTV_PAGE_SIZE. So in include/vtv-permission.h you would have something like: +#elif defined(__loongarch_lp64) +#define VTV_PAGE_SIZE sysconf(_SC_PAGE_SIZE) Then you would have the accurate, correct size for the current system, and there would be no need to update the check in vtv_malloc.cc at all. -- Caroline Tice cmtice@google.com On Tue, Sep 27, 2022 at 3:04 AM Lulu Cheng wrote: > > 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 > > --0000000000005784e605eac88887--