From 4cebbfc1ed4b44644d981df996a8ca941e38e8a1 Mon Sep 17 00:00:00 2001 From: Yadnesh Kulkarni Date: Wed, 22 Feb 2023 17:57:55 +0530 Subject: [PATCH] Hugepages plugin skips reading write-only file Since 'demote' is a write-only file do not attempt to to read it. This also prevents the plugin from generating incessant logs about the failure to open it. Fixes: #3993 https://docs.kernel.org/admin-guide/mm/hugetlbpage.html --- src/hugepages.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hugepages.c b/src/hugepages.c index e066300be..bd381a926 100644 --- a/src/hugepages.c +++ b/src/hugepages.c @@ -125,6 +125,14 @@ static int read_hugepage_entry(const char *path, const char *entry, struct entry_info *info = e_info; double value; + /** + * Since demote is a write-only file, do not attempt to open it. + * https://docs.kernel.org/admin-guide/mm/hugetlbpage.html + */ + if (strcmp(entry, "demote") == 0) { + return -1; + } + snprintf(path2, sizeof(path2), "%s/%s", path, entry); FILE *fh = fopen(path2, "rt"); -- 2.39.5