From 2e0bf89a63559f3c7f6b82364df48f8ba9252379 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 16 2022 00:17:12 +0000 Subject: import memstrack-0.2.4-2.el8 --- diff --git a/.gitignore b/.gitignore index c33087e..92a389f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/memstrack-bdc9386.tar.gz +SOURCES/v0.2.4.tar.gz diff --git a/.memstrack.metadata b/.memstrack.metadata index 317cfd3..da87605 100644 --- a/.memstrack.metadata +++ b/.memstrack.metadata @@ -1 +1 @@ -47747f1a981523c9c5caadf7c0ccb30baa3edabb SOURCES/memstrack-bdc9386.tar.gz +4c54a54025a506f5b01a20b377884013459c0e42 SOURCES/v0.2.4.tar.gz diff --git a/SOURCES/0001-Skip-memcg-info-in-__process_stacktrace-for-page_own.patch b/SOURCES/0001-Skip-memcg-info-in-__process_stacktrace-for-page_own.patch new file mode 100644 index 0000000..87302d8 --- /dev/null +++ b/SOURCES/0001-Skip-memcg-info-in-__process_stacktrace-for-page_own.patch @@ -0,0 +1,88 @@ +From 2d27b3694bf0996767b6e5282b9d39784d1524c1 Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Mon, 11 Jul 2022 15:28:25 +0800 +Subject: [PATCH 1/2] Skip memcg info in __process_stacktrace for page_owner + backend + +Kernel patch set [1] extended page_owner to show memcg information: + +Page allocated via order 0, mask 0x0(), pid 1, tgid 1 (swapper/0), ts 158908732 ns, free_ts 0 ns +PFN 4540 type Unmovable Block 8 type Unmovable Flags 0xfffffc0010200(slab|head|node=0|zone=1|lastcpupid=0x1fffff) + register_early_stack+0x28/0x57 + init_page_owner+0x1d/0x2f + kernel_init_freeable+0x138/0x1a2 + kernel_init+0x16/0x120 +Slab cache page + +Page allocated via order 0, mask 0x400dc0(GFP_KERNEL_ACCOUNT|__GFP_ZERO), pid 737, tgid 737 (NetworkManager), ts 3964670439 ns, free_ts 3961489285 ns +PFN 11172 type Unmovable Block 21 type Unmovable Flags 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff) + get_page_from_freelist+0x3f0/0x500 + __alloc_pages+0xe6/0x230 + pte_alloc_one+0x15/0x50 + ... + asm_exc_page_fault+0x1e/0x30 +Charged (via objcg) to memcg NetworkManager.service + +"^Slab|^Charged" lines are unexpected for __process_stacktrace. +As a result, error messages as "Page owner stacktrace malformed" +will be output and fail. + +This patch fix the issue by skip the memcg info lines when iterating +stacktrace. + +[1]: https://lore.kernel.org/all/20220202203036.744010-3-longman@redhat.com/T/#mcd67a65c84092f71efb766d0d509f0e8255d4dc2 + +Signed-off-by: Tao Liu +--- + src/backend/page_owner.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/backend/page_owner.c b/src/backend/page_owner.c +index f66d77d..156f688 100644 +--- a/src/backend/page_owner.c ++++ b/src/backend/page_owner.c +@@ -37,6 +37,23 @@ + + static char *page_owner_file; + ++static char *memcg_info[] = { ++ "Slab cache page", ++ "Charged ", ++}; ++ ++static int is_memcg_info(char *str) ++{ ++ for (int i = 0; ++ i < sizeof(memcg_info) / sizeof(__typeof__(memcg_info[0])); ++ i++) { ++ if (!strncmp(str, memcg_info[i], strlen(memcg_info[i]))) { ++ return true; ++ } ++ } ++ return false; ++} ++ + static struct Tracenode* __process_stacktrace( + struct Tracenode *tn, struct PageEvent *pe, char *line, FILE *file) + { +@@ -45,6 +62,7 @@ static struct Tracenode* __process_stacktrace( + int callsite_len; + unsigned long len; + ++retry: + if (!fgets(line, MAX_LINE, file)) { + log_error("Page owner file ended unexpectly before stacktrace.\n"); + return NULL; +@@ -56,6 +74,9 @@ static struct Tracenode* __process_stacktrace( + return NULL; + } + ++ if (is_memcg_info(line)) ++ goto retry; ++ + /* Empty line, end of a stacktrace */ + if (line[0] == '\n' || line[0] == '\r') + return tn; +-- +2.33.1 + diff --git a/SOURCES/0002-Fix-data-type-error-in-perf_handle_mm_page_alloc.patch b/SOURCES/0002-Fix-data-type-error-in-perf_handle_mm_page_alloc.patch new file mode 100644 index 0000000..36ac599 --- /dev/null +++ b/SOURCES/0002-Fix-data-type-error-in-perf_handle_mm_page_alloc.patch @@ -0,0 +1,53 @@ +From 8c42fcfa92998da170ee84cd24c2377db2e90f33 Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Tue, 12 Jul 2022 19:41:25 +0800 +Subject: [PATCH 2/2] Fix data type error in perf_handle_mm_page_alloc + +For systems as s390, unsigned long and unsigned int are different in +size. After expanding the macro, the code will be: + +unsigned int order = *((unsigned long*) + (((const unsigned char*)(&raw->data)) + + ((struct __perf_event_field_table_mm_page_alloc*)(perf_event_mm_page_alloc.fields))->order_info.offset)); + +or simply: + +unsigned int order = *((unsigned long*) + (((const unsigned char*)(&raw->data)) + 16)); + +If we have the following data array: + +Raw data[16]: 0x0 +Raw data[17]: 0x0 +Raw data[18]: 0x0 +Raw data[19]: 0x2 +Raw data[20]: 0x0 +Raw data[21]: 0x0 +Raw data[22]: 0xc +Raw data[23]: 0xc0 + +The order will be: 0x0cc0, instead of 0x2. + +This patch will fix the error data type. + +Signed-off-by: Tao Liu +--- + src/backend/perf-events.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/backend/perf-events.c b/src/backend/perf-events.c +index 0252991..67f1dad 100644 +--- a/src/backend/perf-events.c ++++ b/src/backend/perf-events.c +@@ -156,7 +156,7 @@ static int perf_handle_mm_page_alloc(const unsigned char* header) { + sizeof(callchain->ips) * callchain->nr); + + unsigned long pfn = read_data_from_perf_raw(mm_page_alloc, pfn, unsigned long, raw); +- unsigned int order = read_data_from_perf_raw(mm_page_alloc, order, unsigned long, raw); ++ unsigned int order = read_data_from_perf_raw(mm_page_alloc, order, unsigned int, raw); + int pid = read_data_from_perf_raw(mm_page_alloc, common_pid, int, raw); + + // TODO: pfn == -1? +-- +2.33.1 + diff --git a/SPECS/memstrack.spec b/SPECS/memstrack.spec index 7f17b5c..011b940 100644 --- a/SPECS/memstrack.spec +++ b/SPECS/memstrack.spec @@ -1,11 +1,8 @@ # vim: syntax=spec -%global gitcommit bdc9386376f377218b25624a580a39c4d5917f71 -%global gitshortcommit %(c=%{gitcommit}; echo ${c:0:7}) -%global snapshotdate 20200806 Name: memstrack -Version: 0.1.11 -Release: 1%{?dist} +Version: 0.2.4 +Release: 2%{?dist} Summary: A memory allocation tracer, like a hot spot analyzer for memory allocation License: GPLv3 URL: https://github.com/ryncsn/memstrack @@ -13,13 +10,18 @@ VCS: git+git@github.com:ryncsn/memstrack.git BuildRequires: gcc BuildRequires: ncurses-devel -Source: https://github.com/ryncsn/memstrack/archive/%{gitcommit}/memstrack-%{gitshortcommit}.tar.gz +Source: https://github.com/ryncsn/memstrack/archive/refs/tags/v%{version}.tar.gz + +Patch1: 0001-Skip-memcg-info-in-__process_stacktrace-for-page_own.patch +Patch2: 0002-Fix-data-type-error-in-perf_handle_mm_page_alloc.patch %description A memory allocation tracer, like a hot spot analyzer for memory allocation %prep -%setup -q -n memstrack-%{gitcommit} +%setup -q -n memstrack-%{version} +%patch1 -p1 +%patch2 -p1 %build %{set_build_flags} @@ -35,6 +37,12 @@ install -p -m 755 memstrack %{buildroot}/%{_bindir} %{_bindir}/memstrack %changelog +* Fri Jul 15 2022 Tao Liu - 0.2.4-2 +- Revert bz2107730 + +* Fri Jul 15 2022 Tao Liu - 0.2.4-1 +- Rebase to latest upstream(813c2feaa2f) + * Tue Aug 6 2020 Kairui Song - 0.1.11-1 - Fix memstrack failure with large memory hole