From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.7 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, MISSING_MIMEOLE,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A09BBCA9EAC for ; Sat, 19 Oct 2019 18:12:35 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 64C7A21925 for ; Sat, 19 Oct 2019 18:12:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=akdev.xyz header.i=alex@akdev.xyz header.b="H/5oel6K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64C7A21925 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=akdev.xyz Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.92.3) (envelope-from ) id 1iLtD8-0004wY-GY; Sat, 19 Oct 2019 14:12:18 -0400 Received: from sender4-op-o19.zoho.com ([136.143.188.19]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1iLbD4-00009w-9p for kernelnewbies@kernelnewbies.org; Fri, 18 Oct 2019 18:59:02 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1571439537; cv=none; d=zohomail.com; s=zohoarc; b=IpAgTTIVNKVeijvRQyoN28cFNnjh0yYzaNmwxnRP/GWBRfmZuoghnw8EFX1op56zirwKdiHtibfJmWp+X9kSLFGoPKgC5ezbmCaWhatuILbvUo+DonYIhGjvgwd2VxUxrCVbypNl1c7WoaphHVB/WA2+A8gFj0+Pp7JKRF886Zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1571439537; h=Content-Type:Content-Transfer-Encoding:Date:From:MIME-Version:Message-ID:Subject:To; bh=0W3wSWL57VChpC+iEQogz0DocnYbzk/yyqT59OqeA5o=; b=StuTPgZpW+3yRJT/Q7VXyIgYBNESJQ8GzOBRX+JOb2j6MiqnjHL2TowAzHBrN/WaclE/1nB8aumpPsd4Ergc+A8OpKQkvSnEKaLgjEY9Oly57BP2QmvjvcbbWVNArN9ymjK9OHF0x3Iy6gCIaZGFTK6XA7plbvWfm2HWtOrM6L0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=akdev.xyz; spf=pass smtp.mailfrom=alex@akdev.xyz; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1571439537; s=akdev; d=akdev.xyz; i=alex@akdev.xyz; h=Date:Subject:Message-ID:From:To:MIME-Version:Content-Type:Content-Transfer-Encoding; l=4141; bh=0W3wSWL57VChpC+iEQogz0DocnYbzk/yyqT59OqeA5o=; b=H/5oel6KM4m+GPp3U8y1If3GB3WeuxG5d1MOIISwBDyfGiwXNYpLO3eKbX3Qw8SU OIgYMNzyCBU3I+j/gwoYBP7xsrjZfbVOtFogDtB1SKMlzLkQta7RzQCrPRTU/HnN8po mgShgUIQic1cAOKE4yTe4vk/BCRi8p2zAbkuOli0= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1571439532090603.8291020865203; Fri, 18 Oct 2019 15:58:52 -0700 (PDT) Date: Fri, 18 Oct 2019 18:58:50 -0400 Subject: [PATCH] feedback appreciated Message-ID: X-Android-Message-ID: From: Alex Diaz To: kernelnewbies@kernelnewbies.org Importance: Normal X-Priority: 3 X-MSMail-Priority: Normal MIME-Version: 1.0 User-Agent: Zoho Mail X-Mailer: Zoho Mail X-Mailman-Approved-At: Sat, 19 Oct 2019 14:12:17 -0400 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============7835273162671562989==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============7835273162671562989== Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
Hi

I sent a patch in and I got ignored. I'm thinking I did something wrong and I would like some feedback. 

There's more backstory in my original email so here it is:

---------- Forwarded message ----------
From: Alex <alex@akdev.xyz>
Date: Sep. 22, 2019 12:50
Subject: [PATCH] perf: save space when filteting events]
To: alex@akdev.xyz
Cc:

I was browsing the code in perf and I found a `FIXME` comment in the code
that builds the binary expressions to filter events/syscalls:r
`perf trace -e write,read`

The code mentioned wanting to use an implementation of log10() in the dvb
drivers. I am not aware why that specific implementation is mentioned.
I used the implementation found in `math.h`.

I tested this patch passing 200 syscalls to filter on a `perf trace -e ${syscalls} ls`
call. You can see the commands used and a snipped of the vallgrind results here:
https://termbin.com/k4of

Before: 61,910,110 bytes allocated
After: 61,907,045 bytes allocated
---
perf used to allocate space in excess to build the filtering expressions.
now perf only allocates the space necessary and not more.

Signed-off-by: Alex Diaz <alex@akdev.xyz>
---
tools/perf/util/string.c | 25 ++++++++++++++++++++-----
tools/perf/util/string2.h | 2 ++
2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 52603876c548..4c3913a9e7e7 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -3,6 +3,7 @@
#include
#include
#include
+#include

#include

@@ -209,15 +210,29 @@ int strtailcmp(const char *s1, const char *s2)
return 0;
}

-char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints)
+size_t calc_expr_buffer_size(const char *var, size_t nints, int *ints)
{
/*
- * FIXME: replace this with an expression using log10() when we
- * find a suitable implementation, maybe the one in the dvb drivers...
+ * Calculate the buffer for the expression:
*
- * "%s == %d || " = log10(MAXINT) * 2 + 8 chars for the operators
+ * "%s == %d || "
+ * length: strlen(var) + strlen(" == ") + log10(n) + strlen(" || ") + 1
*/
- size_t size = nints * 28 + 1; /* \0 */
+ size_t size = 0;
+ size_t num_len = 0;
+ const size_t var_len = strlen(var);
+
+ for (size_t i = 0; i < nints; ++i) {
+ num_len = (ints[i] == 0) ? 1 : log10(ints[i]);
+ size += var_len + num_len + 9;
+ }
+
+ return size;
+}
+
+char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints)
+{
+ size_t size = calc_expr_buffer_size(var, nints, ints);
size_t i, printed = 0;
char *expr = malloc(size);

diff --git a/tools/perf/util/string2.h b/tools/perf/util/string2.h
index 708805f5573e..28fbc782ad54 100644
--- a/tools/perf/util/string2.h
+++ b/tools/perf/util/string2.h
@@ -20,6 +20,8 @@ static inline bool strisglob(const char *str)
}
int strtailcmp(const char *s1, const char *s2);

+size_t calc_expr_buffer_size(const char *var, size_t nints, int *ints);
+
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);

static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
--
2.21.0



--===============7835273162671562989== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============7835273162671562989==--