public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: Mats Liljegren <mats.liljegren@enea.com>
Cc: ltp-list@lists.sourceforge.net, Kevin Hilman <khilman@linaro.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [LTP] [PATCH] partrt_nohz_full: Introducing a new test case
Date: Wed, 7 May 2014 14:17:21 +0200	[thread overview]
Message-ID: <20140507121721.GA20240@rei> (raw)
In-Reply-To: <20140507132016.40361a0a@mats-desktop>

Hi!
> > > +	/* Launch command */
> > > +	errno = 0;
> > > +	file = popen(cmd_buf, "r");
> > > +	if (file == NULL) {
> > > +		if (errno == 0)
> > > +			tst_brkm(TBROK, cleanup, "%s: popen(): Out
> > > of memory",
> > > +				 cmd_buf);
> > > +		else
> > > +			tst_brkm(TBROK | TERRNO, cleanup,
> > > +				"%s: popen() failed", cmd_buf);
> > > +	}
> > 
> > This may be worth of SAFE_POPEN(), I can add it if you want.
> 
> Go ahead. I'll update my code when you're done.

Ok.

> > > +	/* Move child to RT partition */
> > > +	SAFE_ASPRINTF(cleanup, &tid_str, "%ld", (long) tid);
> > > +	SAFE_WRITE(cleanup, 1, cpuset_tasks_fd, tid_str,
> > > strlen(tid_str)); +
> > > +	free(tid_str);
> > > +	SAFE_CLOSE(cleanup, cpuset_tasks_fd);
> > 
> > 	SAFE_FILE_PRINTF(cleanup, CPUSET_RT_TASKS_FILE, "%ld",
> > (long)tid) ?
> > 
> > 	Or is there a good reason to use open(), asprintf(), write()
> > and close() instead?
> 
> Well, printf() by itself will do no file updates, but I replaced
> open(), asprintf(), write(), free() and close() with fopen(), fprintf()
> and fclose().

You lost me here.

Have you seen the code for the SAFE_FILE_PRINTF()? What it does is
is fopen(), fprintf() and fclose(). It was designed to simplify
writing to various kernel pseudo filesystems to one call.

> > > +	for (nr_matches = fscanf(stream, "%d-%d", &range_first,
> > > &range_last);
> > > +	     nr_matches > 0;
> > > +	     nr_matches = fscanf(stream, ",%d-%d", &range_first,
> > > &range_last)) {
> > > +		if (nr_matches == 1)
> > > +			range_last = range_first;
> > > +
> > > +		/* Set all bits in range */
> > > +		for (bit = range_first; bit <= range_last; bit++)
> > > +			mask |= (1 << bit);
> > 
> >                        Are you sure that this would not overflow?
> > 
> > 		       I guess that it depends on how you have
> > 		       partitioned your CPUs.
> 
> As far as I know there is no API stable and architecture portable way of
> determining how many CPUs a machine has, which makes this whole
> business a bit tricky. The problem starts with the partrt tool, which
> should actually support arbitrarily long masks, but this hasn't
> happened.

There is sysconf(_SC_NPROCESSORS_CONF) which tries to collect this
information from the system. It first tries /sys/devices/system/cpu/
then /proc/cpuinfo.

> This is on the TODO list, so currently the test only guarantees 32
> CPUs. Should probably be documented somewhere...

Right, at least add this into the documentation.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  parent reply	other threads:[~2014-05-07 12:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10 13:50 [LTP] Testing absence of ticks with nohz_full Mats Liljegren
2014-03-10 14:04 ` chrubis
2014-03-10 15:17 ` Frederic Weisbecker
2014-03-10 15:27   ` Steven Rostedt
2014-03-10 15:33     ` Frederic Weisbecker
2014-03-11 10:34   ` Mats Liljegren
2014-03-11 23:31     ` Steven Rostedt
2014-03-13 22:10 ` Kevin Hilman
2014-03-17 16:35   ` Mats Liljegren
2014-04-16 15:48     ` [LTP] [RFC][PATCH] partrt_nohz_full: Introducing a new test case Mats Liljegren
2014-04-16 15:48       ` Mats Liljegren
2014-04-22 15:47         ` chrubis
     [not found]           ` <20140423124410.29874232@mats-desktop>
2014-04-23 11:34             ` chrubis
     [not found]           ` <20140424105218.5cd2b5bf@mats-desktop>
2014-04-24  9:06             ` chrubis
     [not found]               ` <20140424140358.63dac752@mats-desktop>
2014-04-24 12:35                 ` chrubis
2014-04-22 14:07       ` chrubis
     [not found]         ` <20140423084101.536f03f0@mats-desktop>
2014-04-23 10:24           ` chrubis
2014-04-28 15:06       ` [LTP] [PATCH v2] " Mats Liljegren
2014-04-28 15:06         ` [LTP] [PATCH] " Mats Liljegren
2014-05-06 16:20           ` chrubis
     [not found]             ` <20140507132016.40361a0a@mats-desktop>
2014-05-07 12:17               ` chrubis [this message]
2014-05-13 14:11         ` [LTP] [PATCH v3] " Mats Liljegren
2014-05-13 14:11           ` Mats Liljegren
2014-06-02 17:17             ` chrubis
     [not found]               ` <20140603104018.3b0cba6f@mats-desktop>
2014-06-03 11:31                 ` chrubis
     [not found]                 ` <20141030171737.3eb800f1@mats-desktop>
2014-11-26 13:40                   ` Cyril Hrubis
2014-05-28 16:45           ` Mats Liljegren
2014-05-29 12:21             ` chrubis

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=20140507121721.GA20240@rei \
    --to=chrubis@suse.cz \
    --cc=fweisbec@gmail.com \
    --cc=khilman@linaro.org \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=mats.liljegren@enea.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