Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp910285pxf; Thu, 8 Apr 2021 16:14:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlBZBahOFifpnEbI5Oi2KtkQ3RpxrK41vXUBIvt3XcFgowd0PI6UHVMtkbq9IKysN375A3 X-Received: by 2002:aa7:99cb:0:b029:245:1b7c:7982 with SMTP id v11-20020aa799cb0000b02902451b7c7982mr4042594pfi.23.1617923661321; Thu, 08 Apr 2021 16:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617923661; cv=none; d=google.com; s=arc-20160816; b=CGJsorGFUjk/p7qtM9/ESrrZaeliCw55eAJ6yoCm30PK1Zwcwl7LbKUjEALYKyO6J6 3QIy3cYDKk5dt2uugvL3T8FOeHe8ImaQfNn5JCwPU+PqRwzjdnZKFU2ZjjAyITUKEpvk HViR0sfWp2b/lSntmBNgPaCUx6gqCgaoCeJGOU1zXryhWKkYjug1+262PQScwUi9OV84 49VO+ua+5+hLhKjFrG7ITsWln204VZo0nyfFyo1lU0OM3zGuelJTUUcjqb9gFRuSCH9B 3dWpItNF5vHoCfuUut7lvlC1dFnKuPkdczFXevlNr1nijJObyIauWy1i8T7PIQqIxxMb lHVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+GHtEiz/NAbPics/brHj5J34LVzN3QbA/4ptALEXnDE=; b=pm/UhscP1BVHX8jhtKzsUY1hyeGMTwZWjaMh8SGpuLRm+DAsdEPG+yq6VwGnWv7a8u XjGNnf/KHdV1kXOpTrtwydIza02PFNclLiTT+AEh3x0Iv4pHxymVJ8xLhizLLd3V9Rit hIZ0RmkKRsrCt9PUiV7dbT0xj+6rPNdIveOYGgarXLoUd4Le27R7UDKFyNvoDcBRDE2B W2osKsjx08YbFIRf9uVgvUJ8vbZEOA+c9GPtGYIdvqgqoElx0ZQJjLFY99LG8qTaP95r tgT7oJhpOOeJSXQds7r1v4tqiKr2QGoolGhEAgLzaxMjwvukbiB07u3Tjh5TE2POnafI /yYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SmkVmZIH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si735213pgj.452.2021.04.08.16.14.07; Thu, 08 Apr 2021 16:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SmkVmZIH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232819AbhDHXNp (ORCPT + 99 others); Thu, 8 Apr 2021 19:13:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbhDHXNp (ORCPT ); Thu, 8 Apr 2021 19:13:45 -0400 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >