From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] zram/zram03.c: Fix obsolete zram status files
Date: Thu, 13 Sep 2018 15:39:07 +0800 [thread overview]
Message-ID: <5B9A141B.1050106@cn.fujitsu.com> (raw)
In-Reply-To: <1531385810-22036-1-git-send-email-yangx.jy@cn.fujitsu.com>
Hi,
Ping :-)
Thanks,
Xiao Yang
On 2018/07/12 16:56, Xiao Yang wrote:
> Since kernel commit c87d1655c295, separate zram status files("compr_data_size",
> "num_reads" etc.) which can be accessed via one of zram<id>/stat or
> zram<id>/io_stat or zram<id>/mm_stat were removed.
>
> This commit broke zram03, as below:
> ----------------------------------------------------------------------
> safe_file_ops.c:144: Failed to open FILE '/sys/block/zram0/compr_data_size'
> for reading at zram03.c:181: errno=ENOENT(2): No such file or directory
> ----------------------------------------------------------------------
>
> Also, zero pages in zram<id>/mm_stat was extended to same element pages
> since kernel commit 8e19d540d107.
>
> We try to get requested zram status by zram<id>/stat and zram<id>/mm_stat
> if separate zram status files don't exist.
>
> URL for detailed zram status:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/blockdev/zram.txt
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/block/stat.txt
>
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
> testcases/kernel/device-drivers/zram/zram03.c | 50 +++++++++++++++++++++++----
> 1 file changed, 44 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/zram/zram03.c b/testcases/kernel/device-drivers/zram/zram03.c
> index 3f7ab4e..06995fd 100644
> --- a/testcases/kernel/device-drivers/zram/zram03.c
> +++ b/testcases/kernel/device-drivers/zram/zram03.c
> @@ -40,6 +40,9 @@ char *TCID = "zram03";
> int TST_TOTAL = 1;
>
> #define PATH_ZRAM "/sys/block/zram0"
> +#define OBSOLETE_ZRAM_FILE "/sys/block/zram0/num_reads"
> +#define PATH_ZRAM_STAT "/sys/block/zram0/stat"
> +#define PATH_ZRAM_MM_STAT "/sys/block/zram0/mm_stat"
> #define SIZE (512 * 1024 * 1024L)
> #define DEVICE "/dev/zram0"
>
> @@ -182,14 +185,49 @@ static void print(char *string)
> tst_resm(TINFO, "%s is %s", filename, value);
> }
>
> +static void print_stat(char *nread, char *nwrite)
> +{
> + char nread_val[BUFSIZ], nwrite_val[BUFSIZ];
> +
> + SAFE_FILE_SCANF(cleanup, PATH_ZRAM_STAT, "%s %*s %*s %*s %s",
> + nread_val, nwrite_val);
> + tst_resm(TINFO, "%s from %s is %s", nread, PATH_ZRAM_STAT,
> + nread_val);
> + tst_resm(TINFO, "%s from %s is %s", nwrite, PATH_ZRAM_STAT,
> + nwrite_val);
> +}
> +
> +static void print_mm_stat(char *orig, char *compr, char *mem, char *zero)
> +{
> + char orig_val[BUFSIZ], compr_val[BUFSIZ];
> + char mem_val[BUFSIZ], zero_val[BUFSIZ];
> +
> + SAFE_FILE_SCANF(cleanup, PATH_ZRAM_MM_STAT, "%s %s %s %*s %*s %s",
> + orig_val, compr_val, mem_val, zero_val);
> + tst_resm(TINFO, "%s from %s is %s", orig, PATH_ZRAM_MM_STAT,
> + orig_val);
> + tst_resm(TINFO, "%s from %s is %s", compr, PATH_ZRAM_MM_STAT,
> + compr_val);
> + tst_resm(TINFO, "%s from %s is %s", mem, PATH_ZRAM_MM_STAT,
> + mem_val);
> + tst_resm(TINFO, "%s from %s is %s", zero, PATH_ZRAM_MM_STAT,
> + zero_val);
> +}
> +
> static void dump_info(void)
> {
> print("initstate");
> - print("compr_data_size");
> - print("orig_data_size");
> print("disksize");
> - print("mem_used_total");
> - print("num_reads");
> - print("num_writes");
> - print("zero_pages");
> + if (!access(OBSOLETE_ZRAM_FILE, F_OK)) {
> + print("orig_data_size");
> + print("compr_data_size");
> + print("mem_used_total");
> + print("zero_pages");
> + print("num_reads");
> + print("num_writes");
> + } else {
> + print_mm_stat("orig_data_size", "compr_data_size",
> + "mem_used_total", "zero/same_pages");
> + print_stat("num_reads", "num_writes");
> + }
> }
next prev parent reply other threads:[~2018-09-13 7:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-12 8:56 [LTP] [PATCH] zram/zram03.c: Fix obsolete zram status files Xiao Yang
2018-09-03 2:17 ` Xiao Yang
2018-09-13 7:39 ` Xiao Yang [this message]
2018-11-06 0:03 ` Petr Vorel
2018-11-06 1:43 ` Xiao Yang
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=5B9A141B.1050106@cn.fujitsu.com \
--to=yangx.jy@cn.fujitsu.com \
--cc=ltp@lists.linux.it \
/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