[LTP] [PATCH 04/29] Hugetlb: Migrating libhugetlbfs counters

Tarun Sahu tsahu@linux.ibm.com
Thu Nov 3 09:39:07 CET 2022


Hi, 
I am now working on this test after recently posted series,
Looking at your comments on this, I got the following question.

On Oct 17 2022, Cyril Hrubis wrote:
> Hi!
> > +static void bad_value(int line, const char *name, long expect, long actual)
> > +{
> > +	tst_res(TFAIL, "Failure Line %i: Bad %s: expected %li, actual %li",
> > +			line, name, expect, actual);
> > +	tst_brk(TBROK, "Breaking.. as once one of counter is not expected, "
> > +			"it will cause other failure anyway");
> > +}
> 
> Never ever create wrappers around result reporting functions like this.
> This break the best feature these function have, i.e. they print file
> and line number where the problem has happenend.
Sure will update it,
> 
> > +static void verify_counters(int line, long et, long ef, long er, long es)
> > +{
> > +	long t, f, r, s;
> > +
> > +	/* Read pool counters */
> > +	read_meminfo_huge(&t, &f, &r, &s);
> > +
> > +	if (f < r)
> > +		tst_res(TWARN, "HugePages_Free < HugePages_Rsvd");
> 
> Why exactly do we warn here?
> 
Yeah, Will remove this check.
> > +	/* Check actual values against expected values */
> > +	if (t != et)
> > +		bad_value(line, "HugePages_Total", et, t);
> > +
> > +	if (f != ef)
> > +		bad_value(line, "HugePages_Free", ef, f);
> > +
> > +	if (r != er)
> > +		bad_value(line, "HugePages_Rsvd", er, r);
> > +
> > +	if (s != es)
> > +		bad_value(line, "HugePages_Surp", es, s);
> 
> We do have rather nice macros exactly for this TST_EXP_EQ_LI() that
> would work nicely as long as you name the variables with something more
> reasonable than a single character.
> 
Q: TST_EXP_EQ_LI retuns with TPASS if counters matches. Only issue is
these counters are getting checked around 4*4*95=(1520) times in the test.
so to avoid printing PASS for so many times, I propse to avoid use of
it and only print TFAIL in case of failure and exit with help of goto
statements (because once counter are not expected, further checks will
not matter as they will be checked again corrupted counter values).
With this, PASS will be reported only once when all counters will be
checked and test will will be finished without any failure.
> 
> > -- 
> > 2.31.1
> > 
> > 
> > -- 
> > Mailing list info: https://lists.linux.it/listinfo/ltp
> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp


More information about the ltp mailing list