linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Daeho Jeong <daeho43@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Daeho Jeong <daehojeong@google.com>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [bug report] f2fs: introduce periodic iostat io latency traces
Date: Mon, 16 Aug 2021 21:09:45 -0700	[thread overview]
Message-ID: <CACOAw_w3TC8ZM9AKE7frPHnMRcXTE8n1aQChEJR7L3tsJ-K0_w@mail.gmail.com> (raw)
In-Reply-To: <20210816073559.GA12039@kili>

Hi Dan,

We don't use NR_PAGE_TYPE for the index.

Thank you,

On Mon, Aug 16, 2021 at 12:37 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Hello Daeho Jeong,
>
> The patch f4b05791dda9: "f2fs: introduce periodic iostat io latency
> traces" from Aug 3, 2021, leads to the following
> Smatch static checker warnings:
>
> fs/f2fs/f2fs.h:3365 __update_iostat_latency() error: buffer overflow 'sbi->rd_sum_lat' 3 <= 3
> fs/f2fs/f2fs.h:3366 __update_iostat_latency() error: buffer overflow 'sbi->rd_bio_cnt' 3 <= 3
> fs/f2fs/f2fs.h:3367 __update_iostat_latency() error: buffer overflow 'sbi->rd_peak_lat' 3 <= 3
> fs/f2fs/f2fs.h:3368 __update_iostat_latency() error: buffer overflow 'sbi->rd_peak_lat' 3 <= 3
> fs/f2fs/f2fs.h:3370 __update_iostat_latency() error: buffer overflow 'sbi->wr_sum_lat[sync]' 3 <= 3
> fs/f2fs/f2fs.h:3371 __update_iostat_latency() error: buffer overflow 'sbi->wr_bio_cnt[sync]' 3 <= 3
> fs/f2fs/f2fs.h:3372 __update_iostat_latency() error: buffer overflow 'sbi->wr_peak_lat[sync]' 3 <= 3
> fs/f2fs/f2fs.h:3373 __update_iostat_latency() error: buffer overflow 'sbi->wr_peak_lat[sync]' 3 <= 3
>
> fs/f2fs/f2fs.h
>     3348 static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx,
>     3349                                int rw, int sync)
>     3350 {
>     3351        unsigned long ts_diff;
>     3352        unsigned int iotype = iostat_ctx->type;
>     3353        unsigned long flags;
>     3354        struct f2fs_sb_info *sbi = iostat_ctx->sbi;
>     3355
>     3356        if (!sbi->iostat_enable)
>     3357                return;
>     3358
>     3359        ts_diff = jiffies - iostat_ctx->submit_ts;
>     3360        if (iotype >= META_FLUSH)
>                     ^^^^^^^^^^^^^^^^^^^^
> This means the highest value of "iotype" is NR_PAGE_TYPE.
>
>     3361                iotype = META;
>     3362
>     3363        spin_lock_irqsave(&sbi->iostat_lat_lock, flags);
>     3364        if (rw == 0) {
> --> 3365                sbi->rd_sum_lat[iotype] += ts_diff;
>                         ^^^^^^^^^^^^^^^^^^^^^^^
>     3366                sbi->rd_bio_cnt[iotype]++;
>                         ^^^^^^^^^^^^^^^^^^^^^^
> These arrays have NR_PAGE_TYPE elements so it's off by one.
>
>     3367                if (ts_diff > sbi->rd_peak_lat[iotype])
>     3368                        sbi->rd_peak_lat[iotype] = ts_diff;
>     3369        } else {
>     3370                sbi->wr_sum_lat[sync][iotype] += ts_diff;
>     3371                sbi->wr_bio_cnt[sync][iotype]++;
>     3372                if (ts_diff > sbi->wr_peak_lat[sync][iotype])
>     3373                        sbi->wr_peak_lat[sync][iotype] = ts_diff;
>     3374        }
>     3375        spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags);
>     3376 }
>
> regards,
> dan carpenter
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

      reply	other threads:[~2021-08-17  4:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16  7:35 [f2fs-dev] [bug report] f2fs: introduce periodic iostat io latency traces Dan Carpenter
2021-08-17  4:09 ` Daeho Jeong [this message]

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=CACOAw_w3TC8ZM9AKE7frPHnMRcXTE8n1aQChEJR7L3tsJ-K0_w@mail.gmail.com \
    --to=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /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).