Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp157058lqh; Fri, 3 May 2024 17:30:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXESPwImTdo+QQdwmPeQi8xzKAEobdxC4emiViyqDOYdLJK0ojtEFyXNYDYqmdG8gqxPqyR4g3j7MP9RVqGUQ5nWbeZ2ZqmsbqkGSbA5w== X-Google-Smtp-Source: AGHT+IEWeeHd3vid16FiA9XzcZN8ieI7FnKcHtuu5g8VFSdq9Cuo0gCvmvon34XIg51CKS6rwaNQ X-Received: by 2002:a05:622a:2989:b0:43a:dcd6:6507 with SMTP id hd9-20020a05622a298900b0043adcd66507mr5334226qtb.50.1714782620079; Fri, 03 May 2024 17:30:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714782620; cv=pass; d=google.com; s=arc-20160816; b=FeXJiFQlQVJZPNdsVgM/NM1HWk/EN5yMHbVJKvkRe8tNsfQ1V2hI5kK1v6at3zGRv1 jJzHj4X/rOARv1zVgxQMsnTIakfu+PqQ6cJ9brsNN3K4T4ayfGTMEJOtKZfN2sy5BqhZ FNdVgoOSW5BYUhPQp8NBqbHzbJ4nzb3SBmombBxAsTYXBFd3B7NjPynU/vb7X3aiPK+O mpbsvoau236vOxJmKaucY51g0yWfMxs1gN5iLA9OcmtAAf7A9lAHY9bXWk2gamzcktQ0 YJ0Mrul8G3iFiTX1qmRyyeqezhHPk9M5tzPW2OYOd5VIsVk4pVdMMQcQVGWvite0a47f D8aQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=A1WozU1IlOQqG66OO6wM+Xhl5cOuOWUBvpdW2Xw0xeI=; fh=RfPw7Llm8j6sRsJS3jErpV27cgSeeOoscbqGq4nLScQ=; b=0I6jE0Zq0qbbIZuCMBeyIK3AebsrIURB+ec83H+853Z4FJXi/PEnhi6bd7p8GZrtbB ASFCOrxSfrTtRPX+0KIOhfB25NiNgmGjK4scZ8JqywWRJGScS3yvZfL731nflfFn67fI PKyYqzWOvuGpmmWTkSd0WmULeBj/lOaBR5tTuD0WFnmC7/MT8+O9m5Y5R2L2ky1RN+ta zeU/5U+zMKf1tB235+59+TNpIhnLE55zu2642Kgfo1WabBChHD9R4KX93zaBHs2hobPB InVU9bhM/w2NT7fcMOQQqUyhsg+aQcRupwNiGSLxMsMHPanljypE91u/1SjQVcjKiivl bXew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=co0MnT07; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d11-20020a05622a05cb00b0043aed9d7685si4500586qtb.131.2024.05.03.17.30.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 17:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=co0MnT07; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C70E21C224AB for ; Sat, 4 May 2024 00:30:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85C654C7E; Sat, 4 May 2024 00:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="co0MnT07" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C1EB139E; Sat, 4 May 2024 00:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714782608; cv=none; b=lWVgU9oEXZ78pr2bsP2FDg00EX3GN8hrFk2RX/60h4c5fzbfkrrL/5Cr7sz5YUsP2gF6mycnH96fe4zfCgw1+AMLns/M+7eDh84wAM0Kz0KGLlnmgOjinSWbe53p2n+W2oqEYUbb0R4ZFa6Q4HvGNRkl3GOw8lRtOSaH1olxUsE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714782608; c=relaxed/simple; bh=TTG74m/eSxBs7jUVXRJ32J+Db4mE/GvMxzpez/uY7KA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WjBk2dne/miIVUONnm+KLcKp/ndK5bWFFPhVvyr3p+l9JkaZ3Ib9qCUjQwqI33GN0MidRZyiu//iP3wh2ssMUBipjTT4hDgPOcsePH9lFmXmFot2HrMX5sMYmnIOk/s7My6EV8iY7jzPeFuYjMX8boUp/U/RLervx2jFDGY8f70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=co0MnT07; arc=none smtp.client-ip=10.30.226.201 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- 2.43.0