From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793819024; b=2730OI4n8u/IC6pLtI1BickZedJe/jZkTWO7uaRgVNKODDCLYzZHavss9VcPZNOsxPJj AdyfJ/zKsW0XLtM0KWNfb06QsYTfPjOmeS/pdwBteRnSgJdKrwwfT52rmEcRgNYM7qkDd ytGTpcnQk39vZCmknFUO8Gc5r1fxtvEgvBCgeVyvnw40aAL9CjdMFoVTKpP8MDzYfV0jX H6B3M71XGnHAzxFBEvi4mlENudUJZ6rc0I0klVmLgSdt6xneRfEaQ+Op06DPTQ8iBYTnV j3Uui9bQ16DWTRhcBjvvSAjYb0OaHW9Po7u6A3kgx9zYl+rdScJA4diffJTDhpDtX3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793819024; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:Mime-Version:X-Mailer:Message-ID: Subject:From:To:Cc:Content-Type; bh=XMmoP1+qWKtXNy9UbFcoNobznW37r4Fg/NhEAO7nu0w=; b=KTGgU1sgqnLL5U2vKRlEjqfoy5BmvANRxehpppNj8nplVbKy96F1cgMYIIP/l2K4TRKu 4YcxkDZkTbeuWwoHT5IHSnQMY58tFTosc6vCYgOhEaz60jEGq8H3ckV45pynJab23nZVd Jaioj10BFF6GfN+VJHulN8+En2uKO/3jmxpQTb5BS2dNTdXNQ/crMjHkeRZEqS7+7ylWr OcSH/b83hYmqo3oy6rhBNd+ERxt+zHPCwSBGI93y8vNVth7R70OlJXTCmCAIwP1X+V1Y0 pA2kSMxZmE/eC2nFhM0tI9rawka7XuiWSchZUc0lNoQ0/b9rMgtG5cny3EOcG2CinWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--abhishekbapat.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Oh6ImFOa; arc=none smtp.remote-ip=74.125.82.200 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31C6C606A33D for ; Wed, 4 Nov 2026 19:03:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 31C6C606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--abhishekbapat.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Oh6ImFOa Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-36a3451ea93so1384785eec.1 for ; Wed, 04 Nov 2026 11:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1793819023; x=1794423823; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XMmoP1+qWKtXNy9UbFcoNobznW37r4Fg/NhEAO7nu0w=; b=Oh6ImFOayl0UKzLRyC4m0Cv4gfVyJ+t1b72/ZjShhLUOp1XVodT3V6dJF9jCWdxLXy oSs2zscPrqg5s1ycwKKFhoP3kpe2Lunz8EcUblo6fGRl98yfoqQJhpidn4EGgSuY1IJM NJ2JdGFtKQMFLQbFf1LMzaAZNKCiYfNG9K34Kn6IRJFwixTBEzz1Hx6qyIF81S/WwuDo WEIj0fc0/ZVDh4O0UPsAP/e2J1KU5AJb6wEXVI7sUSWoFYJeycIJgynR5Hf9FZe6Y/5N 8LjaHO9S9CDc6oL8mcVK/5PGEnt/CnvuN+1w/RO1dCGujCzHni1WQ3B5RCVDxHSbyiWz sWFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793819023; x=1794423823; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XMmoP1+qWKtXNy9UbFcoNobznW37r4Fg/NhEAO7nu0w=; b=Z/PaJ36I2JqNYsqlp0vuRxYg/WtFMk2NXp8SBdaugXIvzKRJUOnjyDR8jd4MH9cE8U o5Yg1x+TTX1zb1hzFqt4D/8OeK9b8fmjy+ma0yR90l9T010DJL2eyK0xbS1ONiHXbJS1 ZmXJce2jgqnJjTN+IoO1LSeSrENmLw6y3Xsz7MYvbQyOEUVCqUGCoejnuS4aBlEdZLJC E7oFsJovrO0Q4YocodR5Pn5CpVPaEn6Z0mM4w4J6mG3SCwz1WHmGibAIQlvaGT9ed7bc B4tTaFiwtUGY5lfWmEQnmXSNkHhhyAgSLS/Vp36cmYY6m7tmhKJsnyw0DjUhA+nhhO+j VOWQ== X-Gm-Message-State: APuU4Z9tfRCwr/DCNdyYxkBf2gS93pQPjHOEqkDUPGZAA7djfOMTNpvR mdb+Av5MIiWBI1Oho10Jsfz8BSCA3nGPKKC4OpjcLHejaSEngMeMl1a86nHB1F+2h2hUbidolD4 5Aw7+osLv9D85hsGiKZz29M18SNWVepwzdg== X-Received: from dlbsv9.prod.google.com ([2002:a05:7022:3a09:b0:1ab:fb55:f657]) (user=abhishekbapat job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:2097:b0:14b:cf58:ce15 with SMTP id a92af1059eb24-1ac600d9f9bmr25256760c88.43.1793819022924; Wed, 04 Nov 2026 11:03:42 -0800 (PST) Date: Wed, 4 Nov 2026 19:03:35 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.0.506.g506a7eabc5-goog Message-ID: Subject: [PATCH v5 0/5] alloc_tag: Introduce selective tracing for MAP From: Abhishek Bapat To: Suren Baghdasaryan , Hao Ge , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, Abhishek Bapat Content-Type: text/plain; charset="UTF-8" The existing memory allocation profiling (MAP) tool accurately maintains aggregate counters for overall memory accounting. However, relying purely on aggregated counters restrics the visibility needed for targeted debugging. This patch series integrates three new tracepoints (alloc_tag_hit, alloc_tag_mem_alloced and alloc_tag_mem_freed) directly into the alloc_hooks_tag fast path. Enabling trace events globally for all allocations introduces a severe baseline overhead. To limit the performance overhead, we let the admin select specific allocations to be traced. A new IOCTL is introduced to allow privileged users to determine which allocation tags need tracing enabled. The IOCTL utilizes the pre-existing filtering mechanism to specify the allocation tags to enable tracing on. v5 changes: - Patch 3/5: Introduced a new patch to introduce a flags field wrapped in an anonymous union with the old inaccurate field. This allows us to extend the UAPI with more filters without breaking backwards compatibility. - Patch 4/5: Minor update to filter out trace_on tags using flags. - Patch 5/5: Updated the test to use the new flags UAPI. v4 changes: - Patch 1/4: Minor refactor, changed macro definition of `alloc_tag_trace_hit()` for the NOOP case. v3 changes: - Patch 2/4: Minor refactor, documented the `CAP_SYS_ADMIN` requirement. Moved the mutex lock / unlock outside the for loop. v2 changes: - Patch 1/4: Changed the trace events for the page allocator to track pointer to the head page instead of codetag_ref. alloc_tag_trace_enabled() no longer takes a tag arg, that arg gets added in patch 2 instead where the function makes use of it. Introduced new sections in the Documentation expanding on the newly introduced trace events. Minor typo fixes. - Patch 2/4: Toggle traces IOCTL now uses the same filter as other related ioctls. IOCTL returns -ENOENT if no tags match and an empty filter matches all tags. Added a subsection in the Documentation expanding on the new IOCTL. - Patch 4/4: Updated the test to work with the new UAPI from patch 2. Updated commit message to accurately mention that the test flips the state of trace_on, verifies it and restores to the original state. Abhishek Bapat (5): alloc_tag: Add trace events for tracing allocations alloc_tag: Introduce IOCTLs to toggle allocation tracepoints alloc_tag: Add a flags field to allocinfo_filter alloc_tag: Extend allocinfo_filter to support tracing queries alloc_tag: Add a test for trace state toggle and filtering Documentation/mm/allocation-profiling.rst | 73 ++++++++ MAINTAINERS | 1 + include/linux/alloc_tag.h | 106 +++++++++--- include/linux/codetag.h | 5 +- include/trace/events/alloc_tag.h | 122 +++++++++++++ include/uapi/linux/alloc_tag.h | 37 +++- mm/alloc_tag.c | 161 +++++++++++++++++- mm/page_alloc.c | 4 +- mm/percpu.c | 13 +- mm/slub.c | 6 +- .../alloc_tag/allocinfo_ioctl_test.c | 114 ++++++++++++- 11 files changed, 589 insertions(+), 53 deletions(-) create mode 100644 include/trace/events/alloc_tag.h base-commit: bcc036cfa1670a64500f6d857eaa71908b79e3fb -- 2.56.0.506.g506a7eabc5-goog