From patchwork Thu Dec 16 19:42:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49023 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B0473858435 for ; Thu, 16 Dec 2021 19:45:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B0473858435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639683901; bh=oAcPF38qMYtsXpBd4EJc9NVHUR0LJV7l2qnN6TP4XBM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=SH8zFWEDeesEmeZh+4r1XRlV8xIhblhGxXv7qeEDDTSM+XUuXdqCqvkYBg8l3UBli ZdqeZsqsKpc+9icFcXDkfK6nR6wbeJYah8Ya4OR2h/LkwmNWfyhlJk35rjfjGRxsim NbHX4hpXopgBx+D2MFC1gy5xjNXckfXqjrIQr0WU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by sourceware.org (Postfix) with ESMTPS id A05813858418 for ; Thu, 16 Dec 2021 19:42:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A05813858418 Received: by mail-qv1-xf2f.google.com with SMTP id ke6so314468qvb.1 for ; Thu, 16 Dec 2021 11:42:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oAcPF38qMYtsXpBd4EJc9NVHUR0LJV7l2qnN6TP4XBM=; b=q9Lwqeu8lWRjQvjaTSHWVrWUWFRM9lYwN74dtXhtiqKnaIgSOXMi27eWX6TtiCOor/ Yq7khyHxPgOBPAKrWS3fmY6M1FbkUh717zTIB5+naxUCQMZrDxQ6IhJ1XXy3SLqSoBKS CZXEOSK6TJkTaNQR2lr4uumDrgGqWJpDkqY5h0qy2khcCj5PZPOaAzHK7IYiTWlAcH79 FeaDGmAeDWRLNy1o2y0yY4oDTbbTVRqJiNMltYzrCFqYPtF9yA5NePdbFqxm5jzIaee/ teIb5LWEko6ZURsQVewxJIXUrQgQ5KMIkKOneMW9s2dcb31L4asStGs6Frh5xskAJprx 9JNw== X-Gm-Message-State: AOAM533yEhlQsA7uZygmqrUNlO+kph0FT3cLj8/I1JOKum45lrqA6r+E L1B7TZQCfjPOPHV07g9VUERUTZ75qE1/0Q== X-Google-Smtp-Source: ABdhPJw83PpBlXioR3oxL9SMjYTSncF4Ze4L9PlVIe40YfBNbdkJz428Q5/D9s/8WYVYJnNpizJsuA== X-Received: by 2002:a05:6214:1d23:: with SMTP id f3mr16845932qvd.25.1639683752093; Thu, 16 Dec 2021 11:42:32 -0800 (PST) Received: from birita.. ([2804:431:c7ca:103f:96e9:fe91:2aff:a44d]) by smtp.gmail.com with ESMTPSA id br13sm3503836qkb.10.2021.12.16.11.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 11:42:31 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 4/5] malloc: Use hp-timing on libmemusage Date: Thu, 16 Dec 2021 16:42:21 -0300 Message-Id: <20211216194222.186992-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216194222.186992-1-adhemerval.zanella@linaro.org> References: <20211216194222.186992-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Instead of reimplemeting on GETTIME macro. --- malloc/memusage.c | 15 ++++++++++++--- sysdeps/generic/memusage.h | 12 ------------ sysdeps/i386/i686/memusage.h | 1 - sysdeps/ia64/memusage.h | 7 ------- sysdeps/x86_64/memusage.h | 1 - 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/malloc/memusage.c b/malloc/memusage.c index d287a7aa82..fb4e754e09 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -35,6 +35,7 @@ #include #include +#include /* Pointer to the real functions. These are determined used `dlsym' when really needed. */ @@ -115,6 +116,14 @@ static struct entry buffer[2 * DEFAULT_BUFFER_SIZE]; static _Atomic uint32_t buffer_cnt; static struct entry first; +static void +gettime (struct entry *e) +{ + hp_timing_t now; + HP_TIMING_NOW (now); + e->time_low = now & 0xffffffff; + e->time_high = now >> 32; +} /* Update the global data after a successful function call. */ static void @@ -178,7 +187,7 @@ update_data (struct header *result, size_t len, size_t old_len) buffer[idx].heap = current_heap; buffer[idx].stack = current_stack; - GETTIME (buffer[idx].time_low, buffer[idx].time_high); + gettime (&buffer[idx]); /* Write out buffer if it is full. */ if (idx + 1 == buffer_size) @@ -268,7 +277,7 @@ me (void) /* Write the first entry. */ first.heap = 0; first.stack = 0; - GETTIME (first.time_low, first.time_high); + gettime (&first); /* Write it two times since we need the starting and end time. */ write (fd, &first, sizeof (first)); write (fd, &first, sizeof (first)); @@ -819,7 +828,7 @@ dest (void) stack. */ first.heap = peak_heap; first.stack = peak_stack; - GETTIME (first.time_low, first.time_high); + gettime (&first); write (fd, &first, sizeof (struct entry)); /* Close the file. */ diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h index c9bde5cd11..514bd058d2 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/generic/memusage.h @@ -23,15 +23,3 @@ # warning "GETSP is not defined for this architecture." # define GETSP 0 #endif - -#ifndef GETTIME -# define GETTIME(low,high) \ - { \ - struct __timespec64 now; \ - uint64_t usecs; \ - __clock_gettime64 (CLOCK_REALTIME, &now); \ - usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \ - low = usecs & 0xffffffff; \ - high = usecs >> 32; \ - } -#endif diff --git a/sysdeps/i386/i686/memusage.h b/sysdeps/i386/i686/memusage.h index 08b7831e12..07b241263c 100644 --- a/sysdeps/i386/i686/memusage.h +++ b/sysdeps/i386/i686/memusage.h @@ -16,6 +16,5 @@ . */ #define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; }) -#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high)) #include diff --git a/sysdeps/ia64/memusage.h b/sysdeps/ia64/memusage.h index 3c3a526007..33fd6ec899 100644 --- a/sysdeps/ia64/memusage.h +++ b/sysdeps/ia64/memusage.h @@ -18,12 +18,5 @@ #include #define GETSP() ({ register uintptr_t stack_ptr asm ("%r12"); stack_ptr; }) -#define GETTIME(low, high) \ - { \ - hp_timing_t __now; \ - HP_TIMING_NOW (__now); \ - low = __now & 0xffffffff; \ - high = __now >> 32; \ - } #include diff --git a/sysdeps/x86_64/memusage.h b/sysdeps/x86_64/memusage.h index 568dd5512d..6652fc5da1 100644 --- a/sysdeps/x86_64/memusage.h +++ b/sysdeps/x86_64/memusage.h @@ -16,6 +16,5 @@ . */ #define GETSP() ({ register uintptr_t stack_ptr asm ("rsp"); stack_ptr; }) -#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high)) #include