Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp75474lqh; Mon, 6 May 2024 11:43:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWs59pnOd//d0uan4V90LLPbKKDelzEgryCNcWpplpMN4xEDIRJax8lkp+/kW5iN1zCnzyNCwxXW/JSu+BJN8ED4UYEnhxbcW0eta+Aow== X-Google-Smtp-Source: AGHT+IGSkWo2oEuBE3peLLK+7SILBEo/ZRhN3lspkPWnwxwqiouyoeuMHra0Q+NsVKjDqa7LC644 X-Received: by 2002:a81:7e0a:0:b0:620:33dc:8341 with SMTP id o10-20020a817e0a000000b0062033dc8341mr706297ywn.25.1715021029643; Mon, 06 May 2024 11:43:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715021029; cv=pass; d=google.com; s=arc-20160816; b=X4rhDdzeEpPw3KeLNb+LZ2Io7BqeqQXm74B4Vl2Pdjk6eR/B029bDdEDquX6Mz+dle JMYdQCLDOWEdepV52uirA/gEtd+kjD896tHcWYz0qLXsrc8V9zZkbknhIHnqfQlU98D+ CCmon+XonjHryp4eNr0Ei04BLhUUF/ZqGm0m44SQUN7dwGoE85q0WxKLNP3VQ5k5alHk t/R2VsYUhSkgF8Sy+2gjuMK6gaP2pkdSbgWz+Ww6xmyQe3XBhTX4CcCySnj8P0ipJu59 hkF5WHfRQv/sb1YjDOzMUvNm43ZDa4+j7wCVrQ8kvyhlzAC5dwdxlTPzReWUX5zTQ/TS Hwhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=aMqIHyLa/gmjK+J+Bo0q9JLXeRdO7aoxpGEVpFxtErc=; fh=Bqvwr8Pz/wtGOYJ5aLRGO+USUsTYYq5zP6UiaX1WC4s=; b=jm7qKbd0D+gQ5Uzu0q9DRqdXkfEenkLyDbiBcw7S6HeI29U118dzZN3lC5hWQpbUFs 4pFLBUSmPbO2k7E6KsSXdXD3ZDBjkQCU2XIffIH6o4u42y05bXxViLJS31jA8OZw7jyo DOSxYwS08swN5p9nFQq6tOIDP4HYiBgcb4OGnjSH9y1guYHJO1+px5CYNcgz6eJpSVZj CGYyEBniJ2wL3fVeMsMsy9HmzkoRrbhGYRtbDvapMAiNaTl1MHcmfWXjLvQm/fvJccd2 3uF8rIScihfi0lMDGRk31pO4p6EA3/VKMAE+qivwPsEfsdvPtpWxY5BPsvIp9F6rWnIR hQEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QWamJBOm; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170304-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ep22-20020a05622a549600b0043acc86568fsi8976598qtb.712.2024.05.06.11.43.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 11:43:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170304-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=@google.com header.s=20230601 header.b=QWamJBOm; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170304-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 50C961C20F98 for ; Mon, 6 May 2024 18:43:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8B4C158DB0; Mon, 6 May 2024 18:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QWamJBOm" Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 9A7AC15821F for ; Mon, 6 May 2024 18:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715021015; cv=none; b=njLse14ILqmHv/6JMxFrQ8dTlVaxmcjOrLG2+7TwlvRFmwuwV0OKCRriAdXQefV1v1rQ0IxHSjlWBDwL/y3eMRaLSOWORsfu2OaCBiHJYcCPhn+DNTxkdIZjQz4uEz5fS6+LzzxwExE54cLj8vpttHi9I/VlUTdBYkEI5mjMy94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715021015; c=relaxed/simple; bh=sPMDL23QS9Xd7hIJCfVoH9uVk6HP1D83LxcnL9CKbhw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fnsDujq8skNArWaZ8ioVprh0y1mPC2/Q8GqObnypLXwEemBcG+Uu4PqVe2wfJICqcwbU32Zbwyn/uZnw0ep+4TWLQaDCoo4OEQRlsXWRTDKoZIPz/wee/OkEJW4in/4bTAH375wDyJGIvhwudu+S6dTDHx8dZQbZCitIWFIujS4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QWamJBOm; arc=none smtp.client-ip=209.85.214.179 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=google.com Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1ee5f3123d8so28285ad.1 for ; Mon, 06 May 2024 11:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715021013; x=1715625813; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aMqIHyLa/gmjK+J+Bo0q9JLXeRdO7aoxpGEVpFxtErc=; b=QWamJBOm4/1TXFGAlwW2Wp7gFQIn4jOLbK8k/7TXtI6Kh/BdcgxPiBgf8NOsA42nAm uQiK29razQgTolKJ83t8GlWw/aWYiHnrKObkVwYk/yQjbnK9rBslQDGQhtZFLayX178G 4OCpW+B+8JqGXHydmgVyA6NPi28sh+1m1G9q+TfOHJV7UFKThKdOApqV0YDJLTcH7F41 bGN1X61cVCHyuYRiUdpYJyQrDOqp2+I3OCslH0/TnK0I0o7rIvQqLyY8PQ5IfFI4/+GX Do8PA1fFt4N5F6O/ozmCq7GZH3m1h5jv0Q5oEwTXYtr90EefNSITLAu0NHBOKZTcQgm6 Kz3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715021013; x=1715625813; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aMqIHyLa/gmjK+J+Bo0q9JLXeRdO7aoxpGEVpFxtErc=; b=ReHZMURZ4l4m78KVXq3zKuLGt1R/UxcYc/KLQKDqmuyrBnSFaIo8Flw0wkTvUdtUuA xs4dSTDEn+cNxc5rq13rE9B0/vw6YIlD8oK89Elgdf61VN2ZDnYoBt++5SjV7vfDB1iE YoM60Mc/SshZN9x891u+pRhUReNhCEWOfCYzHSv0zC7wVG6AMY1RP+QXHy3ORITgxpSR LdXgMMEnRmxRMWZw5ulBKS7qhXN09aMx/sPxyQodjwBsX8fSCJcONUwM5zNQ8K+OCLDz vF5uDFASip4gQHZOoE0c8ak5PMEReU3nXuIO67Zs435f01wCut92qZ+cRCZ8RrijmNzq kAmA== X-Forwarded-Encrypted: i=1; AJvYcCXSj+YzBdFjTSg8FxG+p+Pzt251qmqzlL9YHzZR19OOoTsC7t7q7uYX0llLTZ7qef+LiTx7Ns8l5JXxqikZViU7OJe7nT+4YBJdEG2o X-Gm-Message-State: AOJu0Yz+yYWJQ6NmtN5OOAdMcOauczsOutrtGoUPTQiwI3rd7Ni+iUsl U784meVisqvwWteUuilMo1P8BeNRsKwkU/+PaHC4RX62hEv0xT5JooE+DCv/rrImVdbbXyx//w8 +yl5E4+CAo5JOVjP7IGGwauD8zAMKqeWR7wbq X-Received: by 2002:a17:903:2003:b0:1e2:573:eecd with SMTP id d9443c01a7336-1ee6a6a8e32mr195735ad.3.1715021012487; Mon, 06 May 2024 11:43:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240504003006.3303334-1-andrii@kernel.org> <20240504003006.3303334-6-andrii@kernel.org> <2024050404-rectify-romp-4fdb@gregkh> In-Reply-To: From: Ian Rogers Date: Mon, 6 May 2024 11:43:21 -0700 Message-ID: Subject: Re: [PATCH 5/5] selftests/bpf: a simple benchmark tool for /proc//maps APIs To: Andrii Nakryiko Cc: Greg KH , Andrii Nakryiko , linux-fsdevel@vger.kernel.org, brauner@kernel.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-mm@kvack.org, Arnaldo Carvalho de Melo , "linux-perf-use." Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 6, 2024 at 11:32=E2=80=AFAM Andrii Nakryiko wrote: > > On Sat, May 4, 2024 at 10:09=E2=80=AFPM Ian Rogers w= rote: > > > > On Sat, May 4, 2024 at 2:57=E2=80=AFPM Andrii Nakryiko > > wrote: > > > > > > On Sat, May 4, 2024 at 8:29=E2=80=AFAM Greg KH wrote: > > > > > > > > On Fri, May 03, 2024 at 05:30:06PM -0700, Andrii Nakryiko wrote: > > > > > Implement a simple tool/benchmark for comparing address "resoluti= on" > > > > > logic based on textual /proc//maps interface and new binary > > > > > ioctl-based PROCFS_PROCMAP_QUERY command. > > > > > > > > Of course an artificial benchmark of "read a whole file" vs. "a tin= y > > > > ioctl" is going to be different, but step back and show how this is > > > > going to be used in the real world overall. Pounding on this file = is > > > > not a normal operation, right? > > > > > > > > > > It's not artificial at all. It's *exactly* what, say, blazesym librar= y > > > is doing (see [0], it's Rust and part of the overall library API, I > > > think C code in this patch is way easier to follow for someone not > > > familiar with implementation of blazesym, but both implementations ar= e > > > doing exactly the same sequence of steps). You can do it even less > > > efficiently by parsing the whole file, building an in-memory lookup > > > table, then looking up addresses one by one. But that's even slower > > > and more memory-hungry. So I didn't even bother implementing that, it > > > would put /proc//maps at even more disadvantage. > > > > > > Other applications that deal with stack traces (including perf) would > > > be doing one of those two approaches, depending on circumstances and > > > level of sophistication of code (and sensitivity to performance). > > > > The code in perf doing this is here: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree= /tools/perf/util/synthetic-events.c#n440 > > The code is using the api/io.h code: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree= /tools/lib/api/io.h > > Using perf to profile perf it was observed time was spent allocating > > buffers and locale related activities when using stdio, so io is a > > lighter weight alternative, albeit with more verbose code than fscanf. > > You could add this as an alternate /proc//maps reader, we have a > > similar benchmark in `perf bench internals synthesize`. > > > > If I add a new implementation using this ioctl() into > perf_event__synthesize_mmap_events(), will it be tested from this > `perf bench internals synthesize`? I'm not too familiar with perf code > organization, sorry if it's a stupid question. If not, where exactly > is the code that would be triggered from benchmark? Yes it would be triggered :-) Thanks, Ian > > Thanks, > > Ian > > > > > [0] https://github.com/libbpf/blazesym/blob/ee9b48a80c0b4499118a1e8= e5d901cddb2b33ab1/src/normalize/user.rs#L193 > > > > > > > thanks, > > > > > > > > greg k-h > > >