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 02D99C05027 for ; Sun, 19 Feb 2023 12:21:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 537D66B0072; Sun, 19 Feb 2023 07:21:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E7A06B0073; Sun, 19 Feb 2023 07:21:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AF366B0074; Sun, 19 Feb 2023 07:21:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2AFB96B0072 for ; Sun, 19 Feb 2023 07:21:41 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AF9BDA0514 for ; Sun, 19 Feb 2023 12:21:40 +0000 (UTC) X-FDA: 80483952360.03.5E5715B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 1294912000B for ; Sun, 19 Feb 2023 12:21:38 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CpsPmT7X; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676809299; 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=ZJseHQTnv1iITs62Fnj7SadMOAE+fjrqhaVwjdlj74M=; b=Jspej/a0yfvtmaUnxPHCTtCgUqNrnGfuvlMh+jAc0jO8Gn88c6evxWI0HCqGOTpxjPH3sl Nk3OS+w0YQ3mmzly+1SbfBnCc/KsrQC3Sbz87w/qNT4ACKTGNYyuFvc5GZLORXGKIvThoZ 4wiv+oD1sLaDHIdbvVx6/JkK0mEIRm4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CpsPmT7X; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676809299; a=rsa-sha256; cv=none; b=YbcXHUlH/RSFQYpqIkZmq0EcDFQbTa565oj7mfeQUS87rDSQT8YYGIxUpvLJGHJVBKG+WN eJnIR9wwUsSTnsDyf3Bbxbq0doo/g5FypXyEXqi0wZk+FYHHvw6q7Tdy8BjR9tgharrCTF /5iw051vrHG2ohOqVBJf7TIa1kkxjm4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZJseHQTnv1iITs62Fnj7SadMOAE+fjrqhaVwjdlj74M=; b=CpsPmT7XFm6onB5jMft1I36dAA ior0H9BAS84l6dnGQGcqxWqtyCS8r5oJxjwgkM0oHAySiuIpiZVL4oi0f3EWMx7Il3aBaQ/N7eKb1 BoKVXYCwXAv14xAqoi0GNdDKodhbVtsVc/Pj3CvAPU3gtlGAJYR+XA8GK0SrIKeibgJsx7u2lfZMw A6me6OIOUj3JdffSzxqRCI23lsoPeYZ7F8ZAHJ8qYZTds4A+IVGaUIiwqkbbDPD9XuN3L/ImUR+mH lrqcg8JjqFUp4L66ThpfT4S561/oRr96JjsI+VRTQwjxDan3RKQEk1mYDEGaV4rKEECG9q7PQQiLw 6/apbMwg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTihC-00Aug2-7r; Sun, 19 Feb 2023 12:21:34 +0000 Date: Sun, 19 Feb 2023 12:21:34 +0000 From: Matthew Wilcox To: Nhat Pham Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bfoster@redhat.com, arnd@arndb.de, linux-api@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v10 2/3] cachestat: implement cachestat syscall Message-ID: References: <20230219073318.366189-1-nphamcs@gmail.com> <20230219073318.366189-3-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230219073318.366189-3-nphamcs@gmail.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1294912000B X-Stat-Signature: 146g47mek7s9aqbjxnrzx3hc7nr87pmc X-Rspam-User: X-HE-Tag: 1676809298-802592 X-HE-Meta: U2FsdGVkX1+OggybmgxNyHwegcBvh+3yxRzwD/ba6tVQ6xHBbbh8x48XbiblZbCFahY7FXxsq+tH0FSwqJy8gVFPUIdUnylES4lPXdWI/Ofxe70nukdFQUAxgV5pQ1JRclkdZ4T0EwbY5+g8Paqjv/j4NlbBKuSbwgKWuKmWxgVE/VmGWuL6sUglRZvmemL7kKaNBan5CV0cCJJTmiXn2o3znVSZEcS6wTk2vPg3CwCYK/6/hbIN1PcE0LAgI2E0TvQ71Ej2kQX2kWlZrLymK+R/tAormPOpC2d8vc8WTXc6iH27AyqXzz2chtP9Yg+O69336ViqyS8FWAODAjE6A68mvKuEyoyJmlVv8zFvOBBvjHXkxtQZ5Ng3rWJJCVObV1h1Bm9UHuQv8TAGUiIXBzAb5MDJMksO4zAqsn+CtT17/vGlkqrwHNeOpxbg3gkuRhV3FJTJKVos5sTi2U9//6C9Yj/2M7hG7xeugDwIi66qzfMET7r26mQlBtKXWd2ZYYmJ8iLmPP49PjGdH3kseCS6y2tVPKcNGF2LPzB0819X2X+pKbiebIo+3uHtvPElYz699xgvadlH1CFTdXkSVD9GJKIKc0PiaaAlTcmFMgJN2i4TLUDWDdAl9T8d5VwynJY97jl4YGI9n9gOSRyaJxiUvTt5/KaTXngvW+ZG4XDlq2DZQ1rDh7XoPmSsuUK/TkbXg8w/hXr5NArxtGtdJ9hofG/bITR5nRVxr81DkkAy8fs+fEq4S+5ll6B13FWSfx5a80+DXgV7ZmjUM2GeV+hE/LepqjYXb/VT/eaM3WBpmQ5J/AMowz4XrBLv49ceYGujC8ahdsNIK163bb5ISlA4lnfnflR+EZWlV+7T0uJnboQFB8cLS37z0Gv+3YATCCaxyzm7+wUrqJYeyq+vLVjJCHor0t7PU6jQEXclh1PHftRaDcINRmoptZbXHZuL+cUAAt+JS9MDlkFSll9 ZzLtFk34 Cw4bj8kN7sXUqXbY0nNwhqvtq4USYa1KIslENcV6DL7GRi8bZAJoZAobDXa0pOySrAl0W/bRHzw1XX/Hm8RJpCEK6wsWxT7cHmuiM9ZCmc2qkwuHZDXjxc4L/8r4TIyU3tW0Jrl0kioKDPNoAon5x0PwLUQ== 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 Sat, Feb 18, 2023 at 11:33:17PM -0800, Nhat Pham wrote: > diff --git a/include/linux/fs.h b/include/linux/fs.h > index e654435f1651..83300f1491e7 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -75,6 +75,7 @@ struct fs_context; > struct fs_parameter_spec; > struct fileattr; > struct iomap_ops; > +struct cachestat; > > extern void __init inode_init(void); > extern void __init inode_init_early(void); > @@ -830,6 +831,8 @@ void filemap_invalidate_lock_two(struct address_space *mapping1, > struct address_space *mapping2); > void filemap_invalidate_unlock_two(struct address_space *mapping1, > struct address_space *mapping2); > +void filemap_cachestat(struct address_space *mapping, pgoff_t first_index, > + pgoff_t last_index, struct cachestat *cs); 1. Why is this in fs.h instead of pagemap.h? 2. Why is it not static, since it's only used by the syscall, which is also in filemap.c? > @@ -55,6 +56,9 @@ > #include /* for try_to_free_buffers */ > > #include > +#include I think this hunk should be: -#include +#include (linux/mman.h includes uapi/linux/mman.h, which includes asm/mman.h) > +/** > + * 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. > + */ Do we care that this isn't going to work for hugetlbfs? > + rcu_read_lock(); > + xas_for_each(&xas, folio, last_index) { > + unsigned long nr_pages; > + pgoff_t folio_first_index, folio_last_index; > + > + if (xas_retry(&xas, folio)) > + continue; > + > + nr_pages = folio_nr_pages(folio); > + folio_first_index = folio_pgoff(folio); > + folio_last_index = folio_first_index + nr_pages - 1; > + > + /* Folios might straddle the range boundaries, only count covered subpages */ s/subpages/pages/