Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp615569lqh; Sat, 4 May 2024 15:13:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBGFoqnJCctfWKknvhkWk4GWzy8qC9A32mqmHr0kNMaP331ICB2ip2oCVDny92pxr4x/LoQMgbniaVZLuG2FmcFVdns8OgsaSFjdjtKA== X-Google-Smtp-Source: AGHT+IGcnKks2U1XTpyC/I5z8UyPnr4F0ROlOmVrkOhobIsyUZE2SLS4Kxefdpf2bFjJZo9xtFhD X-Received: by 2002:a05:6402:354d:b0:572:6ee9:5a2d with SMTP id f13-20020a056402354d00b005726ee95a2dmr3922678edd.12.1714860836218; Sat, 04 May 2024 15:13:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714860836; cv=pass; d=google.com; s=arc-20160816; b=QCIGpCZaF9OVhgVlhFpjP5+HZj7uSjLipF30Ole2aF6qJrpraepD5XxzCw+mv8WKy4 EJqgyTZZxMOmAjbICvzqzJv2VTmW76qkR4YkPd4ld+n8DDD4eYZ1pwNG9o93l47o4kry Yo7uWC3TQ2DxwKi2mCrsc0Woq6h83K52Y9RvTYFpBNGJUIAj2buY+qQ9djw2R4AenuDg OEJ3DiMF8m1yFfnGwtDk2vJm2UK9afgsdiXsJf/n5UVGIfVXuOm7SHcyO8RaHUm2TwMb wGKQO5AhxzGnrwG3+ZbHFzNcJc1Z6Qd0r3y3mSUW0poMe+HhPByCAL+GAXv184OeE3Gz hTTQ== 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=A9unkjuVShUEk/iPiPG7EPoKRZdQZGGq2FXrz5dixV4=; fh=AtcgT7EtmoU79EIaKKYjXSXqcSFqo+eP/0Fj9DXd/uQ=; b=GNe+gLs3RzRi03tGIzsJpJ9hqwHGai2u5emA+kXq2EnCHra/aaiqiKh/MNqq9ZCqE3 nzQIqBbo8ER7lmHvELoCGe5K0VGcm/STP42IWzeNaRgCF3GR6n6EVr9Bjq91g507S1Eh Y/ZfOl8rPoEaH/PFzm7NuDKiVfxZt4CLezr73PdNvHHCvhDorzBsdB3ZUTlZlnOTyI1x xkmcZYs4DuRCnIc6sTSLpbGqHQL4ktEu+fqj23PJ6IzVctMjFmYev+oFBiRlFu5uwPr+ V01eFFt5esu74h3NleFauHDOMeD6usInGp0blBqDLyMrMQXRXBurWTMyDP70O2ECznvh V26g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gxkYNDnx; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-168841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n7-20020aa7d047000000b00572ba2a782csi2953269edo.106.2024.05.04.15.13.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 15:13:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gxkYNDnx; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-168841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id BB96B1F21880 for ; Sat, 4 May 2024 22:13:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24ADB84E03; Sat, 4 May 2024 22:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gxkYNDnx" Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 E3BC43AC0C; Sat, 4 May 2024 22:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714860819; cv=none; b=XDmawf68TeY6WHVbCjSjL+mqgTTsc1rFGBHPeAq3xv8Az2JEjuQ5UtPphDutPWlYC7zuG5NiCKTX1SjKco3qyPOLQCdacCly2K52sSL61Vbis7ngU3AslvA7089SYI9eHVb5ao6Z+10nAfBZo+lodBgUO7oPWVGkIxU8LZO4iJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714860819; c=relaxed/simple; bh=+bKYM7oK9MxJEWHIqHgavPy2YCwpLmxgKmFnVCuqWpU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AZTnZzBU160Er7Qf4hqhUfX/Qi5g7svQppNra4Nl6wWK5x5HFZU3ju7eGnefqQHqAxDk2RuYDv77qBUmxns+bnOAIgNlu9VbcvSW3NipUU30kIbatIQsh5VzoOz0BjERB6GD+X2pjW4+dRR/cuwQx7BjMMVdARpoeZ5wwp0V5GM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gxkYNDnx; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5dcc4076c13so489670a12.0; Sat, 04 May 2024 15:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714860817; x=1715465617; 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=A9unkjuVShUEk/iPiPG7EPoKRZdQZGGq2FXrz5dixV4=; b=gxkYNDnxovK2McyUoynA74OO5a+7EzqcQORuXu3P7BFT2UTh8An+mtT/8jIIrjZ9k7 0+lUQ+DYoV4havUea3J2PC+uNU++SxQVnHRr2UykiycnQEpTiexiANcBy4ed5JKKWdpo tXolgOQZnIXBgKebcPWIBBl+0jhAyyXx5Nvgid7dgU08hXs2+mRRYvsUH4vQkjUaXNDo ynqdfS/FM8Ro44xqKXeKpjQXQ33SXMX7EvD4OQ0iqK11vjHb9GeQIescgB37PUdT/fsR VvzNB3YJJ433qTJsGqPxTCKS0HY9hs/u6A6WfbVcmcg/KgA8Kq0EBLe/1HWgaG+h5v76 ATJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714860817; x=1715465617; 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=A9unkjuVShUEk/iPiPG7EPoKRZdQZGGq2FXrz5dixV4=; b=qZcVsG2/MfSRiu9W2+G+5lRedWVKcLFkmu9aYifd60tjMKHpI40gK/x4zs6ZmuwZen meQ/09TmSfK8GzKZPhQibccDIU8ecL+H0UTIbQoTox2nuOhNzQ7iHwDLDSjRW/IljkZO kkPLho7j3xmRI2VZ2UNvtPmE0HhFng8JnIdH7FVjkzkFb7/qMeJxb86JljTS70IGRf9j RuXBMFXpF7z6FRn8WLe7QaTW9jQe20UlsmoJlRSMzNkJbFUxqqwLpZH3eVtHVhYnf5J0 oMNQxyqplcwVLn8DHJ68wM4kGvOpkN9LEuco6QxEnNRa4XNvddgFI/c1amS2cDQ9kSMv pumg== X-Forwarded-Encrypted: i=1; AJvYcCV5bTxFTP1etFWl4Z6tI6qwb0Ud2vY16GeO9PT0YB+ZvRMX9brYuxeOjkmMih0IQy9vubqxS1FnjSKRbR2KLjFhMDRY3NGch7ihzBK835DyqMds6yHxLA1M6Qp3hy0/qLZ6L8sQ/DvvjWcoL5iRetPQw66MAJgZuyj8R3FZe6VvZA== X-Gm-Message-State: AOJu0YwR5RJHiMtzzsy21uZ2CHd9ovCkR6z6s9NHCfBiAwBR83WtGXac NUDPKb9YwLmD68UzVCbunnY2swvTv/bNoKYdXQtvmFTIysz2ZxWBTOff7CKdrPSIbgmIMatrf7R KSAK0u+7cp/lwannyeVoYlOuWxxA= X-Received: by 2002:a17:90a:d709:b0:2a5:be1a:6831 with SMTP id y9-20020a17090ad70900b002a5be1a6831mr14208459pju.19.1714860817143; Sat, 04 May 2024 15:13:37 -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> <2024050425-setting-enhance-3bcd@gregkh> In-Reply-To: <2024050425-setting-enhance-3bcd@gregkh> From: Andrii Nakryiko Date: Sat, 4 May 2024 15:13:25 -0700 Message-ID: Subject: Re: [PATCH 5/5] selftests/bpf: a simple benchmark tool for /proc//maps APIs To: Greg KH Cc: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, May 4, 2024 at 8:32=E2=80=AFAM Greg KH = wrote: > > On Fri, May 03, 2024 at 05:30:06PM -0700, Andrii Nakryiko wrote: > > I also did an strace run of both cases. In text-based one the tool did > > 68 read() syscalls, fetching up to 4KB of data in one go. > > Why not fetch more at once? > I didn't expect to be interrogated so much on the performance of the text parsing front, sorry. :) You can probably tune this, but where is the reasonable limit? 64KB? 256KB? 1MB? See below for some more production numbers. > And I have a fun 'readfile()' syscall implementation around here that > needs justification to get merged (I try so every other year or so) that > can do the open/read/close loop in one call, with the buffer size set by > userspace if you really are saying this is a "hot path" that needs that > kind of speedup. But in the end, io_uring usually is the proper api for > that instead, why not use that here instead of slow open/read/close if > you care about speed? > I'm not sure what I need to say here. I'm sure it will be useful, but as I already explained, it's not about the text file or not, it's about having to read too much information that's completely irrelevant. Again, see below for another data point. > > In comparison, > > ioctl-based implementation had to do only 6 ioctl() calls to fetch all > > relevant VMAs. > > > > It is projected that savings from processing big production application= s > > would only widen the gap in favor of binary-based querying ioctl API, a= s > > bigger applications will tend to have even more non-executable VMA > > mappings relative to executable ones. > > Define "bigger applications" please. Is this some "large database > company workload" type of thing, or something else? I don't have a definition. But I had in mind, as one example, an ads-serving service we use internally (it's a pretty large application by pretty much any metric you can come up with). I just randomly picked one of the production hosts, found one instance of that service, and looked at its /proc//maps file. Hopefully it will satisfy your need for specifics. # cat /proc/1126243/maps | wc -c 1570178 # cat /proc/1126243/maps | wc -l 28875 # cat /proc/1126243/maps | grep ' ..x. ' | wc -l 7347 You can see that maps file itself is about 1.5MB of text (which means single-shot reading of its entire contents is a bit unrealistic, though, sure, why not). The process contains 28875 VMAs, out of which only 7347 are executable. This means if we were to profile this process (and normally we profile entire system, so it's almost never single /proc//maps file that needs to be open and processed), we'd need *at most* (absolute worst case!) 7347/28875 =3D 25.5% of entries. In reality, most code will be concentrated in a much smaller number of executable VMAs, of course. But no, I don't have specific numbers at hand, sorry. It matters less whether it's text or binary (though binary undoubtedly will be faster, it's strange to even argue about this), it's the ability to fetch only relevant VMAs that is the point here. > > thanks, > > greg k-h