From patchwork Sat May 4 00:30:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 13653687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8818C4345F for ; Sat, 4 May 2024 00:30:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0E416B0087; Fri, 3 May 2024 20:30:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBD206B0088; Fri, 3 May 2024 20:30:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAC086B0089; Fri, 3 May 2024 20:30:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BD3F26B0087 for ; Fri, 3 May 2024 20:30:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5B4151C195F for ; Sat, 4 May 2024 00:30:11 +0000 (UTC) X-FDA: 82078831422.18.69FCD47 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id C251B8000D for ; Sat, 4 May 2024 00:30:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=co0MnT07; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714782609; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=A1WozU1IlOQqG66OO6wM+Xhl5cOuOWUBvpdW2Xw0xeI=; b=Vz+H+hyV7XyS7CBzUdLcHLI6i8C3dxyjQZv3/0ZHMFNfcnjD9d0cEqOUUe73rDcGH4n80B JuDEWE8HZ4MV18ZIb3Prnm/2hVcm4qHrvFX+Rx34fYu30ykfF7KlpTowiPw7WOcEbye8t6 gHMP0WYZ2xCX6W8/kStJ7YKgJACpR2w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714782609; a=rsa-sha256; cv=none; b=Qe9B5EmUyblvyXF1jJK9izIRR+Zivh3PiCNDluPpEjXkeFFH3WF9Vik7bFhigiXiJ/6JIV 8FeEWktN0MeVbKpTQmTDF2xFAKf8KoF9tWLdcDLjhH1mRVyKDYmd1bagm20TUmRB/haU+9 rCLTcOePJbd7uaPjNP6HjVvDmQH8amU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=co0MnT07; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8B1B661A7C; Sat, 4 May 2024 00:30:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12BE5C116B1; Sat, 4 May 2024 00:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714782608; bh=TTG74m/eSxBs7jUVXRJ32J+Db4mE/GvMxzpez/uY7KA=; h=From:To:Cc:Subject:Date:From; b=co0MnT07AYnGkVusTnpu3exa2v9kMVLAecTi7KUpW2DrkNTY2ezwHeaQl1yGeSFxR HjW/eAsqfpi/LP41Xbv835HtALENu1vTIX+iLPIizCNPWOpsAA7X2xA9/bnlgcuHND zLb0V9d92DztsGaD6Yh97kyj6FIYDiNBxiAL9UoCi2jNCJRfD7lJhLfqOoCeeaqexY nWyM9eT5FpkF0TVBMTNqBPEizJwkwaFjCAE4RNm01hRsmWhRCoTdbavC8GE3LbkmxS okXt7Xp65ytfKkcBxaLbNB+NAYnU0dMuTQabaSxXbvXh44RHXfETfSi8nSOD00p7MM NPKiIB4wjccDg== From: Andrii Nakryiko To: linux-fsdevel@vger.kernel.org, brauner@kernel.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, gregkh@linuxfoundation.org, linux-mm@kvack.org, Andrii Nakryiko Subject: [PATCH 0/5] ioctl()-based API to query VMAs from /proc//maps Date: Fri, 3 May 2024 17:30:01 -0700 Message-ID: <20240504003006.3303334-1-andrii@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C251B8000D X-Stat-Signature: twwoged59d3ks4jg3fyapr9fkxce5ssj X-Rspam-User: X-HE-Tag: 1714782609-344576 X-HE-Meta: U2FsdGVkX1+98RMR3ThP9Ee6YAJ4waB3vxZdhRitT0Di+SrJRqgpugw+adK0sBOHX5bIbnlBTSTGq1rM2ukmNQwG+Pn+uQvbMQefEL+uzem7Pb+OiPIMFtamUOLYJpjoIQrTaMkZOKv1YaxSDDARzhxPP/WuttOQ5JmPQNhOepuPwpyKyhYplPg3ZPbNlnJ49RgaSxjZT689oi5q/k0nfksma5UJNalCxdQUF5d7nzZeKjpZTF0DmFR7nWu8MQiYAL3fQ3TUxhB14rrcdPaJGZLzXBjJB00r9gFpnW2WAEigjFwwPD7MWI4dj5lLkU5MmJrt7N2qkfiU+ugjxn7Mig0LT3nPKhukW+vGRZlBiVjOZxJOCejGv0Q33apHX01EhiiZg9PP2vdm2ZabuBD8ESn13zw3nVLSsyGEiPA64CAhQtLfFisF9Yz57hqERpoMv3JgdviVuq3511AJA/D55SQfY6P8VJrHU22/FdJ3tQUgQKXhn8mk7/g4kuQcOXRv8qqhC9kUkr1+O5o2D02YO7W/INqxyIVRNxrt84JkMdpIdS2A0+4K5v8VCx3RxQN39G6oCW9OxG1Vw266XNZkb3l2V/0ODZbERAJdzlL+SeGwWurtq7opx6ZJdl40m3UA3tTwS5c2MaO1N4gft813emWsrZDG9eJKdSxdRx9tY99y1rbAqBcHYKyNQvj3TnFxn5eTlkiZiIiYw3ZRSSNs6eRk9J0G9cDXFPRP6V//HyXbPVdCuOtex0IjuHD6HIDA5Xc6Tpi1sa/Wg9Ut2DYWBHrB0isasY9fo1EP2dGkrp+cv9iSA1+YGhOalhnhNeX+cOZ9ppfAYljQqE4RHe0wP6oElnnphH+DVe0qYPtyReOPxr3e5upkQiQKrPS/s7YbworRQrq/ZaXZBytwGcR+mEk0yVs9/u6l4IAD8O2FtMUrXxL6PuaPb7+c8TR32Q8AnbmzfBqryDZf8UyGMqb 2C2NA/gf XkoS9cYb4CdNcKFpAwKz1QswMnsDZ8edNW/Mz1afwV4xIdi0rbPGf+z9bWHvsHu1/68sUaXnCVkcO58s+7wRxy92jK0zNsb7SlIDpBtOTb2z97DkUf8nVaiJvWLvHXUEudYi5e1Wbp6mSgfd3Lq8rjuCneLRUUCqqOhRLDuPcIGhojq96JOi1stfPzw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Implement binary ioctl()-based interface to /proc//maps file to allow applications to query VMA information more efficiently than through textual processing of /proc//maps contents. See patch #2 for the context, justification, and nuances of the API design. Patch #1 is a refactoring to keep VMA name logic determination in one place. Patch #2 is the meat of kernel-side API. Patch #3 just syncs UAPI header (linux/fs.h) into tools/include. Patch #4 adjusts BPF selftests logic that currently parses /proc//maps to optionally use this new ioctl()-based API, if supported. Patch #5 implements a simple C tool to demonstrate intended efficient use (for both textual and binary interfaces) and allows benchmarking them. Patch itself also has performance numbers of a test based on one of the medium-sized internal applications taken from production. This patch set was based on top of next-20240503 tag in linux-next tree. Not sure what should be the target tree for this, I'd appreciate any guidance, thank you! Andrii Nakryiko (5): fs/procfs: extract logic for getting VMA name constituents fs/procfs: implement efficient VMA querying API for /proc//maps tools: sync uapi/linux/fs.h header into tools subdir selftests/bpf: make use of PROCFS_PROCMAP_QUERY ioctl, if available selftests/bpf: a simple benchmark tool for /proc//maps APIs fs/proc/task_mmu.c | 290 +++++++++++--- include/uapi/linux/fs.h | 32 ++ .../perf/trace/beauty/include/uapi/linux/fs.h | 32 ++ tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/procfs_query.c | 366 ++++++++++++++++++ tools/testing/selftests/bpf/test_progs.c | 3 + tools/testing/selftests/bpf/test_progs.h | 2 + tools/testing/selftests/bpf/trace_helpers.c | 105 ++++- 9 files changed, 763 insertions(+), 70 deletions(-) create mode 100644 tools/testing/selftests/bpf/procfs_query.c