Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1161822rdg; Fri, 13 Oct 2023 12:05:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd6V9PuvAKSRdqiMJCBozwAB7PZB+iW5DHfSvf1HYY7RERAuY4hmyh05ivJIlIIZ2zRaxW X-Received: by 2002:a17:90a:540e:b0:279:104e:1779 with SMTP id z14-20020a17090a540e00b00279104e1779mr26346281pjh.16.1697223912514; Fri, 13 Oct 2023 12:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697223912; cv=none; d=google.com; s=arc-20160816; b=LMLkUG+Q4xUVp3dsLbVs6jm9zG8bBLplxNml40dan8qv6QtSwY1t/1MKgxzZukEk1O XtZCpLAbj6w/mNiAONwmdTzMy4XK5+wZ+CixfybHs/bhwfT5VcyfLLI3qsBmb/9fwSfb 9AMTF+a0T/SYcTqlstcl5H/qCrsK2bVRadGx/9Usc9URuMRlqLsct0UgWCiTqwbA1Cu3 36PMzCxxLe5sZHa5P6CZwDFutnii/F78wtlknk0ArZtl7LnPRwQe/mIcwKx5ACn6/3xp dDK0hXNx/zMJTaIJVu9xtNjkuHVTty0nmdYtb99Z7wND4Gq/s3lIbe4ZL2oTIErbvZ/F lJDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zR5p3ioGj44ReczmQkXwckrYVMKEAFkp4XWCVgfnl84=; fh=YslCjvlXkGsdmqLq8rTUMG5flN38yHruc56T4Q8Q6OI=; b=Sn2CRra6Z5v9L3iZbiUABy/08Cdj0p+j1QgFxXDFXdjDeTurIAEmMA7xl4Wa1IHgDS 5+8JHf8/oyKLVLRi8Z8mqy2vCdtwzzyPmiOTOyMP3GILmOeVA7pTAzfdANmWyw71ew/b WsYABdom5IYWrb0PnnN8kJpEUoGvdLz0Lilmiz1L6+hX7ZExBs5EPxTRBQpI31C7tpeE /JY5cQHh6fyhlEToF9WaKDBF3FMDnCGfasFREcbJA90yKlq3hIJhMQOBjMrMHcMQuE0D dCXRlq76cWR4nDEYxP3qv+qQXzdnRUXn0IhHBlW9TKe/f7QQSj6+zhZw5edLP42AeUm3 PWZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S7vm8MUJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i4-20020a63e444000000b005aa6bcd54fdsi2424294pgk.735.2023.10.13.12.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 12:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S7vm8MUJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 65B2A8331E3A; Fri, 13 Oct 2023 12:05:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbjJMTFF (ORCPT + 99 others); Fri, 13 Oct 2023 15:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjJMTFD (ORCPT ); Fri, 13 Oct 2023 15:05:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7CF5BF for ; Fri, 13 Oct 2023 12:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697223854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zR5p3ioGj44ReczmQkXwckrYVMKEAFkp4XWCVgfnl84=; b=S7vm8MUJfBKHRToOJzXWHYHQK8xMj4nepiIWZ5dxKGCwpk6GsPU+6CJjr5YcJ1ECEL0n4G vEX0bn2lBWsN8S4QnxJDA9tVe8Rd4yLqv00uFv11Wu77atiE6vCAUVl/NYdkX8Z0k9pYP2 VSH7yZgnGmdrUDr0pXg7IR1Mfo8y+Os= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-TnrzPz-tMWW8slqjaMdDHg-1; Fri, 13 Oct 2023 15:04:10 -0400 X-MC-Unique: TnrzPz-tMWW8slqjaMdDHg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82CEF185A795; Fri, 13 Oct 2023 19:04:06 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.33.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 482022157F5A; Fri, 13 Oct 2023 19:04:06 +0000 (UTC) From: Audra Mitchell 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 Message-ID: <20231013190350.579407-4-audra@redhat.com> In-Reply-To: <20231013190350.579407-1-audra@redhat.com> References: <20231013190350.579407-1-audra@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 13 Oct 2023 12:05:11 -0700 (PDT) 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 --- 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