From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A9EFC433ED for ; Thu, 8 Apr 2021 23:13:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D613661106 for ; Thu, 8 Apr 2021 23:13:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D613661106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5294E6B0036; Thu, 8 Apr 2021 19:13:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FFD06B006C; Thu, 8 Apr 2021 19:13:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A49E6B006E; Thu, 8 Apr 2021 19:13:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id 1E1EE6B0036 for ; Thu, 8 Apr 2021 19:13:37 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BF84B18014CB1 for ; Thu, 8 Apr 2021 23:13:36 +0000 (UTC) X-FDA: 78010753632.09.EBA4119 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf22.hostedemail.com (Postfix) with ESMTP id CA163C0007CB for ; Thu, 8 Apr 2021 23:13:33 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 53565610E6; Thu, 8 Apr 2021 23:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617923613; bh=mpb93QphQtuxs5UnMlRM4pkZBibPsFpxB+KeCxq8Bns=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SmkVmZIHE2AzWbDXTTV8ESq9Z0tJYGNFMGAPNiOGJdTjrTTli6v29PSWLk3I86M5p JYFfHf5U7r9CljP54pZ0BOGQvm10ZPTGabdvEC7Q4Wu57Wl1I3ZxIOhmeAaTVgbfNR o7UYNeCzclQgVzOWuKG7kGUsMcrOuNdJxEIe0+73QHSIDmMzZ1D7n+5N7cShz7p2ia bmvNo7aEDdV9M/U2kEIZs90y5DTcg0LpIN5oWKy4xbChHttOWce+6Aq4xPM99jVkrB 9mBLVH/ZdSjloHt+wZUVUK35uHgZjmlfH4FHABfG/x5Qk+cvtSml0rD0uT142+YWP9 e8FfPB9ffhOgw== Date: Thu, 8 Apr 2021 16:13:32 -0700 From: "Darrick J. Wong" To: Daniel Xu Cc: bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, jolsa@kernel.org, hannes@cmpxchg.org, yhs@fb.com Subject: Re: [RFC bpf-next 0/1] bpf: Add page cache iterator Message-ID: <20210408231332.GH22094@magnolia> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: CA163C0007CB X-Stat-Signature: xgrto3ceo9175ujko3xahx1srpg635op X-Rspamd-Server: rspam02 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617923613-659299 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: On Wed, Apr 07, 2021 at 02:46:10PM -0700, Daniel Xu wrote: > There currently does not exist a way to answer the question: "What is in > the page cache?". There are various heuristics and counters but nothing > that can tell you anything like: > > * 3M from /home/dxu/foo.txt > * 5K from ... 5K? That's an extraordinary Weird Machine(tm). > * etc. > > The answer to the question is particularly useful in the stacked > container world. Stacked containers implies multiple containers are run > on the same physical host. Memory is precious resource on some (if not > most) of these systems. On these systems, it's useful to know how much > duplicated data is in the page cache. Once you know the answer, you can > do something about it. One possible technique would be bind mount common > items from the root host into each container. Um, are you describing a system that uses BPF to deduplicating the page cache by using bind mounts? Can the containers scribble on these files and thereby mess up the other containers? What happens if the container wants to update itself and clobbers the root host's copy instead? How do you deal with a software update process failing because the root host fights back against the container trying to change its files? Also, I thought we weren't supposed to share resources across security boundaries anymore? --D > > NOTES: > > * This patch compiles and (maybe) works -- totally not fully tested > or in a final state > > * I'm sending this early RFC to get comments on the general approach. > I chatted w/ Johannes a little bit and it seems like the best way to > do this is through superblock -> inode -> address_space iteration > rather than going from numa node -> LRU iteration > > * I'll most likely add a page_hash() helper (or something) that hashes > a page so that userspace can more easily tell which pages are > duplicate > > Daniel Xu (1): > bpf: Introduce iter_pagecache > > kernel/bpf/Makefile | 2 +- > kernel/bpf/pagecache_iter.c | 293 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 294 insertions(+), 1 deletion(-) > create mode 100644 kernel/bpf/pagecache_iter.c > > -- > 2.26.3 >