From: Filippo ARCIDIACONO <filippo.arcidiacono@st.com>
To: 'Caspar Zhang' <caspar@casparzhang.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v2] getrusage03: add opportunity to reduce memory allocation's size
Date: Thu, 16 Feb 2012 09:57:33 +0100 [thread overview]
Message-ID: <021b01ccec89$06208150$126183f0$@arcidiacono@st.com> (raw)
In-Reply-To: <4F3CA4B0.9000401@casparzhang.com>
> -----Original Message-----
> From: Caspar Zhang [mailto:caspar@casparzhang.com]
> Sent: Thursday, February 16, 2012 7:40 AM
> To: Filippo ARCIDIACONO
> Cc: ltp-list@lists.sourceforge.net
> Subject: Re: [LTP] [PATCH v2] getrusage03: add opportunity to reduce
> memory allocation's size
>
> Hi,
>
> On 02/15/2012 09:04 PM, Filippo ARCIDIACONO wrote:
> > static struct rusage ru;
> > static long maxrss_init;
> > -static int retval, status;
> > +static int retval, status, opt_factor;
> > static pid_t pid;
> > +static char *factor_str;
> > +int factor_nr = 10;
>
> missing `static`?
In my opinion doesn't need to be static.
>
> >
> > +option_t child_options[] = {
> > + { "m:", &opt_factor, &factor_str },
> > + { NULL, NULL, NULL }
> > +};
> > +
> > +static void usage(void);
> > static void inherit_fork(void);
> > -static void inherit_fork2(void);
> > +static void inherit_fork2(const int size);
> > static void fork_malloc(void);
> > static void grandchild_maxrss(void);
> > static void zombie(void);
> > @@ -68,23 +76,33 @@ static void cleanup(void);
> >
> > int main(int argc, char *argv[])
> > {
> > - int lc;
> > + int lc, size;
> > char *msg;
> >
> > - msg = parse_opts(argc, argv, NULL, NULL);
> > + msg = parse_opts(argc, argv, child_options, usage);
> > if (msg != NULL)
> > tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> >
> > setup();
> >
> > + if (opt_factor)
> > + factor_nr = atoi(factor_str);
> > +
> > + if (factor_nr == 0)
> > + tst_brkm(TBROK, cleanup, "Input factor must be != 0");
>
> Hi, I guess factor_nr should not be < 0 too? If so, you might want to
> use
>
> factor_nr = SAFE_STRTOL(NULL, factor_str, 1, LONG_MAX);
>
> where SAFE_STRTOL is defined in safe_macros.h, of course you should
> make
> factor_nr to be long int.
Factor_nr being a multiply factor, should be a relatively small number,
int type should be enough. For this reason I didn't use the SAFE_STRTOL macro you have recently introduced.
It could modify the factor_nr check to "if (factor_nr <= 0)".
Alternatively, as you suggest, it could be use SAFE_STRTOL. In this case I suggest something like
factor_nr = SAFE_STRTOL(NULL, factor_str, 1, FACTOR_MAX)
where FACTOR_MAX should be locally defined, for example, to 20 (two times of actual).
>
> Rest looks good to me.
>
> Thanks,
> Caspar
Filippo.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2012-02-16 8:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-15 13:04 [LTP] [PATCH v2] getrusage03: add opportunity to reduce memory allocation's size Filippo ARCIDIACONO
2012-02-16 6:39 ` Caspar Zhang
2012-02-16 8:57 ` Filippo ARCIDIACONO [this message]
[not found] ` <4f3cc506.49350e0a.271e.703dSMTPIN_ADDED@mx.google.com>
2012-02-16 9:27 ` Caspar Zhang
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='021b01ccec89$06208150$126183f0$@arcidiacono@st.com' \
--to=filippo.arcidiacono@st.com \
--cc=caspar@casparzhang.com \
--cc=ltp-list@lists.sourceforge.net \
/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