All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [LTP] [PATCH] There was no "processor" key word in the "cpuinfo" on the non-SMP ARM Platforms. So the tracing "ftrace_buffer_size.sh" script would report "division by 0" error, then it would exit soon. The tracing test would check failed when it could not find this script running.
       [not found]     ` <201210151332.57424.vapier@gentoo.org>
@ 2012-10-15 18:18       ` chrubis
  2012-10-15 18:21         ` chrubis
  0 siblings, 1 reply; 6+ messages in thread
From: chrubis @ 2012-10-15 18:18 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Zhou Guojian, ltp-list

Hi!
> really we should be using `getconf _NPROCESSORS_ONLN` instead and centralizing 
> this parsing logic.  /proc/cpuinfo is directly accessed by many scripts.  the 
> -i suggestion i provided came from its usage in those other files which, 
> according to your findings, are also broken.
> 
> i'd suggest updating tools/apicmds/ to add a new helper program like 
> `tst_ncpus` which will call sysconf() and we convert all of our .sh scripts 
> from reading /proc/cpuinfo to calling that program.

That is coincidentally soultion I would about to propose.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH] There was no "processor" key word in the "cpuinfo" on the non-SMP ARM Platforms. So the tracing "ftrace_buffer_size.sh" script would report "division by 0" error, then it would exit soon. The tracing test would check failed when it could not find this script running.
  2012-10-15 18:18       ` [LTP] [PATCH] There was no "processor" key word in the "cpuinfo" on the non-SMP ARM Platforms. So the tracing "ftrace_buffer_size.sh" script would report "division by 0" error, then it would exit soon. The tracing test would check failed when it could not find this script running chrubis
@ 2012-10-15 18:21         ` chrubis
       [not found]           ` <1350443616-20186-1-git-send-email-gaowanlong@cn.fujitsu.com>
  0 siblings, 1 reply; 6+ messages in thread
From: chrubis @ 2012-10-15 18:21 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Zhou Guojian, ltp-list

> > really we should be using `getconf _NPROCESSORS_ONLN` instead and centralizing 
> > this parsing logic.  /proc/cpuinfo is directly accessed by many scripts.  the 
> > -i suggestion i provided came from its usage in those other files which, 
> > according to your findings, are also broken.
> > 
> > i'd suggest updating tools/apicmds/ to add a new helper program like 
> > `tst_ncpus` which will call sysconf() and we convert all of our .sh scripts 
> > from reading /proc/cpuinfo to calling that program.
> 
> That is coincidentally soultion I would about to propose.

Should have been: "was about to propose"

Now we only need somebody to get it implemented ;).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS
       [not found]           ` <1350443616-20186-1-git-send-email-gaowanlong@cn.fujitsu.com>
@ 2012-10-17  4:31             ` Mike Frysinger
  2012-10-17  7:13               ` Wanlong Gao
  2012-10-17 14:09               ` chrubis
  2012-10-17 13:00             ` chrubis
  1 sibling, 2 replies; 6+ messages in thread
From: Mike Frysinger @ 2012-10-17  4:31 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1: Type: Text/Plain, Size: 873 bytes --]

On Tuesday 16 October 2012 23:13:36 Wanlong Gao wrote:
> --- a/tools/apicmds/ltpapicmd.c
> +++ b/tools/apicmds/ltpapicmd.c
> @@ -266,6 +266,12 @@ int main(int argc, char *argv[])
>  		else if (exit_value > 0)
>  			exit_value = 2;
>  		exit(exit_value);
> +	} else if (strcmp(cmd_name, "tst_ncpus") == 0) {
> +		long exit_ncpus = tst_ncpus();
> +		exit(exit_ncpus);
> +	} else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
> +		long exit_ncpus_max = tst_ncpus_max();
> +		exit(exit_ncpus_max);
>  	}

i'm afraid exit() won't work.  the value is anded with 0xff which means if you 
have a system with 4096 cpus, these will exit(0) and obviously that isn't what 
you want :).  plus, extracting the value from the exit status is not normal 
behavior in the shell scripting world.

simply write it to stdout instead:
	printf("%li\n", tst_ncpus());
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 240 bytes --]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS
  2012-10-17  4:31             ` [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS Mike Frysinger
@ 2012-10-17  7:13               ` Wanlong Gao
  2012-10-17 14:09               ` chrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Wanlong Gao @ 2012-10-17  7:13 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On 10/17/2012 12:31 PM, Mike Frysinger wrote:
> On Tuesday 16 October 2012 23:13:36 Wanlong Gao wrote:
>> --- a/tools/apicmds/ltpapicmd.c
>> +++ b/tools/apicmds/ltpapicmd.c
>> @@ -266,6 +266,12 @@ int main(int argc, char *argv[])
>>  		else if (exit_value > 0)
>>  			exit_value = 2;
>>  		exit(exit_value);
>> +	} else if (strcmp(cmd_name, "tst_ncpus") == 0) {
>> +		long exit_ncpus = tst_ncpus();
>> +		exit(exit_ncpus);
>> +	} else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
>> +		long exit_ncpus_max = tst_ncpus_max();
>> +		exit(exit_ncpus_max);
>>  	}
> 
> i'm afraid exit() won't work.  the value is anded with 0xff which means if you 
> have a system with 4096 cpus, these will exit(0) and obviously that isn't what 
> you want :).  plus, extracting the value from the exit status is not normal 
> behavior in the shell scripting world.
> 
> simply write it to stdout instead:
> 	printf("%li\n", tst_ncpus());

OK, thank you for your suggestion. I'll update my patch.

Thanks,
Wanlong Gao

