From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] mtest06/mmap1: rewrite to newlib
Date: Fri, 30 Nov 2018 04:46:32 -0500 (EST) [thread overview]
Message-ID: <2002461812.80702248.1543571192512.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20181129134411.GA22216@rei.lan>
----- Original Message -----
> Hi!
> > Instead each mmap/munmap increases a map/unmap counter. Upon hitting
> > SIGSEGV or when comparing read value, these counter values are used
> > to determine state of mapped area as observed by first thread.
> > This isn't 100% accurrate as first thread might be faster than the
> > check, but it allows second thread to race against map/unmap for
> > its entire duration.
>
> Looks good to me, using atomic counters and comparing values before and
> after we access the memory is very clever as well. You can add my
> Reviewed-by.
>
> Very minor comments below.
> > +/* compare "before read" counters with "after read" counters */
> > +static inline int was_area_mapped(int br_m, int br_u, int ar_m, int ar_u)
> > +{
> > + return (br_m == ar_m && br_u == ar_u && br_m > br_u);
> > +}
>
> Since the br_map and br_unmap are global I would consider passing only
> the values after to this function.
Hi,
I find it more clear if it doesn't depend on globals. Since it's inlined
there should be no penalty, so I kept it as is.
> > +
> > +void *read_mem(LTP_ATTRIBUTE_UNUSED void *ptr)
> > +{
> > + int i, j, ar_map, ar_unmap;
> > + unsigned char c;
> > +
> > + for (i = 0; i < num_iter; i++) {
> > + if (setjmp(jmpbuf) == 1)
> > + continue;
I made 'i' volatile, since longjmp could clobber it.
> > +static void run(void)
> > +{
> > + pthread_t thid[2];
> > + long chld_args[1];
> > + int remaining = tst_timeout_remaining();
> > + int elapsed = 0;
> > +
> > + while (tst_timeout_remaining() > STOP_THRESHOLD) {
> > + int fd = mkfile(file_size);
> > +
> > + tst_atomic_store(0, &mapcnt);
> > + tst_atomic_store(0, &unmapcnt);
> > +
> > + chld_args[0] = fd;
>
> I would have just casted the fd here to long or intptr_t (to make sure
> compiler padds it with zeroes) then to (void*) and passed the value
> directly, i.e. (void*)(inptr_t)fd and then back in the thread we do
> fd = (intptr_t)ptr.
I changed this to pass int ptr directly, which requires no casts AFAICT.
... and pushed.
Thanks,
Jan
next prev parent reply other threads:[~2018-11-30 9:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 8:21 [LTP] [PATCH v2] mtest06/mmap1: rewrite to newlib Jan Stancek
2018-11-27 6:37 ` Li Wang
2018-11-27 8:54 ` Jan Stancek
2018-11-29 13:44 ` Cyril Hrubis
2018-11-30 9:46 ` Jan Stancek [this message]
2019-02-04 8:34 ` Naresh Kamboju
2019-02-04 9:05 ` Jan Stancek
2019-02-05 6:46 ` Jan Stancek
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=2002461812.80702248.1543571192512.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.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 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.