* [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c
@ 2011-12-23 5:48 Song.Li
2011-12-29 19:30 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Song.Li @ 2011-12-23 5:48 UTC (permalink / raw)
To: ltp-list
From: LiSong <Song.Li@windriver.com>
There is no guarantee that the LOOP of the child proecess
can be certainly big enough on any device at any time.
So if set_affinity function is available,
use it to bind the test processes to a single CPU
rather than using the LOOP.
Signed-off-by: Song.Li <Song.Li@windriver.com>
---
.../conformance/interfaces/sched_setparam/2-1.c | 26 +++++++++++++++----
.../conformance/interfaces/sched_setparam/2-2.c | 26 +++++++++++++++----
2 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c
index c548dd4..93f6443 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c
@@ -29,6 +29,7 @@
*
*/
+#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <signal.h>
@@ -48,6 +49,8 @@
# include <sys/pstat.h>
#endif
+#include <affinity.h>
+
#define NB_LOOP 20000000
#define NB_LOOP_CHILD 200000000 /* shall be much greater than NB_LOOP */
@@ -119,11 +122,22 @@ int main() {
int *child_pid;
float ratio;
- nb_child = get_ncpu();
- if (nb_child == -1) {
- printf("Can not get the number of CPUs of your machine.\n");
- return PTS_UNRESOLVED;
- }
+ /* Only use a single CPU and one child process when set_affinity is availaible
+ It's because no matter what value of the counter is set to,
+ There is no guarantee that the LOOP of the child can be certainly big enough on any device at any time.
+ */
+ int rc = set_affinity(0);
+ if (rc) {
+ nb_child = get_ncpu();
+ if (nb_child == -1) {
+ printf("Can not get the number of CPUs of your machine.\n");
+ return PTS_UNRESOLVED;
+ }
+ }
+ else {
+ nb_child = 1;
+ }
+
child_pid = malloc(nb_child);
param.sched_priority = (sched_get_priority_min(SCHED_FIFO) +
@@ -208,4 +222,4 @@ int main() {
return PTS_UNRESOLVED;
}
-}
\ No newline at end of file
+}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c
index 2b71893..c17c5b6 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c
@@ -29,6 +29,7 @@
*
*/
+#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <signal.h>
@@ -48,6 +49,8 @@
# include <sys/pstat.h>
#endif
+#include <affinity.h>
+
#define NB_LOOP 20000000
#define NB_LOOP_CHILD 200000000 /* shall be much greater than NB_LOOP */
@@ -119,16 +122,27 @@ int main() {
int *child_pid;
float ratio;
- nb_child = get_ncpu();
- if (nb_child == -1) {
- printf("Can not get the number of CPUs of your machine.\n");
- return PTS_UNRESOLVED;
- }
+ /* Only use a single CPU and one child process when set_affinity is availaible
+ It's because no matter what value of the counter is set to,
+ There is no guarantee that the LOOP of the child can be certainly big enough on any device at any time.
+ */
+ int rc = set_affinity(0);
+ if (rc) {
+ nb_child = get_ncpu();
+ if (nb_child == -1) {
+ printf("Can not get the number of CPUs of your machine.\n");
+ return PTS_UNRESOLVED;
+ }
+ }
+ else {
+ nb_child = 1;
+ }
child_pid = malloc(nb_child);
if (child_pid == NULL) {
printf("malloc failed\n");
return PTS_UNRESOLVED;
}
+
param.sched_priority = (sched_get_priority_min(SCHED_RR) +
sched_get_priority_max(SCHED_RR)) / 2;
@@ -211,4 +225,4 @@ int main() {
return PTS_UNRESOLVED;
}
-}
\ No newline at end of file
+}
--
1.7.5.4
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c
2011-12-23 5:48 [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c Song.Li
@ 2011-12-29 19:30 ` Cyril Hrubis
2011-12-29 19:32 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2011-12-29 19:30 UTC (permalink / raw)
To: Song.Li; +Cc: ltp-list
Hi!
> There is no guarantee that the LOOP of the child proecess
> can be certainly big enough on any device at any time.
> So if set_affinity function is available,
> use it to bind the test processes to a single CPU
> rather than using the LOOP.
The patch logic is looking good, there are some style problems though.
Please use checkpatch.pl (that is packed with linux kernel) and resend.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c
2011-12-29 19:30 ` Cyril Hrubis
@ 2011-12-29 19:32 ` Cyril Hrubis
0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2011-12-29 19:32 UTC (permalink / raw)
To: Song.Li; +Cc: ltp-list
Hi!
> > There is no guarantee that the LOOP of the child proecess
> > can be certainly big enough on any device at any time.
> > So if set_affinity function is available,
> > use it to bind the test processes to a single CPU
> > rather than using the LOOP.
>
> The patch logic is looking good, there are some style problems though.
>
> Please use checkpatch.pl (that is packed with linux kernel) and resend.
And also I would suggest moving the get_ncpu() into common header just
as the affinity is (in another patch).
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c
@ 2011-12-30 6:52 Song.Li
2011-12-30 12:24 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Song.Li @ 2011-12-30 6:52 UTC (permalink / raw)
To: ltp-list
From: LiSong <Song.Li@windriver.com>
There is no guarantee that the LOOP of the child proecess
can be certainly big enough on any device at any time.
So if set_affinity function is available,
use it to bind the test processes to a single CPU
rather than using the LOOP.
Signed-off-by: Song.Li <Song.Li@windriver.com>
---
.../conformance/interfaces/sched_setparam/2-1.c | 26 ++++++++++++++++----
.../conformance/interfaces/sched_setparam/2-2.c | 26 ++++++++++++++++----
2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c
index c548dd4..2d20f9f 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c
@@ -29,6 +29,7 @@
*
*/
+#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <signal.h>
@@ -48,6 +49,8 @@
# include <sys/pstat.h>
#endif
+#include <affinity.h>
+
#define NB_LOOP 20000000
#define NB_LOOP_CHILD 200000000 /* shall be much greater than NB_LOOP */
@@ -119,11 +122,24 @@ int main() {
int *child_pid;
float ratio;
- nb_child = get_ncpu();
- if (nb_child == -1) {
- printf("Can not get the number of CPUs of your machine.\n");
- return PTS_UNRESOLVED;
+ /* Only use a single CPU and one child process
+ when set_affinity is availaible.It's because
+ no matter what value of the counter is set to,
+ There is no guarantee that the LOOP of the child
+ can be certainly big enough on any device at any time.
+ */
+ int rc = set_affinity(0);
+ if (rc) {
+ nb_child = get_ncpu();
+ if (nb_child == -1) {
+ printf("Can not get the number of"
+ "CPUs of your machine.\n");
+ return PTS_UNRESOLVED;
+ }
+ } else {
+ nb_child = 1;
}
+
child_pid = malloc(nb_child);
param.sched_priority = (sched_get_priority_min(SCHED_FIFO) +
@@ -208,4 +224,4 @@ int main() {
return PTS_UNRESOLVED;
}
-}
\ No newline at end of file
+}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c
index 2b71893..08cdc34 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c
@@ -29,6 +29,7 @@
*
*/
+#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <signal.h>
@@ -48,6 +49,8 @@
# include <sys/pstat.h>
#endif
+#include <affinity.h>
+
#define NB_LOOP 20000000
#define NB_LOOP_CHILD 200000000 /* shall be much greater than NB_LOOP */
@@ -119,11 +122,24 @@ int main() {
int *child_pid;
float ratio;
- nb_child = get_ncpu();
- if (nb_child == -1) {
- printf("Can not get the number of CPUs of your machine.\n");
- return PTS_UNRESOLVED;
+ /* Only use a single CPU and one child process
+ when set_affinity is availaible.It's because
+ no matter what value of the counter is set to,
+ There is no guarantee that the LOOP of the child
+ can be certainly big enough on any device at any time.
+ */
+ int rc = set_affinity(0);
+ if (rc) {
+ nb_child = get_ncpu();
+ if (nb_child == -1) {
+ printf("Can not get the number of"
+ "CPUs of your machine.\n");
+ return PTS_UNRESOLVED;
+ }
+ } else {
+ nb_child = 1;
}
+
child_pid = malloc(nb_child);
if (child_pid == NULL) {
printf("malloc failed\n");
@@ -211,4 +227,4 @@ int main() {
return PTS_UNRESOLVED;
}
-}
\ No newline at end of file
+}
--
1.7.5.4
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c
2011-12-30 6:52 Song.Li
@ 2011-12-30 12:24 ` Cyril Hrubis
0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2011-12-30 12:24 UTC (permalink / raw)
To: Song.Li; +Cc: ltp-list
Hi!
> There is no guarantee that the LOOP of the child proecess
> can be certainly big enough on any device at any time.
> So if set_affinity function is available,
> use it to bind the test processes to a single CPU
> rather than using the LOOP.
>
> Signed-off-by: Song.Li <Song.Li@windriver.com>
Commited, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-30 12:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-23 5:48 [LTP] [PATCH] sched_setparam/2-1.c and sched_setparam/2-2.c Song.Li
2011-12-29 19:30 ` Cyril Hrubis
2011-12-29 19:32 ` Cyril Hrubis
-- strict thread matches above, loose matches on Subject: below --
2011-12-30 6:52 Song.Li
2011-12-30 12:24 ` Cyril Hrubis
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.