From: Tuan Bui <tuan.d.bui@hp.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org, dbueso@suse.de,
a.p.zijlstra@chello.nl, paulus@samba.org, artagnon@gmail.com,
jolsa@redhat.com, dvhart@linux.intel.com,
Aswin Chandramouleeswaran <aswin@hp.com>,
Jason Low <jason.low2@hp.com>,
akpm@linux-foundation.org, mingo@kernel.org
Subject: Re: [PATCH v3] Perf Bench: Locking Microbenchmark
Date: Wed, 17 Dec 2014 14:28:50 -0800 [thread overview]
Message-ID: <1418855330.3962.5.camel@u64> (raw)
In-Reply-To: <20141211211254.GC9845@kernel.org>
On Thu, 2014-12-11 at 18:12 -0300, Arnaldo Carvalho de Melo wrote:
> > +struct timeval start, end, total;
> > +static unsigned int start_nr = 100;
> > +static unsigned int end_nr = 1100;
> > +static unsigned int increment_by = 100;
> > +static int bench_dur = NOTSET;
> > +static int num_jobs = NOTSET;
> > +static bool run_jobs;
> > +static int n_pro;
> > +
> > +/* Shared variables between fork processes*/
> > +unsigned int *finished, *setup;
> > +unsigned long long *shared_workers;
> > +char *tmp_dir;
>
> Are you sure these variables aren't static?
>
Yes you are right. I will change these to static.
> > +/* Running bench vfs workload */
> > +static void *run_bench_vfs(struct worker *workers)
> > +{
> > + int fd;
> > + unsigned long long nr_ops = 0;
> > + int jobs = num_jobs;
> > +
> > + sprintf(workers->str, "%s/%d-XXXXXX", tmp_dir, getpid());
>
>
> Please use snprintf, checking for overflows on the target string
>
Thank you for pointing this out. I will change all sprintf to use
snprintf and check for overflows on the target string.
> > +
> > + /* finished shared var is use to signal start and end of benchmark */
> > + finished_tmp = (void *)mmap(0, sizeof(unsigned int), PROT_READ|PROT_WRITE,
> > + MAP_SHARED|MAP_ANONYMOUS, -1, 0);
>
> Why do you use these void * casts before mmap alreayd returns void *?
>
Yes the cast to void here is redundant. I will remove the cast to (void
*) here.
> > + if (finished_tmp == (void *) -1)
>
> Please use MAP_FAILED instead of its equivalent (void *) -1.
>
I will check for MAP_FAILED here instead. Thank you for the suggestion.
-Tuan
next prev parent reply other threads:[~2014-12-17 22:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-09 22:54 [PATCH v3] Perf Bench: Locking Microbenchmark Tuan Bui
2014-12-11 6:45 ` Ingo Molnar
2014-12-11 21:12 ` Arnaldo Carvalho de Melo
2014-12-17 22:28 ` Tuan Bui [this message]
2014-12-11 22:57 ` Davidlohr Bueso
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=1418855330.3962.5.camel@u64 \
--to=tuan.d.bui@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=artagnon@gmail.com \
--cc=aswin@hp.com \
--cc=dbueso@suse.de \
--cc=dvhart@linux.intel.com \
--cc=jason.low2@hp.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@samba.org \
/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