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 C6279C61DA4 for ; Sun, 5 Mar 2023 10:32:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38B2D6B0071; Sun, 5 Mar 2023 05:32:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3459C6B0073; Sun, 5 Mar 2023 05:32:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2026B6B0074; Sun, 5 Mar 2023 05:32:22 -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 0E0E56B0071 for ; Sun, 5 Mar 2023 05:32:22 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D3DA4AAB95 for ; Sun, 5 Mar 2023 10:32:21 +0000 (UTC) X-FDA: 80534480082.23.191D367 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf22.hostedemail.com (Postfix) with ESMTP id 1FE6FC000E for ; Sun, 5 Mar 2023 10:32:19 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RpxZlBFY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678012340; 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=HyWuCklZqeWHeAAvpRzvccua2zn3XmympaWs29aKNGQ=; b=XlA8KwiQApcp2vFN4FS5OvWVY8a5yK1FmQYw8mKjyZkSFYlyrfT4u1KHT1KkLVZxlbQPMR vTZYlwLdzTYVu9bEArImODHSGxKZ55B4xax2Xrbnq/U2DcynjKAtDCpSE8yBMZ1Qry9MSj UEAvK0pTDdHGS03RxaxOWGrL5+myxzM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RpxZlBFY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678012340; a=rsa-sha256; cv=none; b=Zk9Mc/xKqldi0VBN26wozyo8brUaeOoHJilaQ4QLPtvVdLMZ8Q6cYx4jvXkhhyIGTuJ+il JIWPNbcjMs5HhG6vahfzMLxYUstm+150kZ/PW3piPI9A3xZ6hGDLOWJx+qp4Idtz2ggORw itfcF1fK2SXzFfLgi3cl1NlbI78+ddM= Received: by mail-qk1-f178.google.com with SMTP id h17so2139614qka.11 for ; Sun, 05 Mar 2023 02:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678012339; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HyWuCklZqeWHeAAvpRzvccua2zn3XmympaWs29aKNGQ=; b=RpxZlBFYj7ktpGFKb2LRVRIYWz3V9QosLteYaUkRcCR0QYNaGXzpYJ+UQ4bhGCZ87B aDBzGSpC+ANhYSGo/P7znGRLP+rYWE+n6PmbH9kUyhxZ12tRVMSA/UWn8pl0BnUctyvn 7BRrx6rA2vTUlt5RkOyQ1PORtOE/O5cxF46RzmExF5u9X5Az7S7tovxjgUhNEUa1231q vj4I6uYo/Ar8gRN8usfsqgymfHEhi024MInhPTCJGSgVGBtwVoMKkkZ0WK/cXhYaaCVs buEvQRTFADyYBtFYlziJvx8jgvHSlTJodB2o0/KtyW8r4RzIm+j83bLf9zkDN3ltvhV0 A6TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678012339; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HyWuCklZqeWHeAAvpRzvccua2zn3XmympaWs29aKNGQ=; b=FY0Jh8QzuA1Hyl74a7PxzbRIaPl3xoJ5WKlmJr/DDPXoM4E9LCcAFyqoZ53tZvZ9Az 6zhUdZteILkfcgERT6YThh3Prhn7LL+K0e9GbLKyG8LiCCjKt/st0I9P0nY41h5UavqB JVZjJcqjXGGEq4jJTQg8ZknxpXTSGTuPQrzLQ5hHwY8IVEcG6IcdeB75LYRjuP6lRr7y nDeJt2cKIMg6p+YJJGZJ3X1mwD1kR2nObhwqC7Xhhj4CVzIAGCFyPd7XXORguQPcBHC0 i6f3OE2lt7a0jHF/iUbwVdUQaaK965m0FLyDhwhx7BMq75RQEVmjH1Nt3T8SLfxNGRIk HA9A== X-Gm-Message-State: AO0yUKXojFFPQLoQF2umo5QdBD6TehxshyzBy54/ToA3z9bUgWcyA61r 47A6DbvIY/xbKQxqvJRe7FcIhs2TGROrM04x9iE= X-Google-Smtp-Source: AK7set+dbxiU9HKVUjdXSTLsWZhS1FzVFcfvLw7VRJXoIt9CBrIZUYxSyYPJNZN/bfB76VozAT8xvEIg2wXXSfhRKXg= X-Received: by 2002:a37:64c1:0:b0:71f:b89c:5ac7 with SMTP id y184-20020a3764c1000000b0071fb89c5ac7mr1479076qkb.8.1678012339264; Sun, 05 Mar 2023 02:32:19 -0800 (PST) MIME-Version: 1.0 References: <20230219073318.366189-1-nphamcs@gmail.com> <20230219073318.366189-3-nphamcs@gmail.com> In-Reply-To: From: Nhat Pham Date: Sun, 5 Mar 2023 02:32:08 -0800 Message-ID: Subject: Re: [PATCH v10 2/3] cachestat: implement cachestat syscall To: Matthew Wilcox 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1FE6FC000E X-Stat-Signature: rb9z3n4wbxubrbzis1now6nwx7h6sk6e X-HE-Tag: 1678012339-15339 X-HE-Meta: U2FsdGVkX1/ZxUBm0iVgpbVAtqOl5a0fdBjrV7090ohlydvaeMQyK2M5DtEi76JwH9PSROgli5vwP2iQyNNvuIepDEXSWjZY8YSRTblaZ4JLSTNKoDfwRfF6tiQS6J8aWHS6ymNMfQf0cvAMoUVaiP8HE29uV/2JAZXVPjLyw/VTjR6w25m617yAwryUOG74zkqD1fC6TZ2/oucixBXn12ZjshsZ9IhncBWs7YbOvBLFLyvsWu1DdbmKd5qIb5WIKC8Ltos9ELWz8jK6J73hiLtSOmXwHByvLiquWREtPK4XmIgixREuGxEcXhdo+DW6avnuo/LN0+OuIv5eXqC2aYeFgoOyaL/88eXvNB1MsU+RHkPF1iUwJ8jCtOSdFR4+9teDZJR5UTTx81rELQwYz0J2p5qoCgZHYecdp9HuxwZmj3QfO/1Ra1QHkpf5HNeuRZPsgZSWRYSdS8PtE5EqpUGu2N+wzDedYj26SijhJg27Qd9MSauUDnhYz6k1W5ARbvxxBJon66fbmhSNoG6YsyX8lAoOPuFkWp/NAsG3Jim0eGbBJnHdsosTenLTyEyHEF4keaRIq1/wk2ktUzTHmauV/NYRhFzpt0+WWvNyrXgOE08en4UzY+VP2+mWx0QkTedrmqn8984MSKEmCnHy+NmXIhFTSwY+y9EtPbdH3N3eihPF5VyJFt1WTHasF3X7IzICexpWKEdhMg9L0Xb9PD8PR8gva1ceYda0u7Mj74IJmGovYi9twMqgcp7UIxrsWJ77/lMtzVyFt7XZzDQz2xlVBDxq8UqrfloyneTOG5LRtNySwZQITsdkn3KJekUkYZLs4/cufNFqCLO3XW+9OWAdFpYGer8uZzZeeoYspWMgdM7uElLSwnzVRCGPfwGLFHKTl6pOy07TnS00+9tbBCzbgnhbwEaZhSc5JBvC2ejfulaOi19TWDprrDZUAHOR1BkWPlIOB4AEglW1Bum cDK2XfER 3hxxvi4MU1m/vayYTuD9rpWSuq1jBytD07Gp9Pq9p951PrxMPUPuF989DSA54oiBt+UsNsKVp4dEvK5Qci4byaRs/IF/ihBKKAkKJB5cvazlMK1acdOvsKMr/I1WVQf7FuJOOh8dJGhhymtumo8OQfW366/QJWHjqFFOCh2J2MNg3n/gfYw+LTulO2rUDM7FlwnfBUC0fcykc0fPhsQ2MsfUMwjZGN9brrZnaeg4qEgUjWv6oGvYTnwTtq+BTZstASYJyN5fDqtKFyRoJOLbc6QhXJ7jK5FWVUvysM7bjTVikiW7PMWFUyucRyo2FV0klk0bF2RQxMnBC+lRyXdo9ajXQY7+YFVdEgl4pUeebONcl4j0Rfkb2LlMj2g== 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 Sun, Feb 19, 2023 at 4:21=E2=80=AFAM Matthew Wilcox wrote: > > 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_spa= ce *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_in= dex, > > + 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? Actually, I think I can remove its occurrence in another header file altogether. I think it was an artifact from a past iteration, which has filemap_cachestat in filemap.c but the syscall in its own file (cachestat.c). And you're right - we only have one use case for it now (for the syscall). I'll make it static. > > > @@ -55,6 +56,9 @@ > > #include /* for try_to_free_buffers */ > > > > #include > > +#include > > I think this hunk should be: > > -#include > +#include Will be fixed in the next version - thanks for letting me know! > > (linux/mman.h includes uapi/linux/mman.h, which includes asm/mman.h) > > > +/** > > + * filemap_cachestat() - compute the page cache statistics of a mappin= g > > + * @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 =3D folio_nr_pages(folio); > > + folio_first_index =3D folio_pgoff(folio); > > + folio_last_index =3D folio_first_index + nr_pages - 1; > > + > > + /* Folios might straddle the range boundaries, only count= covered subpages */ > > s/subpages/pages/ Yeah that comment is incorrect/confusing with the pages terminology. It'll be fixed!