linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: hannes@cmpxchg.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, bfoster@redhat.com,
	willy@infradead.org
Subject: Re: [PATCH v5 2/3] cachestat: implement cachestat syscall
Date: Thu, 12 Jan 2023 07:53:25 +0800	[thread overview]
Message-ID: <20230111235325.447-1-hdanton@sina.com> (raw)
In-Reply-To: <20230104231127.2634648-3-nphamcs@gmail.com>

On 4 Jan 2023 15:11:26 -0800 Nhat Pham <nphamcs@gmail.com>
> 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.

Feel free to add why. Do copy-and-paste if it is in the cover letter.
> 
> +/**
> + * filemap_cachestat() - compute the page cache statistics of a mapping
> + * @mapping:	The mapping to compute the statistics for.
> + * @first_index:	The starting page cache index.
> + * @last_index:	The final page index (inclusive).
> + * @cs:	the cachestat struct to write the result to.
> + *
> + * This will query the page cache statistics of a mapping in the
> + * page range of [first_index, last_index] (inclusive). The statistics
> + * queried include: number of dirty pages, number of pages marked for
> + * writeback, and the number of (recently) evicted pages.
> + */
> +void filemap_cachestat(struct address_space *mapping, pgoff_t first_index,
> +		pgoff_t last_index, struct cachestat *cs)
> +{
> +	XA_STATE(xas, &mapping->i_pages, first_index);
> +	struct folio *folio;
> +
> +	rcu_read_lock();
> +	xas_for_each(&xas, folio, last_index) {

It does not make sense to take more than two ticks to walk the xarray
with rcu read lock held.

Add stats to mapping instead if CONFIG_CACHESTAT_SYSCALL is enabled, in
case of difficulty handling rcu read lock.


  parent reply	other threads:[~2023-01-11 23:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 23:11 [PATCH v5 0/3] cachestat: a new syscall for page cache state of files Nhat Pham
2023-01-04 23:11 ` [PATCH v5 1/3] workingset: refactor LRU refault to expose refault recency check Nhat Pham
2023-01-04 23:11 ` [PATCH v5 2/3] cachestat: implement cachestat syscall Nhat Pham
2023-01-10 14:22   ` Brian Foster
2023-01-10 21:16     ` Nhat Pham
2023-01-11 12:53       ` Brian Foster
2023-01-11 20:39         ` Nhat Pham
2023-01-11 21:00           ` Brian Foster
2023-01-11 23:53   ` Hillf Danton [this message]
2023-01-13  9:35   ` Geert Uytterhoeven
2023-01-04 23:11 ` [PATCH v5 3/3] selftests: Add selftests for cachestat Nhat Pham
2023-01-04 23:21 ` [PATCH v5 0/3] cachestat: a new syscall for page cache state of files Nhat Pham
  -- strict thread matches above, loose matches on Subject: below --
2023-01-04 23:10 Nhat Pham
2023-01-04 23:10 ` [PATCH v5 2/3] cachestat: implement cachestat syscall Nhat Pham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230111235325.447-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=bfoster@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox