Skip to contentSkip to conversation

redefine NCPU = sysconf(_SC_NPROCESSORS_CONF)

PATCH In review Shang Yanfeng 2 participants 8 messages Dec 20, 2011 – Jan 4, 2012 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 redefine NCPU = sysconf(_SC_NPROCESSORS_CONF)

testcase create NCPU=4 threads running with a high priority with the same sched policy and one with a low-priority. The low-priority thread should not run until the other threads stop running, unless the machine has more than NCPU processors when cpu core >4,testcase failed. redefine NCPU = sysconf(_SC_NPROCESSORS_CONF)

---
 .../conformance/interfaces/pthread_create/1-6.c    |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/1-6.c +2 -2
index 5424439..932367a 100644
@@ -78,7 +78,7 @@
 #endif
 
 /* The value below shall be >= to the # of CPU on the test architecture */
-#define NCPU 	(4)
+#define NCPU sysconf(_SC_NPROCESSORS_CONF) 
 
 /********************************************************************************************/
 /***********************************    Test cases  *****************************************/
@@ -274,4 +274,4 @@ void * threaded (void * arg)
 	if (ret == -1)  {  UNRESOLVED(errno, "Failed to post the semaphore");  }
 
 	return arg;
-}
\ No newline at end of file
+}
Signature · 13 lines
1.6.3.1


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

Quoted 4 lines

testcase create NCPU=4 threads running with a high priority with the same sched policy and one with a low-priority. The low-priority thread should not run until the other threads stop running, unless the machine has more than NCPU processors when cpu core >4,testcase failed. redefine NCPU = sysconf(_SC_NPROCESSORS_CONF)

There are two problems with that. The first one, and less problematic, is that _SC_NPROCESSORS_CONF is not yet POSIX standardized.

The second and more problematic part is that such process would eat all your CPU time, which may easily lock the whole box while testing.

I think that best solution for this is to use affinity (which is not standartized by POSIX either, but at least the code is isolated in one header in open_posix_testsuite/include/) to lock two test threads on one CPU.

See conformance/interfaces/sched_yield/1-1.c and include/affinity.h in open_posix_testsuite as an example.

And if you choose to rewrite the test, please remove the usage of testfrmw.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw
In reply to a message not in the archive

Hi!

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

testcase create NCPU=4 threads running with a high priority with the same sched policy and one with a low-priority. The low-priority thread should not run until the other threads stop running, unless the machine has more than NCPU

processors

Quoted 1 line

when cpu core >4,testcase failed. redefine NCPU =

sysconf(_SC_NPROCESSORS_CONF)

There are two problems with that. The first one, and less problematic, is that _SC_NPROCESSORS_CONF is not yet POSIX standardized.

I think using cat /proc/cpuinfo get core number is better.

That won't work. Not only the /proc/ filesystem is not standartized by POSIX, there is no /proc/ in other unixes.

The sysconf() is more common, it's not standartized either, but at least it seems to work on newer unixes.

Quoted 3 lines
Quoted 2 lines

The second and more problematic part is that such process would eat all your CPU time, which may easily lock the whole box while testing.

I test this case on many kinds of board(arm,mips,x86,ppc), no lock issue.

It may work most of the time, but my expirience with realtime threadd and schedulling is that you will burn sooner or later when you do more realtime threads that is a number of your cores. Expecially if these threads are cycling in infinite loop.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#5 lore raw
In reply to a message not in the archive

Hi!

Quoted 5 lines
Quoted 2 lines

I think using cat /proc/cpuinfo get core number is better.

But /proc/cpuinfo may not be supported by other OS.

Yes, procfs is linux specific.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#7 lore raw
In reply to a message not in the archive

Hi!

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I think using cat /proc/cpuinfo get core number is better.

But /proc/cpuinfo may not be supported by other OS.

Yes, procfs is linux specific.

no, it's not. but much of the stuff that linux puts under /proc is Linux specific like "cpuinfo". in fact, the format of "cpuinfo" under Linux tends to change based on the arch you're running on ...

Ah, right, I didn't know that procfs was there before Linux (anyway most of the systems store process exports only related data there at least google suggets that), but still it's not good idea not to use cpuinfo in open posix testsuite...

Quoted 4 lines

since this patch is against the open_posix_testsuite, we need to stick to POSIX APIs (although, the forking of open_posix_testsuite in ltp is pretty awful in general). if it were against a different tree, then not caring about non-Linux would be fine.

Well, the open posix testsuite project seems to be dead for some time (at least four years) so having fork is only natural. Do you know some of the original authors? Maybe we can just ask them to update the sf.net pages to redirect people to LTP.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#9 lore raw
In reply to a message not in the archive

Hi!

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

since this patch is against the open_posix_testsuite, we need to stick to POSIX APIs (although, the forking of open_posix_testsuite in ltp is pretty awful in general). if it were against a different tree, then not caring about non-Linux would be fine.

Quoted 7 lines
Quoted 4 lines

Well, the open posix testsuite project seems to be dead for some time (at least four years) so having fork is only natural. Do you know some of the original authors? Maybe we can just ask them to update the sf.net pages to redirect people to LTP.

if the maintainers opened up access, i think it'd make more sense to divest LTP of the testsuite and merge all our local changes back.

I would disagree here. This would possibly add burden of maitaing the code in two places, simple redirect to forked project is better solution here.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#11 lore raw
In reply to a message not in the archive

Hi!

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Well, the open posix testsuite project seems to be dead for some time (at least four years) so having fork is only natural. Do you know some of the original authors? Maybe we can just ask them to update the sf.net pages to redirect people to LTP.

if the maintainers opened up access, i think it'd make more sense to divest LTP of the testsuite and merge all our local changes back.

Quoted 7 lines
Quoted 3 lines

I would disagree here. This would possibly add burden of maitaing the code in two places, simple redirect to forked project is better solution here.

Except at one point in time the other SF project was considered
the defacto standard. Makes me wonder how many replicas of the project there are out there...

Anyway first thing to do is to try to contact the original authors and ask for their opinions.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#13 lore raw
In reply to a message not in the archive

Hi!

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

Well, the open posix testsuite project seems to be dead for some time (at least four years) so having fork is only natural. Do you know some of the original authors? Maybe we can just ask them to update the sf.net pages to redirect people to LTP.

if the maintainers opened up access, i think it'd make more sense to divest LTP of the testsuite and merge all our local changes back.

I would disagree here. This would possibly add burden of maitaing the code in two places, simple redirect to forked project is better solution here.

Quoted 5 lines

no it wouldn't. the implication would be that LTP would no longer duplicate the code base in the LTP tree. it makes no sense.

if people want it as part of the LTP release, well that still is trivial to
do: have the open posix testsuite be a git submodule in the LTP git repo.

Ah, sorry for my misunderstanding, moving it there makes more sense than having it in both places. But still then people would send patches against it to the LTP mailing list (which is not problem as far as there are some people who are maitaining both projects).

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list