linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Audra Mitchell <audra@redhat.com>
To: linux-mm@kvack.org
Cc: raquini@redhat.com, akpm@linux-foundation.org, djakov@kernel.org,
	vbabka@suse.cz, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] tools/mm: Filter out timestamps for correct collation
Date: Fri, 13 Oct 2023 15:03:47 -0400	[thread overview]
Message-ID: <20231013190350.579407-4-audra@redhat.com> (raw)
In-Reply-To: <20231013190350.579407-1-audra@redhat.com>

With the introduction of allocation timestamps being included in page_owner
output, each record becomes unique due to the timestamp nanosecond
granularity. Remove the check in add_list that tries to collate each record
during processing as the memcmp() is just additional overhead at this
point.

Also keep the allocation timestamps, but allow collation to occur without
consideration of the allocation timestamp except in the case were
allocation timestamps are requested by the user (the -a option).

Signed-off-by: Audra Mitchell <audra@redhat.com>
---
 tools/mm/page_owner_sort.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
index 9c93f3f4514f..7ddabcb3a073 100644
--- a/tools/mm/page_owner_sort.c
+++ b/tools/mm/page_owner_sort.c
@@ -203,6 +203,21 @@ static int compare_sort_condition(const void *p1, const void *p2)
 	return cmp;
 }
 
+static int remove_pattern(regex_t *pattern, char *buf, int len)
+{
+	regmatch_t pmatch[2];
+	int err;
+
+	err = regexec(pattern, buf, 2, pmatch, REG_NOTBOL);
+	if (err != 0 || pmatch[1].rm_so == -1)
+		return len;
+
+	memcpy(buf + pmatch[1].rm_so,
+		buf + pmatch[1].rm_eo, len - pmatch[1].rm_eo);
+
+	return len - (pmatch[1].rm_eo - pmatch[1].rm_so);
+}
+
 static int search_pattern(regex_t *pattern, char *pattern_str, char *buf)
 {
 	int err, val_len;
@@ -443,13 +458,6 @@ static bool is_need(char *buf)
 
 static bool add_list(char *buf, int len, char *ext_buf)
 {
-	if (list_size != 0 &&
-		len == list[list_size-1].len &&
-		memcmp(buf, list[list_size-1].txt, len) == 0) {
-		list[list_size-1].num++;
-		list[list_size-1].page_num += get_page_num(buf);
-		return true;
-	}
 	if (list_size == max_size) {
 		fprintf(stderr, "max_size too small??\n");
 		return false;
@@ -465,6 +473,9 @@ static bool add_list(char *buf, int len, char *ext_buf)
 		return false;
 	}
 	memcpy(list[list_size].txt, buf, len);
+	if (sc.cmps[0] != compare_ts) {
+		len = remove_pattern(&ts_nsec_pattern, list[list_size].txt, len);
+	}
 	list[list_size].txt[len] = 0;
 	list[list_size].len = len;
 	list[list_size].num = 1;
-- 
2.41.0



  parent reply	other threads:[~2023-10-13 19:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 19:03 [PATCH 0/5] Fix page_owner's use of free timestamps Audra Mitchell
2023-10-13 19:03 ` [PATCH 1/5] mm/page_owner: Remove free_ts from page_owner output Audra Mitchell
2023-10-17  8:07   ` Vlastimil Babka
2023-10-13 19:03 ` [PATCH 2/5] tools/mm: Remove references to free_ts from page_owner_sort Audra Mitchell
2023-10-17  8:10   ` Vlastimil Babka
2023-10-13 19:03 ` Audra Mitchell [this message]
2023-10-17  8:12   ` [PATCH 3/5] tools/mm: Filter out timestamps for correct collation Vlastimil Babka
2023-10-13 19:03 ` [PATCH 4/5] tools/mm: Fix the default case for page_owner_sort Audra Mitchell
2023-10-17  8:13   ` Vlastimil Babka
2023-10-13 19:03 ` [PATCH 5/5] tools/mm: Update the usage output to be more organized Audra Mitchell
2023-10-17  8:13   ` Vlastimil Babka
2023-10-16 11:55 ` [PATCH 0/5] Fix page_owner's use of free timestamps Rafael Aquini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231013190350.579407-4-audra@redhat.com \
    --to=audra@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=djakov@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=raquini@redhat.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox