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 7F4D0357D0A for ; Fri, 22 May 2026 17:45:44 +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=1779471946; cv=none; b=CquK2YfpuuZZiEOvhG1vbAn+DrhrgrhFYn2dztMlKjnmf4BF/16AGXCRuFebO+wSS0EUL1yLeUYeCuENLkhMkF/WPvDE9TTIYBt0BEeBSH1X33ih0A3KnVe0Jm8SIE1yxHqP2zqJ2akiGZxe0/qnc2Vgkln/lAVAnYqL9d5GoQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779471946; c=relaxed/simple; bh=fjUUJbkfAqezKdE6dfx0M8Oahe/zQdqsRRNlhXBgI3o=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=cWyVVXDASdTc/P37krn44UU1AER+WWiPvnJ8wyK7s+nkEedqQQHr8UNH0jTuQxQ+doOJ6/oqStiuL6sv5RvkUEzCKh+phUoauATZ3pstcduuR3XhXzkFr39hfC452uv1mMBbMXxPQT4djFXK9SAx4+aqCSDqrQIFTOmQk2QjwK0= 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=P56lvFQl; 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="P56lvFQl" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2ef62078ee7so8715667eec.0 for ; Fri, 22 May 2026 10:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779471943; x=1780076743; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=RUhGNhxD0QOUIs2ABS/Rux/YDmNy6ndLUdXOBB/mJ3M=; b=P56lvFQl6VgPHwAVrtIzXCd7BfJQZTFp74nE0FQJCWPH5HTLtOnOXh9iah5odNsSI2 zgHhnhAvnFHAB3+a0KTgibfM/UrgNrLTtwJWWn/Dk5V2phnorCizzwFeZDGsWX+K0ZxU s3QsyMpRRXTF2Ggij4WeOxVVYF961Erd85z6bOo0npHlJfiEJP8Eb12ij/XlpHSLouHU RZHbXYwqzCHi9cNf79FBxQnOLmC3wHpN1cS72Z6bascMfEVER3O5A8kiTILthydu+Yj8 Fe85CkIdkplz0TfGts4L/8C2da9Bi5HfXnwiSltNdAAZv2Yxu+4I1OIPrIDN1s7ZertF 69vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779471943; x=1780076743; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=RUhGNhxD0QOUIs2ABS/Rux/YDmNy6ndLUdXOBB/mJ3M=; b=YsegchJJqnh66Yci80mdGzPGJ2S1U8I9hA3xec3njvscsc9luzXonEp9RLHMWLphoT hqaGqJrk01u5KXhOfdYqpOcfrps+Jv6WbZVN8yBq0VzX2w1dvAAAZdbZp5JKJ4n4HfOb Ckr5M03PNRRAikj+Co9lv/0ufx5QjcsWNZcYkD8uasnqNsFvMnEGUDwCBfwCfNhUPwNK UWIcR92M7jTDt8bfUsY6g0XDTIhct4Xw2ttGsu4/0MM0oSzr1i5jti/zpuvO5KjKfZwk 7VmlMZxg6HWVCV3cDBm1lIzJZDz+SW6L0X9Km/T0ym4TWp7j3e6e3hCdjrZNK5lMa7uI 0gkw== X-Forwarded-Encrypted: i=1; AFNElJ/tOoB0QeYp0K/GX4YA5siFu/REWhxrfY5rjPmZt1MXL29DNZwbiBFyCTV1bW8HK9lIZg/MotXDHkyK4DU=@vger.kernel.org X-Gm-Message-State: AOJu0YxQzIse67D1+ySFOi1K6jeZ50te7cmUpgaPM1tK/4mJHyInZwik iDtc5ISwxWDWPUbJHlVGjHBxtc69/QU3JDJe7J/6QL5KIoS62Ks6D7aGW0u9lRrikh1tNxGza25 b40Q9+B8g48qUFGGFq5zBhL5E9eVQ59srQQ== X-Received: from dyev16.prod.google.com ([2002:a05:7300:4310:b0:303:c170:9611]) (user=abhishekbapat job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:6588:b0:2f2:1b3c:d824 with SMTP id 5a478bee46e88-3044904df42mr2422519eec.7.1779471943340; Fri, 22 May 2026 10:45:43 -0700 (PDT) Date: Fri, 22 May 2026 17:45:32 +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.746.g67dd491aae-goog Message-ID: Subject: [PATCH v2 0/6] alloc_tag: introduce IOCTL-based filtering for MAP From: Abhishek Bapat To: Suren Baghdasaryan , Andrew Morton , Kent Overstreet , Hao Ge 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) v2 changes: - Patch 1/6: Introduced locking for m->private. Also included the new uapi header file in MAINTAINERS list. - Patch 2/6: Handled the case where ALLOCINFO_FILTER_MASK_MODNAME is passed but ct->modname is NULL. - Patch 3/6: Moved min_size and max_size outside of struct allocinfo_tag into struct allocinfo_filter. Added validation that min_size <= max_size. Prefetched alloc_tag_counters if size based filter masks are provided to avoid assimilating per-cpu counters twice. - Patch 5/6: Removed the hardcoded logic to skip the header, instead the test will skip lines that don't match the format. Also included the newly added alloc_tag selftests directory in MAINTAINERS list. 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 + MAINTAINERS | 2 + include/linux/codetag.h | 1 + include/uapi/linux/alloc_tag.h | 87 +++ lib/alloc_tag.c | 303 ++++++++++- lib/codetag.c | 11 + tools/testing/selftests/alloc_tag/Makefile | 9 + .../alloc_tag/allocinfo_ioctl_test.c | 505 ++++++++++++++++++ 8 files changed, 918 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.746.g67dd491aae-goog