From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: yang.yang29@zte.com.cn
Cc: Andrew Morton <akpm@linux-foundation.org>,
minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org,
axboe@kernel.dk, linux-kernel@vger.kernel.org,
linux-block@vger.kernel.org, xu.panda@zte.com.cn
Subject: Re: [PATCH linux-next] zram: use sysfs_emit() to instead of scnprintf()
Date: Mon, 14 Nov 2022 13:02:51 +0900 [thread overview]
Message-ID: <Y3G9649G6j99N/F2@google.com> (raw)
In-Reply-To: <202211141141400847357@zte.com.cn>
On (22/11/14 11:41), yang.yang29@zte.com.cn wrote:
[..]
> static ssize_t max_comp_streams_store(struct device *dev,
> @@ -1191,8 +1191,7 @@ static ssize_t io_stat_show(struct device *dev,
> ssize_t ret;
>
> down_read(&zram->init_lock);
> - ret = scnprintf(buf, PAGE_SIZE,
> - "%8llu %8llu %8llu %8llu\n",
> + ret = sysfs_emit(buf, "%8llu %8llu %8llu %8llu\n",
> (u64)atomic64_read(&zram->stats.failed_reads),
> (u64)atomic64_read(&zram->stats.failed_writes),
> (u64)atomic64_read(&zram->stats.invalid_io),
sysfs_emit() params need to be realigned to match (.
> @@ -1222,8 +1221,7 @@ static ssize_t mm_stat_show(struct device *dev,
> orig_size = atomic64_read(&zram->stats.pages_stored);
> max_used = atomic_long_read(&zram->stats.max_used_pages);
>
> - ret = scnprintf(buf, PAGE_SIZE,
> - "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu\n",
> + ret = sysfs_emit(buf, "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu\n",
> orig_size << PAGE_SHIFT,
> (u64)atomic64_read(&zram->stats.compr_data_size),
> mem_used << PAGE_SHIFT,
Ditto.
> @@ -1247,8 +1245,7 @@ static ssize_t bd_stat_show(struct device *dev,
> ssize_t ret;
>
> down_read(&zram->init_lock);
> - ret = scnprintf(buf, PAGE_SIZE,
> - "%8llu %8llu %8llu\n",
> + ret = sysfs_emit(buf, "%8llu %8llu %8llu\n",
> FOUR_K((u64)atomic64_read(&zram->stats.bd_count)),
> FOUR_K((u64)atomic64_read(&zram->stats.bd_reads)),
> FOUR_K((u64)atomic64_read(&zram->stats.bd_writes)));
Ditto.
> @@ -1266,9 +1263,7 @@ static ssize_t debug_stat_show(struct device *dev,
> ssize_t ret;
>
> down_read(&zram->init_lock);
> - ret = scnprintf(buf, PAGE_SIZE,
> - "version: %d\n%8llu %8llu\n",
> - version,
> + ret = sysfs_emit(buf, "version: %d\n%8llu %8llu\n", version,
> (u64)atomic64_read(&zram->stats.writestall),
> (u64)atomic64_read(&zram->stats.miss_free));
Ditto.
---
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 01ab32f2897e..430933b73c1b 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1192,10 +1192,10 @@ static ssize_t io_stat_show(struct device *dev,
down_read(&zram->init_lock);
ret = sysfs_emit(buf, "%8llu %8llu %8llu %8llu\n",
- (u64)atomic64_read(&zram->stats.failed_reads),
- (u64)atomic64_read(&zram->stats.failed_writes),
- (u64)atomic64_read(&zram->stats.invalid_io),
- (u64)atomic64_read(&zram->stats.notify_free));
+ (u64)atomic64_read(&zram->stats.failed_reads),
+ (u64)atomic64_read(&zram->stats.failed_writes),
+ (u64)atomic64_read(&zram->stats.invalid_io),
+ (u64)atomic64_read(&zram->stats.notify_free));
up_read(&zram->init_lock);
return ret;
@@ -1222,15 +1222,15 @@ static ssize_t mm_stat_show(struct device *dev,
max_used = atomic_long_read(&zram->stats.max_used_pages);
ret = sysfs_emit(buf, "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu\n",
- orig_size << PAGE_SHIFT,
- (u64)atomic64_read(&zram->stats.compr_data_size),
- mem_used << PAGE_SHIFT,
- zram->limit_pages << PAGE_SHIFT,
- max_used << PAGE_SHIFT,
- (u64)atomic64_read(&zram->stats.same_pages),
- atomic_long_read(&pool_stats.pages_compacted),
- (u64)atomic64_read(&zram->stats.huge_pages),
- (u64)atomic64_read(&zram->stats.huge_pages_since));
+ orig_size << PAGE_SHIFT,
+ (u64)atomic64_read(&zram->stats.compr_data_size),
+ mem_used << PAGE_SHIFT,
+ zram->limit_pages << PAGE_SHIFT,
+ max_used << PAGE_SHIFT,
+ (u64)atomic64_read(&zram->stats.same_pages),
+ atomic_long_read(&pool_stats.pages_compacted),
+ (u64)atomic64_read(&zram->stats.huge_pages),
+ (u64)atomic64_read(&zram->stats.huge_pages_since));
up_read(&zram->init_lock);
return ret;
@@ -1246,9 +1246,9 @@ static ssize_t bd_stat_show(struct device *dev,
down_read(&zram->init_lock);
ret = sysfs_emit(buf, "%8llu %8llu %8llu\n",
- FOUR_K((u64)atomic64_read(&zram->stats.bd_count)),
- FOUR_K((u64)atomic64_read(&zram->stats.bd_reads)),
- FOUR_K((u64)atomic64_read(&zram->stats.bd_writes)));
+ FOUR_K((u64)atomic64_read(&zram->stats.bd_count)),
+ FOUR_K((u64)atomic64_read(&zram->stats.bd_reads)),
+ FOUR_K((u64)atomic64_read(&zram->stats.bd_writes)));
up_read(&zram->init_lock);
return ret;
@@ -1264,8 +1264,8 @@ static ssize_t debug_stat_show(struct device *dev,
down_read(&zram->init_lock);
ret = sysfs_emit(buf, "version: %d\n%8llu %8llu\n", version,
- (u64)atomic64_read(&zram->stats.writestall),
- (u64)atomic64_read(&zram->stats.miss_free));
+ (u64)atomic64_read(&zram->stats.writestall),
+ (u64)atomic64_read(&zram->stats.miss_free));
up_read(&zram->init_lock);
return ret;
next prev parent reply other threads:[~2022-11-14 4:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 3:41 [PATCH linux-next] zram: use sysfs_emit() to instead of scnprintf() yang.yang29
2022-11-14 4:02 ` Sergey Senozhatsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-11-15 1:12 guo.ziliang
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=Y3G9649G6j99N/F2@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
--cc=xu.panda@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
/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 NNTP newsgroup(s).