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 70D0CC678D4 for ; Fri, 3 Mar 2023 07:03:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A727B6B0072; Fri, 3 Mar 2023 02:03:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A21516B0073; Fri, 3 Mar 2023 02:03:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 910C56B0074; Fri, 3 Mar 2023 02:03:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7ECB56B0072 for ; Fri, 3 Mar 2023 02:03:46 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 50397C056D for ; Fri, 3 Mar 2023 07:03:46 +0000 (UTC) X-FDA: 80526696852.06.6322768 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id ECD91120012 for ; Fri, 3 Mar 2023 07:03:43 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BEh2bMP9; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677827024; 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=/5WuhsRDIv/UuTU95tT5UESTyEJuE6jSQoLAmCreiRM=; b=nVM7hNY22q2GhfkEaf4EZ5M+gwP3aOsJ/OXSwWCjkRXxrM1ycRjQEVtCt6AzY36fu3aa5D udBBGwhd/yvD9Q/k7BDAaMhZB75ZJKMWAoNLNoVlVWR8qlq4vorIpn05boaw7chb9V6Cbd ciJZoObp1ie5EjzwrfqOi1TMbJpYaoQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BEh2bMP9; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677827024; a=rsa-sha256; cv=none; b=2GuOleKijJLj9da+GXYIgLHayF7xsGLdwo0C893SF8vHW6YJHMr/DjDTgbfc/qekWINlFD CC28WCj3sDEkfiVHp1ge/0nDMdTcO77MXqvlebDKIwrYOeT9/4iatZEvnQnDyT+6CDMJG4 NDokknMMwnPp9Mn897UDYztY1+KI9WA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=/5WuhsRDIv/UuTU95tT5UESTyEJuE6jSQoLAmCreiRM=; b=BEh2bMP9VZ5HvOBAZKQFo9TxZl GWB9buvFTr/SNNnBAYV5RKgjZUPt1RlmR1MnmxsLqcd7NksUtXxSKH3pH0djkohdm4Nhj5mT2qjzL YIqPMoUSQrXvO9Znoz1O6Oc4Wb6jTmJHwJ/C3sDudvVYBlirKrQQ1Fo/UuPqhz+hm1X2yM/lOTrd4 tXyVoFdh7Onnnc20CeFdN6H0BFicfgPa7/l4PMVXAeES3jEH2AObQeLWgf/hayxx+GGUQZiMPBM2m h1COHu5tOheOcup5Ox0q8wQiQE3iS2Dlu7o4LzTm7+vrmdLcM2d07Y+qVymAu2CZ8bR+yuyE0teL3 4pMh4Ymw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXzS4-002wvW-7l; Fri, 03 Mar 2023 07:03:36 +0000 Date: Fri, 3 Mar 2023 07:03:36 +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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ECD91120012 X-Stat-Signature: p96qgoamp8bct1o6skkarga8nqzw8xz9 X-HE-Tag: 1677827023-4762 X-HE-Meta: U2FsdGVkX197tQOKceAOwUECZtawkve5C49+Dn1hVYLABskMFnBzjP71grrR5sDDFWpGhPfFI8vgMOJ9EafrmDkUWcAas3s/dhA3mPoozbFl1nnu/0hEbi9sxBuOkAfxp9Ys7usUKp776zZVdNLQzUpNdYun+SWTboxfTwLLTBJ4KlG2Mm2blzPqd8Cfx9Vtn0mj4XNYXgQHejODA4RRGQ025otZhnkMh/nsdcndeZvzqNxYYpm+14YmwowWTK6yMOl13eTK7461HNkXooKt+PXW9+hso0MtmTf0RgtXoP/osN9PvTGpgpkqWOdQKV68ICc2K6WHEyqSCjG7ESIYyNykxOFy1LKTShjBmN8mHGimlWNJ6ziqhzk2YAWjZJ1q/AAiCJQxhs7xOhzKVbPV2tpd9qV8m96rNWgZteQWNKlBW/6OpXe7Z0R9NGDjKfHZhrGmOOipNq04T562ZjN3xnQMHi8yI7noRTH1mvQi7sf7DZHZs9aIfaFjT9Tes5ng8bFoidZgufC9MZV1E7b18XH83etzSpGfIPYmgkJ+3LlnoIBx6BCd8CHg1NgOc6pC3jpGXhT2u9/J69MNp9hPE2Yr8m92dtZUhzmNxrTEjvRoxSt4HEay3l0/c7Bk4X31rjIT/OoqdH+wJAdG09iL7iaK3TluJqECrNTN/MsBVFD5n1BO17izl4lWDbfuTe4e53TpAJZgNDqJTRlWjFvRgqdG7T5qLGki9dR0BgCvoYutM8RW3VgllEVDYD3wDoVdYoFDcDgi9mKbIA88J/wvxc1smQDipVNHbG3DOPDNVQUoYru8VtbNhztyCtkPvHYPXCLqe1WICJcRuAL0xudKHIjYeNZ+q1tzUw8pIAolTSfPtjtOy4ZeBnGShhjMsiAAYtu/YYO+Fs1wcuw1QRwS2E7aJKwFtP6GHBVTMVzOX5n7AjwS4c7OUT5cSlb75GtYuARLeu3TW1t7QBGyFI/ DdPqBYIn DVbKijT12yX36vd4VPh0R9+E/Zlbv2T06sO8Is5YG91q4ELRJrY2V1FRvQhiYOP/44JCVWYV225Z3an4sgEI3aWfhva/4pX+Gn4/gtZh4EeCoKPqq8QhAfC6qFJZr144VnoukXW5JIK1I5FjYLxK7vEHesZYQfC5zxFi19akAcJDNvV7RxAsOFTbYl0v/tGA6pq9Zf/wY2P48JNA9LFm136LCoA== 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 Thu, Mar 02, 2023 at 10:55:48PM -0800, Nhat Pham wrote: > On Sun, Feb 19, 2023 at 4:21 AM Matthew Wilcox wrote: > > > +/** > > > + * 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? > > I ran a quick test using hugetlbfs. It looks like the current > implementation is treating it in accordance to the multi-page > folio case we discussed earlier, i.e: > > - Returned number of "pages" is in terms of the number of > base/small pages (i.e 512 dirty pages instead of 1 dirty > huge page etc.) > - If we touch one byte in the huge page, it would report the > entire huge page as dirty, but again in terms of the underlying > pages. > > Is this what you have in mind, or is there another edge > case that I'm missing...? Hugetlbfs indexes its pages by hugepage number rather than by smallpage number. Imagine you have a 2MB folio at offset 4MB into the file. Filesystems other than hugetlbfs store it at indices 1024-1535. hugetlbfs stores it at index 2. So your report probably seems to work, but if you ask it about a range, you might be surprised by how wide that range will cover for hugetlbfs. I know Sidhartha is working on fixing that, but I'm not sure if what he has is working yet.