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 B910DC54EBD for ; Fri, 13 Jan 2023 09:36:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E0CD8E0002; Fri, 13 Jan 2023 04:36:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 191178E0001; Fri, 13 Jan 2023 04:36:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 080598E0002; Fri, 13 Jan 2023 04:36:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EE1648E0001 for ; Fri, 13 Jan 2023 04:36:12 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9E0BC1C5F68 for ; Fri, 13 Jan 2023 09:36:12 +0000 (UTC) X-FDA: 80349269784.14.BD2DB00 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf11.hostedemail.com (Postfix) with ESMTP id DD99240017 for ; Fri, 13 Jan 2023 09:36:10 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673602571; a=rsa-sha256; cv=none; b=zX3Q+BJe5yUQZjbOXvIBHJrT+2/GAzD+TZdRAGj7bZvapZIuhaapw2dBSUCQubwiKIwdiu lBNzkOnCqn5yDiqE6tH1YFOIwncRCCk+IjHhNCBY3EdJPlwsVCYPmVKVthtvbj1YOXRn5m +ND7pVvbbHjlctTUfm5MIgyDWWyz5MQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673602571; 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; bh=OfYWOGUw6JcZk6BCbCEfYG54SLYJu12x8TR2uJqxvmU=; b=sfsqAUSA9xZPiYiZQNbFkf4U46uOb4l8v6F9jO6k0gi28L4x+KFr98INYxjSN3M3tpR7Bj kqnZvhI37ndJ7YE95c0foEcEAj+vezON6WlaARFkudyES8eJWA7k94QkUi04VJ/VXtPf5X 8vt9MzOJI+qKVIWhwSzQPP1oG9TWqiA= Received: by mail-qt1-f170.google.com with SMTP id h21so18503799qta.12 for ; Fri, 13 Jan 2023 01:36:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=OfYWOGUw6JcZk6BCbCEfYG54SLYJu12x8TR2uJqxvmU=; b=J+PX81Vz9hUrWAwyIvjgqjVOYU+Xxn7wEll8udoGiAEov4y63FLs2uWWaB9lFlM9tr 9XihqkVNuZWChxR2sXvTgR+3T1/kJtUaWC06jyBALjSn0heJImqs9MFEAeQfi+E3KQ6K kfjFXrP8RB4u0M5sIWaiuqSC8y/I8VUFfMqu7wPgbJsqZuVNltZubDM/sf/+PmBVnamz A9hSIs9BXePIiNmbQ1hX716zzOxAyVTAJx/fCG3aFow4i+O9egDIoerFiqSOzCQKwndB rBQKt+i9dMPSVyHtQwZpEeRWYMivEKBrobi60fyBtG808vmFejJH1hIS4zHqkohyY3Nx v1oQ== X-Gm-Message-State: AFqh2krCr704vS5oU+QyD4qREXtP/sYOMnez0YmXaliTHvVoZ2WJ5LBK RLqQtkRwy+SOuyd6zlZ8aqBqOOXstBXLog== X-Google-Smtp-Source: AMrXdXs3GBlC910Lg4jwc2mkJdSP+rkma2IbPA25fOpHmnsdn9c3N4QmksasJvoyrzOBVwdkIt4ogQ== X-Received: by 2002:ac8:1203:0:b0:3ad:ccdb:97e with SMTP id x3-20020ac81203000000b003adccdb097emr20841360qti.51.1673602569855; Fri, 13 Jan 2023 01:36:09 -0800 (PST) Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com. [209.85.128.177]) by smtp.gmail.com with ESMTPSA id gb15-20020a05622a598f00b003a530a32f67sm10147171qtb.65.2023.01.13.01.36.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Jan 2023 01:36:09 -0800 (PST) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-4db05a4db9bso53837507b3.10 for ; Fri, 13 Jan 2023 01:36:09 -0800 (PST) X-Received: by 2002:a0d:d98c:0:b0:4dd:7a8e:1cf3 with SMTP id b134-20020a0dd98c000000b004dd7a8e1cf3mr249079ywe.384.1673602568857; Fri, 13 Jan 2023 01:36:08 -0800 (PST) MIME-Version: 1.0 References: <20230104231127.2634648-1-nphamcs@gmail.com> <20230104231127.2634648-3-nphamcs@gmail.com> In-Reply-To: <20230104231127.2634648-3-nphamcs@gmail.com> From: Geert Uytterhoeven Date: Fri, 13 Jan 2023 10:35:57 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 2/3] cachestat: implement cachestat syscall To: Nhat Pham Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bfoster@redhat.com, willy@infradead.org, kernel-team@meta.com Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Queue-Id: DD99240017 X-Rspamd-Server: rspam01 X-Stat-Signature: zqkduj463smpajhtgt3zc89rxg6ctngu X-HE-Tag: 1673602570-412826 X-HE-Meta: U2FsdGVkX18YE+xw1Nhi4Raf+1FvRki2zrvWzL1VOh5F7yhDf1uK8sOgRkaA2VaHywysfOeJHNg145jvGqSmpx8BVc3Ii2CoK0BuNWDuVnSNoY1vw2zzzTN4YV4jKDuChqdBreAP78JfpY+bmbk3cgYLV+7u1niBFRhclsgqGtkYwnki9sGaPwCbpn68dCcI4i5rVgvd4ZlMyVR/0XtthwurIJouQ1M0QlHA24iyi+FqMr2OCTYKQks9sSCvs66Xgn4YFLs/cEWXbZo2nb8RQ0BS0hIGrA0wPIpryBngyuS61NR6ms+kPYUT4oQc8FS9QWEQRt60/k4uDygCG3rFjgPFTfiiv3sn0qab5Xx6wqIRxNteO+Gd5eEPb7Uw9QFwMzF20oUEZT3SylsYXUy29Anzoquw4th8Dh9Ofc0kiSO7IFR46rrHpKXT52tALkwHvN56WtWvlg0HcPkbrhGONLQW04JogdHSS1uTc0qrVN8x6mEK5yZjcwJYA3+rXS2Nnx7xRzdx1ypU3lGAukXTp4dxOba96zveAfxHPWUBoL2Z+U7K6Vl0ERik9JIBXwNdNdhfPYS8QddzB8YJFnfkrZiSZprUchBzCS3aRPl7S/HsIGNcxFfJWoEuWMZ6KF48LJn4V/ZiW3JB4Azlw3x+Xh/VnAw/2YNQCa4qIwoJvowrydY1Yw317/rSD60wsgI3BGjSoAVeHxmE3jPH7RMCPH0IrzRfg0wHpiF+oIODMHVOdQOpYLSyM10bm1kBKfhPhBydtDQUf+MElrEyra7dDgc3DtzQXdz2MlFD+I31wufXVQqcxGzkXODuUO5X5ZO5pZmlCKFly6/yWJu6lGVI5R7/eZEetZGrRyZUYYxzqZXLU6cyO4tMQjUAPa0v4JU9dSRC8Bh3Wv8YG9Ndbqut3XK4kujKJQQpBT/qe2ZqZBRFY2mFc3dxH9HUntpwhc+4/ksyJiB8xO91NWS7iLE /ioVYdNK 8RH0WDWMoUbX5Csvq33E7GHrZZRbCz2IqhzTMKuaT2ZgZGg1eZUhrJnap0QpkBwStTVxaxomT3ubefi9C+xPgFpod4BgMOe4sT0ZdssahJz0xO6rizqH7WitKA+CaB4AfgN/vXJC8dxDaLN5RgvUTR4hNIlgLc3/UdMaOlRPkPSdCGpENUEApvl/yA1YYHj5oCDPy 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, Jan 5, 2023 at 12:13 AM 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 statistics of a file. > > SYNOPSIS > #include > > struct cachestat { > __u64 nr_cache; > __u64 nr_dirty; > __u64 nr_writeback; > __u64 nr_evicted; > __u64 nr_recently_evicted; > }; > > int cachestat(unsigned int fd, off_t off, size_t len, > size_t cstat_size, struct cachestat *cstat, > unsigned int flags); > > DESCRIPTION > cachestat() queries the number of cached pages, number of dirty > pages, number of pages marked for writeback, number of evicted > pages, number of recently evicted pages, in the bytes range given by > `off` and `len`. > > An evicted page is a page that is previously in the page cache but > has been evicted since. A page is recently evicted if its last > eviction was recent enough that its reentry to the cache would > indicate that it is actively being used by the system, and that > there is memory pressure on the system. > > These values are returned in a cachestat struct, whose address is > given by the `cstat` argument. > > The `off` and `len` arguments must be non-negative integers. If > `len` > 0, the queried range is [`off`, `off` + `len`]. If `len` == > 0, we will query in the range from `off` to the end of the file. > > `cstat_size` allows users to obtain partial results. The syscall > will copy the first `csstat_size` bytes to the specified userspace > memory. `cstat_size` must be a non-negative value that is no larger > than the current size of the cachestat struct. > > The `flags` argument is unused for now, but is included for future > extensibility. User should pass 0 (i.e no flag specified). > > RETURN VALUE > On success, cachestat returns 0. On error, -1 is returned, and errno > is set to indicate the error. > > ERRORS > EFAULT cstat points to an invalid address. > > EINVAL invalid `cstat_size` or `flags` > > EBADF invalid file descriptor. > > Signed-off-by: Nhat Pham > arch/m68k/kernel/syscalls/syscall.tbl | 1 + Acked-by: Geert Uytterhoeven [m68k] Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds