public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Wei Gao via ltp <ltp@lists.linux.it>
To: Richard Palethorpe <rpalethorpe@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] readahead02.c: Use fsync instead of sync
Date: Mon, 16 Jan 2023 21:22:45 -0500	[thread overview]
Message-ID: <20230117021631.GA20825@aa> (raw)
In-Reply-To: <87fscawlku.fsf@suse.de>

On Mon, Jan 16, 2023 at 03:08:44PM +0000, Richard Palethorpe wrote:
> Hello,
> 
> Wei Gao via ltp <ltp@lists.linux.it> writes:
> 
> > Use fsync on test file instead of sync should faster than syncing
> > whole system.
> 
> The test completes in less than a second in OpenQA. We don't want to
> risk introducing a regression or spend time reviewing changes unless the
> performance improvement solves a timeout.
> 
> I suggest you convert dup06 to the new API (for example) or investigate
> a test failure.
> 
The motivation of this change is base on the https://github.com/linux-test-project/ltp/issues/972
which give following suggestion:
"As we run the test inside a loop device I guess that we can also 
sync and drop caches just for the device, which should be faster 
than syncing and dropping the whole system. Possibly we just need 
to umount it and mount it again."

But currently i can not find any API to sync and drop caches just 
ONLY for device, so base my view just replace sync whole 
system to single file also can make a small help.

> >
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > ---
> >  .../kernel/syscalls/readahead/readahead02.c     | 17 +++++++++++++----
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
> > index 7acf4bb18..e04046bc3 100644
> > --- a/testcases/kernel/syscalls/readahead/readahead02.c
> > +++ b/testcases/kernel/syscalls/readahead/readahead02.c
> > @@ -99,6 +99,17 @@ static void drop_caches(void)
> >  	SAFE_FILE_PRINTF(DROP_CACHES_FNAME, "1");
> >  }
> >  
> > +static void sync_drop_caches(void)
> > +{
> > +	int fd;
> > +
> > +	fd  = SAFE_OPEN(testfile, O_RDONLY);
> > +	if (fsync(fd) == -1)
> > +		tst_brk(TBROK | TERRNO, "fsync()");
> > +	SAFE_CLOSE(fd);
> > +	drop_caches();
> > +}
> > +
> >  static unsigned long get_bytes_read(void)
> >  {
> >  	unsigned long ret;
> > @@ -233,8 +244,7 @@ static void test_readahead(unsigned int n)
> >  	read_testfile(tc, 0, testfile, testfile_size, &read_bytes, &usec,
> >  		      &cached);
> >  	cached_high = get_cached_size();
> > -	sync();
> > -	drop_caches();
> > +	sync_drop_caches();
> >  	cached_low = get_cached_size();
> >  	cached_max = MAX(cached_max, cached_high - cached_low);
> >  
> > @@ -246,8 +256,7 @@ static void test_readahead(unsigned int n)
> >  	else
> >  		cached = 0;
> >  
> > -	sync();
> > -	drop_caches();
> > +	sync_drop_caches();
> >  	cached_low = get_cached_size();
> >  	tst_res(TINFO, "read_testfile(1)");
> >  	ret = read_testfile(tc, 1, testfile, testfile_size, &read_bytes_ra,
> > -- 
> > 2.35.3
> 
> 
> -- 
> Thank you,
> Richard.

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

  reply	other threads:[~2023-01-17  2:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16  7:41 [LTP] [PATCH v1] readahead02.c: Use fsync instead of sync Wei Gao via ltp
2023-01-16 15:08 ` Richard Palethorpe
2023-01-17  2:22   ` Wei Gao via ltp [this message]
2023-01-17  9:23     ` Richard Palethorpe
2023-01-17 16:33       ` Cyril Hrubis
2023-01-17 16:50         ` Richard Palethorpe

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=20230117021631.GA20825@aa \
    --to=ltp@lists.linux.it \
    --cc=rpalethorpe@suse.de \
    --cc=wegao@suse.com \
    /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