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 0356AC433FE for ; Mon, 21 Nov 2022 15:55:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 870EF6B0071; Mon, 21 Nov 2022 10:55:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FA1D6B0073; Mon, 21 Nov 2022 10:55:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69B988E0002; Mon, 21 Nov 2022 10:55:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 52C5C6B0071 for ; Mon, 21 Nov 2022 10:55:23 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1E2251A03CF for ; Mon, 21 Nov 2022 15:55:23 +0000 (UTC) X-FDA: 80157898926.16.F1D8E42 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 7BAD4C000A for ; Mon, 21 Nov 2022 15:55:22 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id x21so8302432qkj.0 for ; Mon, 21 Nov 2022 07:55:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tzcJ7m6RG0X4n6Tx+9V/SeCGzltFocNyCQlYUWsjGK8=; b=C/nzGG+7owDjyVyN+SsPMFO0p4QvEEOsbGuB+hy7vFO7NmqKQ7Ag6EDOTvdQVYCiv5 5BDrTlj7aU/BgAg/jw5QggCczdmqRZI6xQeIZEjgJDnlmxEZSx6fOsIdiZsOsMZ1uRQV Tp0ELT1Yjqirmv3IDOIU4wNC5CWRxGGnaln9+hztNTi48FM3zF1xVl1Bxn9AJYqr9/Bv PnladyNHyJCsv97Um/GbwVMkEUzGw764kMgwYFcoBBcd5Lv5TIdKUgZkpb1RWP7KU1KL 4QrtEhMmIKjOIGKU5mSmCtrtAZef2qO4KXCmahGm0XuB+qTNygRXSKtKkwA8+q14eXFD 0IZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tzcJ7m6RG0X4n6Tx+9V/SeCGzltFocNyCQlYUWsjGK8=; b=fcHX9INZhoORxpzZrNnx/s65XVWF94mKP75e5rkIN5zlTAa3Hy1620sovgyCBf3FyY mKkIJCoxHlK1qko2mtjij9nhqWyVPRezfaAEAKs513tsHc09LOmeXM64GoAIlDUa5t2K Z9dYhqjqGVRZAw5/KpLjCm6lAk/aU9IF6FUorPE1C5XT3OclGUfCa3kCKo3oGEJSP6qw yGsbmQg87ZgOqYUspSjeLqSFlWe8wtbmD/+F6HgBjQsSdVjzpE5r2N3LCW53E8fa3nvd qj0gHDWqLRblk9wXBgVaw3I9iU8WbixkBH/TX6HRljv6ajrWwBrpr9iEsBNYMz2gQ8T6 k3rQ== X-Gm-Message-State: ANoB5pnabAD4EEiZrTJ6rAOjSTc5Nt9G0Hg7vULnoONRNDzyulOTZ7g1 FfiTPIo3h0iDhh2OCLIk+qcOHQ== X-Google-Smtp-Source: AA0mqf6N9WcywTslUZQMKcSZLiGSID+mMqoKP7uYR/sGzf48BMoMHcdVdcmOHHIwBburlIfanSD8jg== X-Received: by 2002:a37:6816:0:b0:6ce:7d05:9f9e with SMTP id d22-20020a376816000000b006ce7d059f9emr3756703qkc.409.1669046121644; Mon, 21 Nov 2022 07:55:21 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:bc4]) by smtp.gmail.com with ESMTPSA id m14-20020ac85b0e000000b003a591194221sm7058090qtw.7.2022.11.21.07.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 07:55:21 -0800 (PST) Date: Mon, 21 Nov 2022 10:55:46 -0500 From: Johannes Weiner To: Brian Foster Cc: Nhat Pham , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/4] cachestat: implement cachestat syscall Message-ID: References: <20221115182901.2755368-1-nphamcs@gmail.com> <20221115182901.2755368-4-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669046122; a=rsa-sha256; cv=none; b=EWRznmwnZOxLBixAQnORDX1HYqrY1op13TxecU6lw2NoHeLW0mE7DtNltI0GgXTvhNEGtC qqLLHwDqjylaWTZIirIqOxrA5KLeetm5xP1MpCML6838j9md6xqjWhjCQZH7v/NOgrC5AI 2r6WwWf0CR0ZYTzZNLTcA1HW3lhsK3Y= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="C/nzGG+7"; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.172 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669046122; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tzcJ7m6RG0X4n6Tx+9V/SeCGzltFocNyCQlYUWsjGK8=; b=hXs8/By5vPaotGQsELgg1owrE1PUP6kXnDWUkAAcvq+gZ/lptejOHb6L3jZdGt67RseAS+ 5JueeOIaXlDU8jBNcIj9mbInAE+YR//Yfg1QMWThXJvT7rv6oQud6SPv2PCRNIIvRwaVtP PsH15gPxMJ28WhN+8YvtbdkpIS0qyvc= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7BAD4C000A Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="C/nzGG+7"; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.172 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspam-User: X-Stat-Signature: jaeuftkbt89kxsu3hu5yhqgmqrdu55pm X-HE-Tag: 1669046122-212274 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 Mon, Nov 21, 2022 at 09:45:49AM -0500, Brian Foster wrote: > On Tue, Nov 15, 2022 at 10:29:00AM -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 { > > unsigned long nr_cache; > > unsigned long nr_dirty; > > unsigned long nr_writeback; > > unsigned long nr_evicted; > > unsigned long nr_recently_evicted; > > }; > > > > int cachestat(unsigned int fd, off_t off, size_t len, > > struct cachestat *cstat); > > > > Do you have a strong use case for a user specified range vs. just > checking the entire file? If not, have you considered whether it might > be worth expanding statx() to include this data? That call is already > designed to include "extended" file status and avoids the need for a new > syscall. For example, the fields could be added individually with > multiple flags, or the entire struct tied to a new STATX_CACHE flag or > some such. Whole-file stats are only useful for data that is structured in directory trees. It doesn't work for structured files. For example, understanding (and subsequently advising/influencing) the readahead and dirty flushing in certain sections of a larger database file. Fadvise/madvise/sync_file_range etc. give the user the ability to influence cache behavior in sub-ranges, so it makes sense to also allow querying at that granularity. > > 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`. > > > > These values are returned in a cachestat struct, whose address is > > given by the `cstat` argument. > > > > The `off` argument must be a non-negative integers, If `off` + `len` > > >= `off`, the queried range is [`off`, `off` + `len`]. Otherwise, we > > will query in the range from `off` to the end of the file. > > > > (off + len < off) is an error condition on some (most?) other syscalls. > At least some calls (i.e. fadvise(), sync_file_range()) use len == 0 to > explicitly specify "to EOF." Good point, it would make sense to stick to that precedent.