All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 3/3] cgroups: Add first IO controller test
Date: Tue, 12 Apr 2022 12:28:16 +0100	[thread overview]
Message-ID: <87lewazfzs.fsf@suse.de> (raw)
In-Reply-To: <Yka3Iu1NLRzLnIlk@pevik>

Hello Petr,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Richie,
>
>> +++ b/testcases/kernel/controllers/io/io_control01.c
>> @@ -0,0 +1,155 @@
>> +// SPDX-License-Identifier: GPL-2.0
> nit: not sure if it was deliberate not adding it, but you may want to
> add your/SUSE copyright.
>
>> +/*\
>> + *
>> + * [Description]
>> + *
>> + * Perform some I/O on a file and check if at least some of it is
>> + * recorded by the I/O controller.
>> + *
>> + * The exact amount of I/O performed is dependent on the file system,
>> + * page cache, scheduler and block driver. We call sync and drop the
>> + * file's page cache to force reading and writing. We also write
>> + * random data to try to prevent compression.
>> + *
>> + * The pagecache is a particular issue for reading. If the call to
>> + * fadvise is ignored then the data may only be read from the
>> + * cache. So that no I/O requests are made.
>> + */
>> +
> ...
>> +static int read_io_stats(const char *const line, struct io_stats *const stat)
>> +{
>> +	return sscanf(line,
>> +		      "%u:%u rbytes=%lu wbytes=%lu rios=%lu wios=%lu dbytes=%lu dios=%lu",
>> +		      &stat->mjr, &stat->mnr,
>> +		      &stat->rbytes, &stat->wbytes, &stat->rios, &stat->wios,
>> +		      &stat->dbytes, &stat->dios);
>> +}
> checkpatch.pl false positive:
> io_control01.c:40: WARNING: unchecked sscanf return value
> Obviously perl parsing has some limitations as we check read_io_stats() return
> value.

I'm not sure what to do about this other than switch to a macro which is
a bit silly.

IMO sscanf should have the warn_unused_result attribute and this should
be inherited by read_io_stats. All of which is better handled by the
compiler.

>
> ...
>> +static void setup(void)
>> +{
>> +	char buf[PATH_MAX] = { 0 };
>> +	char *path = SAFE_GETCWD(buf, PATH_MAX - sizeof("mnt") - 1);
>> +	struct stat st;
>> +
>> +	strcpy(path + strlen(path), "/mnt");
>> +
>> +	tst_stat_mount_dev(path, &st);
>> +	dev_major = major(st.st_rdev);
>> +	dev_minor = minor(st.st_rdev);
>> +}
>> +
>> +static struct tst_test test = {
>> +	.test_all = run,
>> +	.setup = setup,
>> +	.needs_device = 1,
> nit: testcases/kernel/controllers/io/io_control01.c: useless tag: needs_device

Pushed with fixes (including needs_device).
-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-04-12 11:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  7:44 [LTP] [PATCH v2 1/3] API/cgroup: Add io controller Richard Palethorpe via ltp
2022-03-29  7:44 ` [LTP] [PATCH v2 2/3] API/device: Add func to stat the actual dev mounted to a path Richard Palethorpe via ltp
2022-04-12  8:46   ` Petr Vorel
2022-03-29  7:44 ` [LTP] [PATCH v2 3/3] cgroups: Add first IO controller test Richard Palethorpe via ltp
2022-04-01  8:26   ` Petr Vorel
2022-04-12 11:28     ` Richard Palethorpe [this message]
2022-04-12  8:58   ` Petr Vorel
2022-04-12  8:26 ` [LTP] [PATCH v2 1/3] API/cgroup: Add io controller Petr Vorel

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=87lewazfzs.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.