From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, cem@kernel.org
Cc: Christoph Hellwig <hch@lst.de>,
cmaiolino@redhat.com, linux-xfs@vger.kernel.org,
hch@infradead.org
Subject: [PATCH 5/5] xfs_io: add linux madvise advice codes
Date: Mon, 15 Apr 2024 17:59:52 -0700 [thread overview]
Message-ID: <171322881873.210882.13529720668713675414.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <171322881805.210882.5445286603045179895.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Add all the Linux-specific madvise codes. We're going to need
MADV_POPULATE_READ for a regression test.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
io/madvise.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 1 deletion(-)
diff --git a/io/madvise.c b/io/madvise.c
index 6e9c5b121d72..ede233955ced 100644
--- a/io/madvise.c
+++ b/io/madvise.c
@@ -9,6 +9,7 @@
#include <sys/mman.h>
#include "init.h"
#include "io.h"
+#include <asm/mman.h>
static cmdinfo_t madvise_cmd;
@@ -26,6 +27,31 @@ madvise_help(void)
" -r -- expect random page references (POSIX_MADV_RANDOM)\n"
" -s -- expect sequential page references (POSIX_MADV_SEQUENTIAL)\n"
" -w -- will need these pages (POSIX_MADV_WILLNEED) [*]\n"
+"\n"
+"The following Linux-specific advise values are available:\n"
+#ifdef MADV_COLLAPSE
+" -c -- try to collapse range into transparent hugepages (MADV_COLLAPSE)\n"
+#endif
+#ifdef MADV_COLD
+" -D -- deactivate the range (MADV_COLD)\n"
+#endif
+" -f -- free the range (MADV_FREE)\n"
+" -h -- disable transparent hugepages (MADV_NOHUGEPAGE)\n"
+" -H -- enable transparent hugepages (MADV_HUGEPAGE)\n"
+" -m -- mark the range mergeable (MADV_MERGEABLE)\n"
+" -M -- mark the range unmergeable (MADV_UNMERGEABLE)\n"
+" -o -- mark the range offline (MADV_SOFT_OFFLINE)\n"
+" -p -- punch a hole in the file (MADV_REMOVE)\n"
+" -P -- poison the page cache (MADV_HWPOISON)\n"
+#ifdef MADV_POPULATE_READ
+" -R -- prefault in the range for read (MADV_POPULATE_READ)\n"
+#endif
+#ifdef MADV_POPULATE_WRITE
+" -W -- prefault in the range for write (MADV_POPULATE_WRITE)\n"
+#endif
+#ifdef MADV_PAGEOUT
+" -X -- reclaim the range (MADV_PAGEOUT)\n"
+#endif
" Notes:\n"
" NORMAL sets the default readahead setting on the file.\n"
" RANDOM sets the readahead setting on the file to zero.\n"
@@ -45,20 +71,69 @@ madvise_f(
int advise = MADV_NORMAL, c;
size_t blocksize, sectsize;
- while ((c = getopt(argc, argv, "drsw")) != EOF) {
+ while ((c = getopt(argc, argv, "cdDfhHmMopPrRswWX")) != EOF) {
switch (c) {
+#ifdef MADV_COLLAPSE
+ case 'c': /* collapse to thp */
+ advise = MADV_COLLAPSE;
+ break;
+#endif
case 'd': /* Don't need these pages */
advise = MADV_DONTNEED;
break;
+#ifdef MADV_COLD
+ case 'D': /* make more likely to be reclaimed */
+ advise = MADV_COLD;
+ break;
+#endif
+ case 'f': /* page range out of memory */
+ advise = MADV_FREE;
+ break;
+ case 'h': /* enable thp memory */
+ advise = MADV_HUGEPAGE;
+ break;
+ case 'H': /* disable thp memory */
+ advise = MADV_NOHUGEPAGE;
+ break;
+ case 'm': /* enable merging */
+ advise = MADV_MERGEABLE;
+ break;
+ case 'M': /* disable merging */
+ advise = MADV_UNMERGEABLE;
+ break;
+ case 'o': /* offline */
+ advise = MADV_SOFT_OFFLINE;
+ break;
+ case 'p': /* punch hole */
+ advise = MADV_REMOVE;
+ break;
+ case 'P': /* poison */
+ advise = MADV_HWPOISON;
+ break;
case 'r': /* Expect random page references */
advise = MADV_RANDOM;
break;
+#ifdef MADV_POPULATE_READ
+ case 'R': /* fault in pages for read */
+ advise = MADV_POPULATE_READ;
+ break;
+#endif
case 's': /* Expect sequential page references */
advise = MADV_SEQUENTIAL;
break;
case 'w': /* Will need these pages */
advise = MADV_WILLNEED;
break;
+#ifdef MADV_POPULATE_WRITE
+ case 'W': /* fault in pages for write */
+ advise = MADV_POPULATE_WRITE;
+ break;
+#endif
+#ifdef MADV_PAGEOUT
+ case 'X': /* reclaim memory */
+ advise = MADV_PAGEOUT;
+ break;
+#endif
default:
exitcode = 1;
return command_usage(&madvise_cmd);
next prev parent reply other threads:[~2024-04-16 0:59 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 0:51 [PATCHBOMB v3] xfsprogs: everything headed towards 6.9 Darrick J. Wong
2024-04-16 0:57 ` [PATCHSET 1/4] xfsprogs: bug fixes for 6.8 Darrick J. Wong
2024-04-16 0:58 ` [PATCH 1/5] xfs_repair: double-check with shortform attr verifiers Darrick J. Wong
2024-04-16 0:59 ` [PATCH 2/5] xfs_db: improve number extraction in getbitval Darrick J. Wong
2024-04-16 4:53 ` Christoph Hellwig
2024-04-16 0:59 ` [PATCH 3/5] xfs_scrub: fix threadcount estimates for phase 6 Darrick J. Wong
2024-04-16 4:53 ` Christoph Hellwig
2024-04-16 0:59 ` [PATCH 4/5] xfs_scrub: don't fail while reporting media scan errors Darrick J. Wong
2024-04-16 0:59 ` Darrick J. Wong [this message]
2024-04-17 7:34 ` [PATCHSET 1/4] xfsprogs: bug fixes for 6.8 Carlos Maiolino
2024-04-17 15:30 ` Darrick J. Wong
2024-04-16 0:58 ` [PATCHSET 2/4] libxfs: sync with 6.9 Darrick J. Wong
2024-04-16 1:00 ` [PATCH 088/111] libxfs: teach buftargs to maintain their own buffer hashtable Darrick J. Wong
2024-04-16 1:00 ` [PATCH 089/111] libxfs: add xfile support Darrick J. Wong
2024-04-16 1:00 ` [PATCH 090/111] libxfs: partition memfd files to avoid using too many fds Darrick J. Wong
2024-04-16 4:55 ` Christoph Hellwig
2024-04-16 15:49 ` Darrick J. Wong
2024-04-16 16:29 ` Christoph Hellwig
2024-04-16 16:57 ` Darrick J. Wong
2024-04-16 18:47 ` Christoph Hellwig
2024-04-16 18:55 ` Darrick J. Wong
2024-04-24 17:20 ` [PATCH v3.1 " Darrick J. Wong
2024-04-16 1:00 ` [PATCH 091/111] xfs: teach buftargs to maintain their own buffer hashtable Darrick J. Wong
2024-04-16 1:01 ` [PATCH 092/111] libxfs: support in-memory buffer cache targets Darrick J. Wong
2024-04-16 0:58 ` [PATCHSET v30.3 3/4] xfsprogs: bmap log intent cleanups Darrick J. Wong
2024-04-16 1:01 ` [PATCH 1/4] libxfs: remove kmem_alloc, kmem_zalloc, and kmem_free Darrick J. Wong
2024-04-16 4:55 ` Christoph Hellwig
2024-04-16 1:01 ` [PATCH 2/4] libxfs: add a bi_entry helper Darrick J. Wong
2024-04-16 4:55 ` Christoph Hellwig
2024-04-16 1:01 ` [PATCH 3/4] libxfs: reuse xfs_bmap_update_cancel_item Darrick J. Wong
2024-04-16 4:55 ` Christoph Hellwig
2024-04-16 1:02 ` [PATCH 4/4] libxfs: add a xattr_entry helper Darrick J. Wong
2024-04-16 4:56 ` Christoph Hellwig
2024-04-16 0:58 ` [PATCHSET v30.3 4/4] xfs_repair: minor fixes Darrick J. Wong
2024-04-16 1:02 ` [PATCH 1/1] xfs_repair: check num before bplist[num] Darrick J. Wong
2024-04-16 4:56 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2024-04-17 21:16 [PATCHSET 06/11] xfsprogs: bug fixes for 6.8 Darrick J. Wong
2024-04-17 21:41 ` [PATCH 5/5] xfs_io: add linux madvise advice codes Darrick J. Wong
2024-03-26 2:55 [PATCHSET 04/18] xfsprogs: bug fixes for 6.8 Darrick J. Wong
2024-03-26 3:22 ` [PATCH 5/5] xfs_io: add linux madvise advice codes Darrick J. Wong
2024-03-26 5:15 ` Christoph Hellwig
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=171322881873.210882.13529720668713675414.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=cmaiolino@redhat.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).