From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C9672264A9 for ; Mon, 4 May 2026 23:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777937790; cv=none; b=EFR7L2dHlYHvZp62R2O2chF8fJCYlID3Ozfidj2Aocj5fV3eaR686syf42EeiHMxIhPwGl+a9LLPrRM8T+xMnWvJHKnpQ64WJMNXrh7UjjakmbLn7X6t/A8ORkyw92fNG5BK1GvR/syCoUhti8oxo7hO8Uw73E8o9MhQwXy7Sw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777937790; c=relaxed/simple; bh=tJeULi/q7xpYupoBRYwHRPzDC/aOPztVImhVoaMF02s=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Y6ZFDy4nQQ/xPkKgoWl/VplNpMkFrq9WBw41fErcf8q+mhje2B0VfF4Zsuppqgd1dPIb9qSJqaB+aKPjI43VrU6XK3bszSWGf3a9ZEGlv8k0qQFlGoePUSHWBqkHtcXe77+cHkSard4IowhL8OSiEgUy1tabcZNrxxAatC88Tww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--abhishekbapat.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jt/3n///; arc=none smtp.client-ip=74.125.82.201 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) header.d=google.com header.i=@google.com header.b="jt/3n///" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2cc75e79b97so9758731eec.1 for ; Mon, 04 May 2026 16:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777937788; x=1778542588; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=6SVtzc1b2hNmp2ps3pkK8pPFTjVWAOuceZgJhvLk1yE=; b=jt/3n///JL1V3HB0AEJjNORk6+ipqjfiym711zZyoGNHUwO5CAVTYftWxEyQYPeEbI 2CaOpuRqBRwf982bq8UZxYzKVDJe7S8GqnhjsId92ESiUopMQRGcJw/sL1t0ZW0BBl3M OUUe8EZcfIprqggU3fh7QKMvxdO7WwjYbK6W2z3cYtCZnsQ0llW6vfP82xXxj66k3aDd zUhJgpQCivDR9hK9vTM/8oUj2d+TmaL4oZ1iW1NEsy6Qb/Mt8QGODkP7Ou+0TL+cEPg8 yNyAddqZYyjoznNfIRbG94xX/xy+xqDYJbRfuPqk7zpL/ZGybYaZTad74yaJesq/JVmP RZEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777937788; x=1778542588; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6SVtzc1b2hNmp2ps3pkK8pPFTjVWAOuceZgJhvLk1yE=; b=C0zIBOf7OGACb5gY6yZLObpijMZeK4J0DnbsX5NA6sDL0AxV5PvcTYWi0kYm7NehcT L3RMr+NuwNZiyEG1OfchQqwznaFAlGFngrFoOjMLkvv+verBwJNJ40JjdNiPS0Q5I3+j cwfWveR0Vu4wTG32ourkg4qoUVSYClLE2jmg0Bi9obOz9nqOw9KOvdIFIuolHN8pFfkC kDb4mFuDarWnMxjAlRuj6XDc2MOGNJ9nQHqam5a1PMUUhDGgqEKPMUIbabG/YEFmbwCK EXK+EDlCsachMKJYvdhpMr2fLips4rlWt+rYwrNWaj7vY2ColqHOSzHcxeXFVmIa8xVE J7Qw== X-Forwarded-Encrypted: i=1; AFNElJ9dCLFxZS3b/kXTNltJ8b6foQKhQvQxHdT1b4dojtmwvJUinuvIt2NT0vgx0DrHr0OMEyizJR58NDWtyM0=@vger.kernel.org X-Gm-Message-State: AOJu0YyZ68DAj/iPa9UCvbCSVtOQzISJpsyuZd2+WOVnWDBLiCOyHPhr zfg3w9XNkXRgdnffwUpwHm+zVxg0wIDM9ePwEUCPPXhQF4aVZcqQ19UfA/66AJwOl+avo1Dtq9t Iwxj3z9SQqrWGLY5taNFDNj3MkIlVU3QEJA== X-Received: from dybcr21.prod.google.com ([2002:a05:7300:ac95:b0:2e2:2088:dca7]) (user=abhishekbapat job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:6592:b0:2ed:e12:3771 with SMTP id 5a478bee46e88-2efba5a4258mr4958847eec.33.1777937787455; Mon, 04 May 2026 16:36:27 -0700 (PDT) Date: Mon, 4 May 2026 23:36:18 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Message-ID: Subject: [PATCH 0/6] alloc_tag: introduce IOCTL-based filtering for MAP From: Abhishek Bapat To: Suren Baghdasaryan , Andrew Morton , Kent Overstreet Cc: Shuah Khan , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sourav Panda , Abhishek Bapat Content-Type: text/plain; charset="UTF-8" Currently, memory allocation profiling data is primarily exposed through /proc/allocinfo. While useful for manual inspection, this text-based interface poses challenges for production monitoring and large-scale analysis: 1. Userspace must parse large amounts of text to extract specific fields. 2. To find specific tags, userspace must read the entire dataset, requiring many context switches and high data copying. 3. The kernel currently aggregates per-CPU counters for every allocation size, even those the user intends to filter out immediately. This series introduces a new IOCTL-based binary interface for allocinfo that supports kernel-side filtering. By allowing the user to specify a filter mask, we significantly reduce the work performed in-kernel and the amount of data transferred to userspace. Performance measurements were conducted on an Intel Xeon Platinum 8481C (224 CPUs) with caches dropped before each run. The IOCTL mechanism shows a ~20x performance improvement for filtered queries. The kernel avoids the expensive per-CPU counter aggregation (alloc_tag_read) for any tags that fail the initial string or location filters. Scenario 1: Specific File Filtering (arch/x86/events/rapl.c) 1. Traditional (cat /proc/allocinfo | grep): 22ms (sys) 2. IOCTL Interface: 1ms (sys) Scenario 2: Compound Filtering (Filename + Size) 1. Traditional: (cat ... | grep | awk): 21ms (sys) 2. IOCTL Interface: 1ms (sys) Scenario 3: Size-Based Filtering (min_size = 1MB) 1. Traditional: (cat ... | awk): 21ms (sys) 2. IOCTL Interface: 14ms (sys) Abhishek Bapat (5): alloc_tag: add ioctl filters to /proc/allocinfo alloc_tag: add size-based filtering to ioctl alloc_tag: add accuracy based filtering to ioctl kselftest: alloc_tag: add kselftest for ioctl interface kselftest: alloc_tag: extend the allocinfo ioctl kselftest Suren Baghdasaryan (1): alloc_tag: add ioctl to /proc/allocinfo .../userspace-api/ioctl/ioctl-number.rst | 2 + include/linux/codetag.h | 1 + include/uapi/linux/alloc_tag.h | 87 +++ lib/alloc_tag.c | 249 ++++++++- lib/codetag.c | 11 + tools/testing/selftests/alloc_tag/Makefile | 9 + .../alloc_tag/allocinfo_ioctl_test.c | 508 ++++++++++++++++++ 7 files changed, 865 insertions(+), 2 deletions(-) create mode 100644 include/uapi/linux/alloc_tag.h create mode 100644 tools/testing/selftests/alloc_tag/Makefile create mode 100644 tools/testing/selftests/alloc_tag/allocinfo_ioctl_test.c -- 2.54.0.545.g6539524ca2-goog