From: Naoya Horiguchi <naoya.horiguchi@linux.dev>
To: linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Konstantin Khlebnikov <koct9i@gmail.com>,
Christian Hansen <chansen3@cisco.com>,
Changbin Du <changbin.du@intel.com>,
Bin Wang <wangbin224@huawei.com>,
Naoya Horiguchi <naoya.horiguchi@nec.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v1 1/3] tools/vm/page-types.c: make walk_file() aware of address range option
Date: Mon, 4 Oct 2021 15:13:23 +0900 [thread overview]
Message-ID: <20211004061325.1525902-2-naoya.horiguchi@linux.dev> (raw)
In-Reply-To: <20211004061325.1525902-1-naoya.horiguchi@linux.dev>
From: Naoya Horiguchi <naoya.horiguchi@nec.com>
-a|--addr option is used to limit the range of address to be
scanned for page status. It works now for physical address space
(dafult mode) or for virtual address space (with -p option), but
not for file address space (with -f option). So make walk_file()
aware of -a option.
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
---
tools/vm/page-types.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git v5.15-rc3/tools/vm/page-types.c v5.15-rc3_patched/tools/vm/page-types.c
index f62f10c988db..b14376af1f16 100644
--- v5.15-rc3/tools/vm/page-types.c
+++ v5.15-rc3_patched/tools/vm/page-types.c
@@ -967,22 +967,19 @@ static struct sigaction sigbus_action = {
.sa_flags = SA_SIGINFO,
};
-static void walk_file(const char *name, const struct stat *st)
+static void walk_file_range(const char *name, int fd,
+ unsigned long off, unsigned long end)
{
uint8_t vec[PAGEMAP_BATCH];
uint64_t buf[PAGEMAP_BATCH], flags;
uint64_t cgroup = 0;
uint64_t mapcnt = 0;
unsigned long nr_pages, pfn, i;
- off_t off, end = st->st_size;
- int fd;
ssize_t len;
void *ptr;
int first = 1;
- fd = checked_open(name, O_RDONLY|O_NOATIME|O_NOFOLLOW);
-
- for (off = 0; off < end; off += len) {
+ for (; off < end; off += len) {
nr_pages = (end - off + page_size - 1) / page_size;
if (nr_pages > PAGEMAP_BATCH)
nr_pages = PAGEMAP_BATCH;
@@ -1043,6 +1040,21 @@ static void walk_file(const char *name, const struct stat *st)
flags, cgroup, mapcnt, buf[i]);
}
}
+}
+
+static void walk_file(const char *name, const struct stat *st)
+{
+ int i;
+ int fd;
+
+ fd = checked_open(name, O_RDONLY|O_NOATIME|O_NOFOLLOW);
+
+ if (!nr_addr_ranges)
+ add_addr_range(0, st->st_size / page_size);
+
+ for (i = 0; i < nr_addr_ranges; i++)
+ walk_file_range(name, fd, opt_offset[i] * page_size,
+ (opt_offset[i] + opt_size[i]) * page_size);
close(fd);
}
--
2.25.1
next prev parent reply other threads:[~2021-10-04 6:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 6:13 [PATCH v1 0/3] tools/vm/page-types.c: a few improvements Naoya Horiguchi
2021-10-04 6:13 ` Naoya Horiguchi [this message]
2021-10-04 6:13 ` [PATCH v1 2/3] tools/vm/page-types.c: move show_file() to summary output Naoya Horiguchi
2021-10-04 6:13 ` [PATCH v1 3/3] tools/vm/page-types.c: print file offset in hexadecimal Naoya Horiguchi
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=20211004061325.1525902-2-naoya.horiguchi@linux.dev \
--to=naoya.horiguchi@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=changbin.du@intel.com \
--cc=chansen3@cisco.com \
--cc=koct9i@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=wangbin224@huawei.com \
/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