> -mike
> 


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS
       [not found]           ` <1350443616-20186-1-git-send-email-gaowanlong@cn.fujitsu.com>
  2012-10-17  4:31             ` [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS Mike Frysinger
@ 2012-10-17 13:00             ` chrubis
  1 sibling, 0 replies; 6+ messages in thread
From: chrubis @ 2012-10-17 13:00 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: LTP

Hi!
>  lib/tst_cpu.c             | 50 +++++++++++++++++++++++++++++++++++++++++++++++

Hmm, aren't you missing header for tst_ncpus() and tst_ncpus_max()?

> +/*
> + *   Copyright (c) 2012 Fujitsu Ltd.
> + *   Author: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> + *
> + *   This program is free software;  you can redistribute it and/or modify
> + *   it under the terms of the GNU General Public License as published by
> + *   the Free Software Foundation; either version 2 of the License, or
> + *   (at your option) any later version.
> + *
> + *   This program is distributed in the hope that it will be useful,
> + *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
> + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> + *   the GNU General Public License for more details.
> + *
> + *   You should have received a copy of the GNU General Public License
> + *   along with this program;  if not, write to the Free Software
> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include "test.h"
> +
> +long tst_ncpus(void)
> +{
> +	long ncpus = -1;
> +#ifdef _SC_NPROCESSORS_ONLN
> +	ncpus = sysconf(_SC_NPROCESSORS_ONLN);
> +	if (ncpus < 1)
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "failed to determine number of CPUs online");
> +#else
> +	tst_brkm(TBROK, NULL, "could not determine number of CPUs online");
> +#endif
> +	return ncpus;
> +}
> +
> +long tst_ncpus_max(void)
> +{
> +#ifdef _SC_NPROCESSORS_CONF
> +	long ncpus_max = -1;
> +	ncpus_max = sysconf(_SC_NPROCESSORS_CONF);
> +	if (ncpus_max < 1)
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "failed to determine number of CPUs configured");
> +#else
> +	tst_brkm(TBROK, NULL, "could not determine number of CPUs configured");
> +#endif
> +	return ncpus_max;
> +}

Looking at the code makes me wonder if creating SAFE_SYSCONF() wouldn't
be more universal solution.

> diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile
> index 59ce6be..faa49b5 100644
> --- a/tools/apicmds/Makefile
> +++ b/tools/apicmds/Makefile
> @@ -26,7 +26,8 @@ include $(top_srcdir)/include/mk/testcases.mk
>  
>  CPPFLAGS		+= -D_GNU_SOURCE
>  
> -MAKE_TARGETS		:= $(addprefix tst_,brk brkm exit flush kvercmp res resm)
> +MAKE_TARGETS		:= $(addprefix tst_,brk brkm exit flush kvercmp res resm \
> +			     ncpus ncpus_max)
>  
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
>  
> diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
> index fe7349b..a1ddb5c 100644
> --- a/tools/apicmds/ltpapicmd.c
> +++ b/tools/apicmds/ltpapicmd.c
> @@ -266,6 +266,12 @@ int main(int argc, char *argv[])
>  		else if (exit_value > 0)
>  			exit_value = 2;
>  		exit(exit_value);
> +	} else if (strcmp(cmd_name, "tst_ncpus") == 0) {
> +		long exit_ncpus = tst_ncpus();
> +		exit(exit_ncpus);
> +	} else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
> +		long exit_ncpus_max = tst_ncpus_max();
> +		exit(exit_ncpus_max);
>  	}

That part looks okay.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS
  2012-10-17  4:31             ` [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS Mike Frysinger
  2012-10-17  7:13               ` Wanlong Gao
@ 2012-10-17 14:09               ` chrubis
  1 sibling, 0 replies; 6+ messages in thread
From: chrubis @ 2012-10-17 14:09 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

Hi!
> > --- a/tools/apicmds/ltpapicmd.c
> > +++ b/tools/apicmds/ltpapicmd.c
> > @@ -266,6 +266,12 @@ int main(int argc, char *argv[])
> >  		else if (exit_value > 0)
> >  			exit_value = 2;
> >  		exit(exit_value);
> > +	} else if (strcmp(cmd_name, "tst_ncpus") == 0) {
> > +		long exit_ncpus = tst_ncpus();
> > +		exit(exit_ncpus);
> > +	} else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
> > +		long exit_ncpus_max = tst_ncpus_max();
> > +		exit(exit_ncpus_max);
> >  	}
> 
> i'm afraid exit() won't work.  the value is anded with 0xff which means if you 
> have a system with 4096 cpus, these will exit(0) and obviously that isn't what 
> you want :).  plus, extracting the value from the exit status is not normal 
> behavior in the shell scripting world.
> 
> simply write it to stdout instead:
> 	printf("%li\n", tst_ncpus());

Ah, right, I really overlooked this.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-17 14:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1349679654-16708-1-git-send-email-GuoJian.Zhou@windriver.com>
     [not found] ` <201210150014.47389.vapier@gentoo.org>
     [not found]   ` <507B9964.8070905@windriver.com>
     [not found]     ` <201210151332.57424.vapier@gentoo.org>
2012-10-15 18:18       ` [LTP] [PATCH] There was no "processor" key word in the "cpuinfo" on the non-SMP ARM Platforms. So the tracing "ftrace_buffer_size.sh" script would report "division by 0" error, then it would exit soon. The tracing test would check failed when it could not find this script running chrubis
2012-10-15 18:21         ` chrubis
     [not found]           ` <1350443616-20186-1-git-send-email-gaowanlong@cn.fujitsu.com>
2012-10-17  4:31             ` [LTP] [PATCH] tools: add tst_ncpus/_max api to get number of CPUS Mike Frysinger
2012-10-17  7:13               ` Wanlong Gao
2012-10-17 14:09               ` chrubis
2012-10-17 13:00             ` chrubis

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.