Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp771296lqb; Fri, 24 May 2024 12:37:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoQvweE4WDHhZCSWoR7kNMl8+OBjTevnx+BwsrhH4YhJRc7RXXFOPumJAoYkR4s6k1JzseMEAl5VK/43QNuq/WGaYHmFiTViGDZiM5OA== X-Google-Smtp-Source: AGHT+IFZaN0+LB/5OI9iyTNOyEgLmUciRx5FVuXXSbshRkzKvRCqie9pkzqs9dfaN5oEYu5knPxC X-Received: by 2002:a17:906:80d2:b0:a5d:3be:f101 with SMTP id a640c23a62f3a-a623e8f72abmr526431266b.18.1716579464633; Fri, 24 May 2024 12:37:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716579464; cv=pass; d=google.com; s=arc-20160816; b=Zt3H38w9mKzcjywuQBDWITkPPuyr6JAAGP2R8UmHp/ESK7Pvs0Kjen963l7Ci4V5CR 7mBK2pl5YaZk21Ox/m0/zzd/FD3DuOjfznN9HdQ+Rtd/mm7/TWpb6yDAx1/ljNuzTdX5 7vhU2njpN+4RzayfAMavBBqdehOgXQ5fRj3hIEEfazHZaM+vU8dV0ZMPgasw4rT1i1rC wQUfzU4tzVfELSi44FJ9ir4c8atMJWsI1m2QovOjf+O59hzxQgO5xkK6sKiwR6TQ9UvB 0od6OlqN7RVgBCIhhADBOio+DO8ZV4aNttPe5OYWYAcRLF955eGeM7EjZj0GcCxYiDiV KtRA== 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=dzHU3P7qRxjg2ho0r9MNensCeoxNpPcQCmFpOL/oYJM=; fh=xqkOKgf0mL34JKOZgMgPts0jTpVereshCpLmCoSmu8c=; b=Z5vTZzX4Lr2LIy+bcva32mS60GXPUy8Gl0uE9q8XL8oX2aqnxPi4VkgY3iJhKVHhYA D/YeBPeQl4QqnWfINtsrHeQgT1Hl65xCWzIOGvGFVxFjcYPIytazl0Dq4ND7cCBB91aR 5CcnDb5hjX17RVQdCd9F0QD5R0nwGDer3vrU+QAscS2eFqqwlI6VFF95f2kqiJjbU45L 0scuUE0D3xOi13hy/3yRuAlJxJdHNSUkPmoM5NpI3y4SliZmwyodlxbDwj3vnRIk7Vnz 9VwI25CA8a11VcwzUKwa4goU4dvbF4GZl14rHz8jVf29DuDzBkt/nJU34CvqFOKHXT7H 6xjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ulzdx/3z"; 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-189047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189047-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 a640c23a62f3a-a626c7ff300si114216766b.135.2024.05.24.12.37.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 12:37:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189047-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="Ulzdx/3z"; 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-189047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189047-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 611E71F21A82 for ; Fri, 24 May 2024 19:30:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 215E56D1A0; Fri, 24 May 2024 19:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ulzdx/3z" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 F1CEE5CDE9; Fri, 24 May 2024 19:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716579033; cv=none; b=HBJOpjZQkMdylN7GT4CYxrdU7z+OgnAgsLD4QIuh7kV7lA5ADmjKlTSuTdrZWnVdZwaHUM8zSzIiMMDi/AbtOnVtgchopkMyygaJCqD7Oft22pEuC7R7v09u8DHHo8qtPuRbZqcPwPhCGks9b47XMtjDAueMC4gpzip4xfTEPn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716579033; c=relaxed/simple; bh=dzHU3P7qRxjg2ho0r9MNensCeoxNpPcQCmFpOL/oYJM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fnqtJfzBRM5QCN/b9OWVfYHSKuZ8rQwZ+ynWgzbPISlelMN/uW2gg60rwlxwYmMkYunzlXaBhpsIH3wVBB+g8CPtrM2do/IzwXbCGCd12ShpA5fpMqpl5iDvoGGah/7uO5lhYI9jjCiCknLmW9KElgIQ38UFlO5kRDD3cGM+0z4= 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=Ulzdx/3z; arc=none smtp.client-ip=209.85.214.182 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-pl1-f182.google.com with SMTP id d9443c01a7336-1f32b1b5429so21791305ad.2; Fri, 24 May 2024 12:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716579031; x=1717183831; 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=dzHU3P7qRxjg2ho0r9MNensCeoxNpPcQCmFpOL/oYJM=; b=Ulzdx/3zkLYBhCIXLDCB3IAMbe0FHGpUsNyY/BosEydFd5j+G8yMgXmY17JwvNBYGt 7m3v+dBkQDUOQSxRP+KbfKg2NazeMeFPNFKJp9icZKsVuqSt4mNdp8wZsiCOyTU1XLjf pTx6hE77O7JG51cvDVf1WITsVYvWZunVDRpifVhHobzwyo4y2zl8ETcPkc6dtN+UHJPh Ih3sdiO3ddxJclK9+KU1f/yjpT3dZSEucBd2luExtUNtIxMh1hXNH6ix7SJj/YnzOwcV e4ZkjDPw4ZYIATY4/6TkkQw8sOs8iVlvjZuAuMWtMdAtodh4/35oM28oaAoEc62VCMy4 y1rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716579031; x=1717183831; 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=dzHU3P7qRxjg2ho0r9MNensCeoxNpPcQCmFpOL/oYJM=; b=PV6zHif/uRqu2XwnoBMWQmff7A1Ilf+b3l0deaCpXQ4Pm+ZL1+vAFb7ilmJ37n+IL7 8UJuI+kEJE7YvKDET15e2Yy0jzY+Sy6mM7tQe3ShU1H89T7ESpO8lDFy/hKINjdxAE4J HNE5YQd8yXzydm8qh0eFfv7li7IupViKV9Oo4jOHjaXCtFm5e+Fig6U6nQp3Ov5ypoZH hNQrsui0qPy5pCIRl91ZHKDIYwGsW8fdtmD2+dh0l+0SQ7jW9vBqWIuJXxkgNiVLgk00 5BDKw/5D/wf4ZXY5xUJj/aa14FrGpkBBSqCbEASd7XLofyXpWECFkM4JVXuo4e+LQP44 4oaw== X-Forwarded-Encrypted: i=1; AJvYcCWp11Cw/58Rz5v8bmNjrD2S9apEhtC74GTxEacIOzfY3WbdHvfb/MDnuY98P+jbnLVzJ1YMTLKH6tVZ5ZEcIOgQ9lBZhD2UESvTtCGgx+LF9mhuSUIMf9IOOe7miITJpPVGx4HXjKj7bxFvWmeN/d27Oiivy2CuWL8Ew3g6uSYJSQ== X-Gm-Message-State: AOJu0Yx/yxdvV0WCDwhPeDBJc1wAO646U5woOsg+7hnVi/TkM5NuBpBD 7K3l6Z0+eF7oWYro01m6zbzUXaRxof45ExxzitfJ6wprkbvXIQG0E8nnjRvV6D9UjIVqapVAPdf nM6ug/k5L2jTbvQen3sz09UNdJ2Q= X-Received: by 2002:a17:902:ecc6:b0:1f3:4348:15ca with SMTP id d9443c01a7336-1f4486f294bmr43420585ad.25.1716579031155; Fri, 24 May 2024 12:30:31 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240524041032.1048094-1-andrii@kernel.org> <20240524103212.382d10aed85f2e843e86febb@linux-foundation.org> In-Reply-To: <20240524103212.382d10aed85f2e843e86febb@linux-foundation.org> From: Andrii Nakryiko Date: Fri, 24 May 2024 12:30:18 -0700 Message-ID: Subject: Re: [PATCH v2 0/9] ioctl()-based API to query VMAs from /proc//maps To: Andrew Morton Cc: Andrii Nakryiko , linux-fsdevel@vger.kernel.org, brauner@kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, gregkh@linuxfoundation.org, linux-mm@kvack.org, liam.howlett@oracle.com, surenb@google.com, rppt@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 24, 2024 at 10:32=E2=80=AFAM Andrew Morton wrote: > > On Thu, 23 May 2024 21:10:22 -0700 Andrii Nakryiko wr= ote: > > > Implement binary ioctl()-based interface to /proc//maps file > > Why an ioctl rather than a read() of (say) a sysfs file? This is effectively a request/response kind of API. User provides at least address and a set of flags (that determine what subset of VMAs are of interest), and optionally could provide buffer pointers for extra variable-length data (e.g., VMA name). I'm not sure how to achieve this with read() syscall. Kernel has already established an approach to support these input/output binary-based protocols and how to handle extensibility and backwards/forward compatibility. And so we are using that here as well. ioctl() is just an existing mechanism for passing a pointer to such binary request/response structure in the context of some process (also note that normally it will be a different process from the actual user process that is using this API, that's always the case for profiling, for example). As for the sysfs as a location for this file. It doesn't matter much to me where to open some file, but it has to be a per-PID file, because each process has its own set of VMAs. Applications often will be querying VMAs across many processes, depending on incoming data (in our cases, profiling stack trace address data). So this eliminates something like prctl(). Does sysfs have an existing per-process hierarchy of files or directories that would be a natural match here? As I mentioned, /proc/PID/maps does seem like a natural fit in this case, because it represents the set of VMAs of a specified process. And this new API is just an alternative (to text-based read() protocol) way of querying this set of VMAs.