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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 290CCC4332F for ; Fri, 16 Dec 2022 21:48:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C7C98E0003; Fri, 16 Dec 2022 16:48:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 650858E0001; Fri, 16 Dec 2022 16:48:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F2168E0003; Fri, 16 Dec 2022 16:48:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 378728E0001 for ; Fri, 16 Dec 2022 16:48:21 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 061861C6B28 for ; Fri, 16 Dec 2022 21:48:20 +0000 (UTC) X-FDA: 80249508360.26.B506777 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 3DAED140009 for ; Fri, 16 Dec 2022 21:48:17 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=oOPiGGCq; spf=pass (imf09.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671227297; a=rsa-sha256; cv=none; b=2FM0gBpUlSL5HyiyWmoIisu7HMpjMZ0SujMYjuwEtnbNnDamIMIbDIneLGUQNqS25ayKxb 3SSd0+YFekpKc+qpNtK+zj4HLtbLmquktUh+GMpFrTUisnz9BikenrvVxwJM+z/RSw+JS8 O6Tj6fVv7TLkpMellE4ZZ6du25ucW8I= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=oOPiGGCq; spf=pass (imf09.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671227297; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bNq2iOZ42aCGeHQPey/fV6ArzNA8wia7UmdrvN9VR1E=; b=yz4SjnA7IbsApgDZmKZGtJ5JngyZ1+alNJIRPe+fqaRepKmN46n3u9lzgILpot6kZbWpaB aMBOJJ0tmnOpjcY7CWJ+8WkT18Tb8BOZ1CFa7KgtDmfSBmydzdv3mHpguKjWfNuybEBIav 3FwS8MtYo8NWtMrhsiwKUsbcNqzNWb0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E0FF56225B; Fri, 16 Dec 2022 21:48:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AF64C433EF; Fri, 16 Dec 2022 21:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1671227295; bh=4si32cFtPatYVk2GoZlXa5/Q/bdn4eAB7DegYBPJzu0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oOPiGGCq+TN077B/wlGYAoiaPw9ZU55dRNLHSilQ7XKti0vvwP0OmKix+V72nxOif cMe0GLbSDHG2tied26vv/ez4F/QxkrBAveOGrlDXfUXLyoyu0JCJ3jzFJkRFjw200O oE/nBDaHJAS66i0W6kZSEbcOIHabT9AwAMPoPIsY= Date: Fri, 16 Dec 2022 13:48:14 -0800 From: Andrew Morton To: Nhat Pham Cc: hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bfoster@redhat.com, willy@infradead.org, kernel-team@meta.com Subject: Re: [PATCH v4 3/4] cachestat: implement cachestat syscall Message-Id: <20221216134814.61c8d5119ceb4179c68e1cd7@linux-foundation.org> In-Reply-To: <20221216192149.3902877-4-nphamcs@gmail.com> References: <20221216192149.3902877-1-nphamcs@gmail.com> <20221216192149.3902877-4-nphamcs@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3DAED140009 X-Stat-Signature: 5gqspfputtntkhwgko9d7wpzf4bbayfm X-HE-Tag: 1671227297-693288 X-HE-Meta: U2FsdGVkX1/gc62PKa6zhiTvaE9JEqc9ag5tz7OZvsqOHF+VirYLFfcsIGTQSAaRqBMScFpDgW65uAsrbezgMA8tbV9PQIkBo4uSaXLrAOsLKyDXQvVRjnS8AAzndGgF7mKf6k6F+5CSjA8iXGzG71v/4y5mSNwZSJC1eY1rNCnkDcMXaEsRcDuDBL9MgsFn3wi0CXkz3FhzqkxvUYLcAesuZce32ZzBZxDty4F3Lng2Qod9amURzIsd3nrripo8M5e66LuWa16USYc2gmvK0CTQVcX0RpB3nhugXaZWejKtOBZCbTRBEa1dhPdwHTaFucyuotJsiScMWnFPMOw8hzMjGxBpF1kfLCw5eif/3ICDJRcN4xvWM/jeKUFIzzQmfgsL0YbwlASLZLBkvPH1yly9HnPNWa0MH5+E6WsKHxh1G4RjYQ9K//EhVAiBHPyv2R7ZIMqLGqmUx9aotiNq4EuttLDKy90bvlvqrMHEK48B+TuFtU8f2e+Y7KMvvQBDbA2FFhbn7FWCFPVV/Ss/NMtJ5bdiHNWaqgq5R7kk90k+X2DSt33QSlmWVSSY/LBkPjCHQtYL5h2Uebfu7lrSO/NGHO/Y/kZ2mK1a/Hrm36jg68hND7OcfM1l4QlEy4WhrDUQLkV7lzG2jfvKX5uFyTKO6ICcu6jYyYNTMuwSRPgElkbUUxVG+foxHtJM0yFm/cl3GSlOb/GD6/Q3acxy149g8cOj4aP+5A5uHMD/dWFia58w8L970G0/V6AUweyI5G5ujsJ93BQK8A2eknT/QRetcTDo9d1y1vZowO8AuXx6n4BKHZEEFPsyJjw/fZWMVdtP6kUB+p/YzXX8XIw6sJOglqyLUZ+5ldcUEsB3ScAHKyayewf4V8AdUCSs5KFvAruNViUyvA2Gb5RCx/mwh1ilJPgrTWRk3/+nqutUXYFmxGHNtArgOvgSNQ0ol4UI6R54fq01Yot8qUFtHAZ kwMCGkUW pkAjl8doVCjzkEkqGf/lwz5AHluvElDFqMCspaDM+QKr7u8Vsve+4KQg1oYzVWKUzfchU 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 Fri, 16 Dec 2022 11:21:48 -0800 Nhat Pham wrote: > Implement a new syscall that queries cache state of a file and > summarizes the number of cached pages, number of dirty pages, number of > pages marked for writeback, number of (recently) evicted pages, etc. in > a given range. > > NAME > cachestat - query the page cache status of a file. > > SYNOPSIS > #include > > struct cachestat { > __u64 nr_cache; > __u64 nr_dirty; > __u64 nr_writeback; > __u64 nr_evicted; > __u64 nr_recently_evicted; > }; > > int cachestat(unsigned int fd, off_t off, size_t len, > size_t cstat_size, struct cachestat *cstat, > unsigned int flags); > > DESCRIPTION > cachestat() queries the number of cached pages, number of dirty > pages, number of pages marked for writeback, number of (recently) > evicted pages, in the bytes range given by `off` and `len`. I suggest this be spelled out better: "number of evicted and number or recently evicted pages". I suggest this clearly tell readers what an "evicted" page is - they aren't kernel programmers! What is the benefit of the "recently evicted" pages? "recently" seems very vague - what use is this to anyone? > These values are returned in a cachestat struct, whose address is > given by the `cstat` argument. > > The `off` and `len` arguments must be non-negative integers. If > `len` > 0, the queried range is [`off`, `off` + `len`]. If `len` == > 0, we will query in the range from `off` to the end of the file. > > `cstat_size` allows users to obtain partial results. The syscall > will copy the first `csstat_size` bytes to the specified userspace > memory. `cstat_size` must be a non-negative value that is no larger > than the current size of the cachestat struct. > > The `flags` argument is unused for now, but is included for future > extensibility. User should pass 0 (i.e no flag specified). Why is `flags' here? We could add an unused flags arg to any syscall, but we don't. What's the plan? Are there security implications? If I know that some process has a file open, I can use cachestat() to infer which parts of that file they're looking at (like mincore(), I guess). And I can infer which parts they're writing to, unlike mincore(). I suggest the [patch 1/4] fixup be separated from this series.