[LTP] [PATCH 1/2] [Realtime] hrtimer-prio - Minor fixes and enhancements

2008-03-06 Thread Gilles Carry
- configurable criteria (-m argument)
- configurable iterations
- check stats init return codes

Signed-off-by: Gilles Carry [EMAIL PROTECTED]
Cc: Darren Hart [EMAIL PROTECTED]
Cc: Tim Chavez [EMAIL PROTECTED]
---
 .../realtime/func/hrtimer-prio/hrtimer-prio.c  |   32 +--
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c 
b/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
index 3fdda64..f22ca83 100644
--- a/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
+++ b/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
@@ -49,7 +49,7 @@
 #include libjvmsim.h
 #include libstats.h
 
-#define DEF_MED_PRIO 60// (softirqd-hrtimer,98]
+#define DEF_MED_PRIO 60// (softirqd-hrtimer,98)
 #define DEF_ITERATIONS 1
 #define HIST_BUCKETS 100
 #define DEF_BUSY_TIME 10   // Duration of busy work in milliseconds
@@ -58,10 +58,10 @@
 
 static int run_jvmsim = 0;
 static int med_prio = DEF_MED_PRIO;
-static int high_prio = DEF_MED_PRIO+1;
+static int high_prio;
 static int busy_time = DEF_BUSY_TIME;
 static int iterations = DEF_ITERATIONS;
-static unsigned long criteria = DEF_CRITERIA;  // FIXME: make configurable
+static unsigned long criteria = DEF_CRITERIA;
 static int busy_threads;
 
 static stats_container_t dat;
@@ -78,6 +78,7 @@ void usage(void)
printf(  -i#   #:number of iterations, defaults to %d\n, 
DEF_ITERATIONS);
printf(  -n#   #:number of busy threads, defaults to 
NR_CPUS*2\n);
printf(  -f#   #:rt fifo priority of busy threads (1,98), 
defaults to %d\n, DEF_MED_PRIO);
+   printf(  -m#   #:maximum timer latency in microseconds, 
defaults to %d\n, DEF_CRITERIA);
 }
 
 int parse_args(int c, char *v)
@@ -99,11 +100,12 @@ int parse_args(int c, char *v)
break;
case 'f':
med_prio = MIN(atoi(v), 98);
-   high_prio = med_prio+1;
break;
 case 'i':
-   printf(Setting iterations disabled\n);
-// iterations = atoi(v);
+   iterations = atoi(v);
+break;
+case 'm':
+   criteria = atoi(v);
 break;
 default:
 handled = 0;
@@ -155,7 +157,8 @@ int main(int argc, char *argv[])
int t_id;
setup();
busy_threads = 2 * sysconf(_SC_NPROCESSORS_ONLN); // default 
busy_threads
-   rt_init(f:i:jhn:t:, parse_args, argc, argv);
+   rt_init(f:i:jhn:t:m:, parse_args, argc, argv);
+   high_prio = med_prio + 1;
 
// Set main()'s prio to one above the timer_thread so it is sure to not
// be starved
@@ -183,9 +186,18 @@ int main(int argc, char *argv[])
 
stats_container_t hist;
stats_quantiles_t quantiles;
-   stats_container_init(dat, iterations);
-   stats_container_init(hist, HIST_BUCKETS);
-   stats_quantiles_init(quantiles, (int)log10(iterations));
+   if (stats_container_init(dat, iterations)) {
+   printf(Cannot init stat containers for dat\n);
+   exit(1);
+   }
+   if (stats_container_init(hist, HIST_BUCKETS)) {
+   printf(Cannot init stat containers for hist\n);
+   exit(1);
+   }
+   if (stats_quantiles_init(quantiles, (int)log10(iterations))) {
+   printf(Cannot init stat quantiles\n);
+   exit(1);
+   }
 
t_id = create_fifo_thread(timer_thread, NULL, high_prio);
if (t_id == -1) {
-- 
1.5.4.3.450.gb92176


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[LTP] [PATCH 0/2] [Realtime] hrtimer-prio fixes

2008-03-06 Thread Gilles Carry
Sorry, the previous email thread has a wrong from address.
Please ignore it.

1. Minor fixes:
Added -i to have the number of iterations configurable.
However, this number cannot be less than 100 else a calloc
fails in init_stat* function, causing sigsegv afterward.
The patch also adds the return code checking for these init_stat
functions.

Added -m args is to have the PASS/FAIL criteria configurable.

2. Bug fix: disk write access deadlock
High prio busy thread hogged cpus forbidding kjournald and pdflush
daemons to release filesystem locks. This caused timer_thread to hang
waiting for the lock.



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[LTP] [PATCH 2/2] [Realtime] hrtimer-prio - Add a flag to tell busy threads to exit

2008-03-06 Thread Gilles Carry
This flag is set by timer_thread when the sampling is finished.
This fixes this deadlock/race condition:
1. busy threads run until main thread exits
2. main thread waits for timer_thread to finish
3. timer_thread is writing samples results into
   files and waits for a filesystem global lock to be released
4. sync threads (kjournald, pdflush) with non-rt prio hold
   the above mentioned lock and cannot finish their job because
   cpu is hogged by busy threads.

Solution: tell busy threads to quit before writing to disk.

Signed-off-by: Gilles Carry [EMAIL PROTECTED]
Cc: Darren Hart [EMAIL PROTECTED]
Cc: Tim Chavez [EMAIL PROTECTED]
---
 .../realtime/func/hrtimer-prio/hrtimer-prio.c  |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c 
b/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
index f22ca83..9e051aa 100644
--- a/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
+++ b/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
@@ -63,6 +63,7 @@ static int busy_time = DEF_BUSY_TIME;
 static int iterations = DEF_ITERATIONS;
 static unsigned long criteria = DEF_CRITERIA;
 static int busy_threads;
+static int busy_exit = 0;
 
 static stats_container_t dat;
 static atomic_t busy_threads_started;
@@ -117,7 +118,7 @@ int parse_args(int c, char *v)
 void *busy_thread(void *thread)
 {
atomic_inc(busy_threads_started);
-   while (1) {
+   while (!busy_exit) {
busy_work_ms(busy_time);
sched_yield();
}
@@ -146,6 +147,7 @@ void *timer_thread(void *thread)
max_delta = MAX(max_delta, delta_us);
min_delta = (i == 0) ? delta_us : MIN(min_delta, delta_us);
}
+   busy_exit = 1; // Tell busy_threads to exit.
return NULL;
 }
 
-- 
1.5.4.3.450.gb92176


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


Re: [LTP] [RFC PATCH 0/3] [Realtime] Get rid of autotools

2008-03-06 Thread Sebastien Dugue
On Thu, 6 Mar 2008 01:47:10 +0530 Subrata Modak [EMAIL PROTECTED] wrote:

 On Thu, Mar 6, 2008 at 1:38 AM, Robert Schwebel [EMAIL PROTECTED]
 wrote:
 
  On Thu, Mar 06, 2008 at 01:26:06AM +0530, Subrata Modak wrote:
Robert, would you be willing to ack them after a successful run in
your environment?
  
Chirag or Sudhanshu, can you please apply Sebastien's patches and
ensure they work in our environment?  Then provide Subrata with an
Ack.
  
   Darren,
  
   I did not see anybody acking these Patches. I am on leave, and, hence
   checking/ merging those patches may get delayed. But, nevertheless
   they will be merged in due time.
 
  Did I miss the patches? Can anyone send me a pointer (or the patches)? I
  have everything ready to test them.
 
 
 Sebastien,
 
 Can you please forward those Patches to Robert once again. He might have
 missed them before the Patches entered the Mailing list ??
 

  Sent privately to Robert.

  Regards,

  Sebastien.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


Re: [LTP] [PATCH 2/2] [Realtime] hrtimer-prio - Add a flag to tell busy threads to exit

2008-03-06 Thread Gilles Carry
I made a mistake in the comment.

Main thread is the writer.
So instead, it should be:

This fixes this deadlock/race condition:
1. busy threads run until main thread exits
2. main thread is writing samples results into
   files and waits for a filesystem global lock to be released
4. sync threads (kjournald, pdflush) with non-rt prio hold
   the above mentioned lock and cannot finish their job because
   cpu is hogged by busy threads.

Gilles.


Gilles Carry wrote:
 This flag is set by timer_thread when the sampling is finished.
 This fixes this deadlock/race condition:
   1. busy threads run until main thread exits
   2. main thread waits for timer_thread to finish
   3. timer_thread is writing samples results into
  files and waits for a filesystem global lock to be released
   4. sync threads (kjournald, pdflush) with non-rt prio hold
  the above mentioned lock and cannot finish their job because
  cpu is hogged by busy threads.
 

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[LTP] [RFC PATCH] file capabilities test update

2008-03-06 Thread serge
Below is a patch to update file capabilities tests to work on
64-bit kernels.  It switches from manually setting file xattrs
to making use of libcap.

I'm sending it but sending it as RFC because I'm getting odd
failures which I suspect are due to libcap and no the testcases.
Figure in the meantime I can at least send it out for some
more comments from Andrew.  Andrew, I'm also attaching the
new verify_caps_exec.c verbatim for easier review.

-serge

Signed-off-by: Serge E. Hallyn [EMAIL PROTECTED]
---
 Makefile   |8 +
 makenumcapsh.c |   21 
 verify_caps_exec.c |  225 +
 3 files changed, 121 insertions(+), 133 deletions(-)

diff --git a/testcases/kernel/security/filecaps/Makefile 
b/testcases/kernel/security/filecaps/Makefile
index ec5cf8f..651769b 100644
--- a/testcases/kernel/security/filecaps/Makefile
+++ b/testcases/kernel/security/filecaps/Makefile
@@ -37,9 +37,15 @@ all:
 TARGETS =
 endif
 
+numcaps.h: makenumcapsh.c
+   gcc -o makenumcapsh makenumcapsh.c
+   ./makenumcapsh  numcaps.h
+
+verify_caps_exec: verify_caps_exec.c numcaps.h
+
 INSTALLTARGETS = $(TARGETS) $(SCRIPTS) checkforlibcap
 install: $(INSTALLTARGETS)
@set -e; for i in $(INSTALLTARGETS); do ln -f $$i ../../../bin/$$i ; 
chmod +x ../../../bin/$$i; done
 
 clean:
-   rm -f $(TARGETS) *.o caps_fifo checkforlibcap
+   rm -f $(TARGETS) *.o caps_fifo checkforlibcap numcaps.h makenumcapsh
diff --git a/testcases/kernel/security/filecaps/makenumcapsh.c 
b/testcases/kernel/security/filecaps/makenumcapsh.c
new file mode 100644
index 000..6676176
--- /dev/null
+++ b/testcases/kernel/security/filecaps/makenumcapsh.c
@@ -0,0 +1,21 @@
+#include stdio.h
+#include errno.h
+#include sys/capability.h
+#include sys/prctl.h
+
+#ifndef PR_CAPBSET_READ
+#define PR_CAPBSET_READ 23
+#endif
+
+int main(int argc, char *argv[])
+{
+   int i, ret = 0;
+
+   for (i=0; ret != -1; i++) {
+   ret = prctl(PR_CAPBSET_READ, i);
+   if (ret == -1)
+   break;
+   }
+   printf(#define NUM_CAPS %d\n, i);
+   return 0;
+}
diff --git a/testcases/kernel/security/filecaps/verify_caps_exec.c 
b/testcases/kernel/security/filecaps/verify_caps_exec.c
index 38aa1ad..77f995a 100644
--- a/testcases/kernel/security/filecaps/verify_caps_exec.c
+++ b/testcases/kernel/security/filecaps/verify_caps_exec.c
@@ -21,7 +21,7 @@
  * File: verify_caps_exec.c
  * Author: Serge Hallyn
  * Purpose: perform several tests of file capabilities:
- *  1. try setting caps without CAP_SYS_ADMIN
+ *  1. try setting caps without privilege
  *  2. test proper calculation of pI', pE', and pP'.
  * Try setting valid caps, drop rights, and run the executable,
  * make sure we get the rights
@@ -35,13 +35,14 @@
 #include sys/types.h
 #include sys/stat.h
 #include sys/wait.h
-#include attr/xattr.h
 #include errno.h
 #include fcntl.h
 #include sys/capability.h
 #include sys/prctl.h
 #include test.h
 
+#include numcaps.h
+
 #define TSTPATH ./print_caps
 char *TCID = filecaps;
 int TST_TOTAL=1;
@@ -51,7 +52,7 @@ int errno;
 void usage(char *me)
 {
tst_resm(TFAIL, Usage: %s 0|1 [arg]\n, me);
-   tst_resm(TINFO,   0: set file caps without CAP_SYS_ADMIN\n);
+   tst_resm(TINFO,   0: set file caps without privilegeCAP_SYS_ADMIN\n);
tst_resm(TINFO,   1: test that file caps are set correctly on exec\n);
tst_exit(1);
 }
@@ -63,6 +64,7 @@ void print_my_caps()
 {
cap_t cap = cap_get_proc();
tst_resm(TINFO, \ncaps are %s\n, cap_to_text(cap, NULL));
+   cap_free(cap);
 }
 
 int drop_root(int keep_perms)
@@ -78,52 +80,27 @@ int drop_root(int keep_perms)
tst_exit(4);
}
if (keep_perms) {
-   cap_t cap = cap_from_text(=eip cap_setpcap-eip);
+   cap_t cap = cap_from_text(=eip);
cap_set_proc(cap);
+   cap_free(cap);
}
 
return 1;
 }
 
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define cpu_to_le32(x)  x
-#else
-#define cpu_to_le32(x)  bswap_32(x)
-#endif
-
-/*
- * TODO: find a better way to do this.  Emulate libcap's
- * way, or just take it from linux/capability.h
- */
-/*
- * TODO: accomodate 64-bit capabilities
- */
-#define CAPNAME security.capability
-#ifndef __CAP_BITS
-#define __CAP_BITS 31
-#endif
-
-#define XATTR_CAPS_SZ (3*sizeof(__le32))
-#define VFS_CAP_REVISION_MASK   0xFF00
-#define VFS_CAP_REVISION0x0100
-
-#define VFS_CAP_FLAGS_MASK  ~VFS_CAP_REVISION_MASK
-#define VFS_CAP_FLAGS_EFFECTIVE 0x01
-
 int perms_test(void)
 {
int ret;
-   unsigned int value[3];
-   unsigned int v;
+   cap_t cap;
 
drop_root(DROP_PERMS);
-   v = VFS_CAP_REVISION | VFS_CAP_FLAGS_EFFECTIVE;
-   value[0] = cpu_to_le32(v);
-   value[1] = 1;
-   value[2] = 1;
-   ret = setxattr(TSTPATH, CAPNAME, value, 3*sizeof(unsigned int), 0);
+   cap = cap_from_text(all=eip);

[LTP] [ ltp-Bugs-1908317 ] broken POSIX shell compliance

2008-03-06 Thread SourceForge.net
Bugs item #1908317, was opened at 2008-03-05 15:16
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=103382aid=1908317group_id=3382

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Dustin Kirkland (dustin_kirkland)
Assigned to: Nobody/Anonymous (nobody)
Summary: broken POSIX shell compliance

Initial Comment:
runltp will not execute on a POSIX-compliant shell (dash).

See patch provided:
https://sourceforge.net/tracker/index.php?func=detailaid=1908313group_id=3382atid=303382



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=103382aid=1908317group_id=3382

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[LTP] [PATCH] [CONCURRENCY] shmctl02

2008-03-06 Thread Renaud Lottiaux
Hi !

This patch fixes a concurrency issue in shmctl02. Same issue as
in shmat02 : 

R.

-- 
Renaud Lottiaux

Kerlabs
Bâtiment Germanium
80, avenue des buttes de Coësmes
35700 Rennes - France
Phone : (+33|0)6 80 89 19 34
Fax   : (+33|0)2 99 84 71 71
Email : [EMAIL PROTECTED]
Web   : http://www.kerlabs.com/
Index: cvs/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
===
--- cvs.orig/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c	2008-03-06 17:54:54.0 +0100
+++ cvs/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c	2008-03-06 18:00:52.0 +0100
@@ -47,6 +47,10 @@
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *
+ *  06/03/2008 Renaud Lottiaux ([EMAIL PROTECTED])
+ *  - Fix concurrency issue. The second key used for this test could
+ *conflict with the key from another task.
+ *
  * RESTRICTIONS
  *	none
  */
@@ -159,6 +163,8 @@
 void
 setup(void)
 {
+	key_t shmkey2;
+
 	/* Switch to nobody user for correct error code collection */
 if (geteuid() != 0) {
 tst_brkm(TBROK, tst_exit, Test must be run as root);
@@ -197,8 +203,16 @@
 			 segment #1 in setup());
 	}
 
+	/* Get an new IPC resource key. Since there is a small chance the
+	 * getipckey() function returns the same key as the previous one,
+	 * loop until we have a different key.
+	 */
+	do {
+		shmkey2 = getipckey();
+	} while (shmkey2 == shmkey);
+
 	/* create a shared memory segment with read and write permissions */
-	if ((shm_id_2 = shmget(shmkey + 1, SHM_SIZE, IPC_CREAT | IPC_EXCL |
+	if ((shm_id_2 = shmget(shmkey2, SHM_SIZE, IPC_CREAT | IPC_EXCL |
 	 SHM_RW)) == -1) {
 		tst_brkm(TBROK, cleanup, couldn't create shared memory 
 			 segment #2 in setup());


signature.asc
Description: This is a digitally signed message part.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[LTP] [PATCH] shmdt01

2008-03-06 Thread Renaud Lottiaux
Hi !

This patch fix return value check from shmat. In case of error, this
wrong check was leading to a seg-fault.
Same problem as in kill05.

R.

-- 
Renaud Lottiaux

Kerlabs
Bâtiment Germanium
80, avenue des buttes de Coësmes
35700 Rennes - France
Phone : (+33|0)6 80 89 19 34
Fax   : (+33|0)2 99 84 71 71
Email : [EMAIL PROTECTED]
Web   : http://www.kerlabs.com/
Index: cvs/testcases/kernel/syscalls/ipc/shmdt/shmdt01.c
===
--- cvs.orig/testcases/kernel/syscalls/ipc/shmdt/shmdt01.c	2008-03-06 18:09:48.0 +0100
+++ cvs/testcases/kernel/syscalls/ipc/shmdt/shmdt01.c	2008-03-06 18:11:28.0 +0100
@@ -52,6 +52,10 @@
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *
+ *  06/03/2008 Renaud Lottiaux ([EMAIL PROTECTED])
+ *  - Fix wrong return value check on shmat system call (leading to 
+ *segfault in case of error with this syscall).
+ *
  * RESTRICTIONS
  *	none
  */
@@ -111,7 +115,7 @@
 		/* reattach the shared memory segment in case we are looping */
 		shared = (int *)shmat(shm_id_1, 0, 0);
 
-		if (*shared == -1) {
+		if (shared == (void *)-1) {
 			tst_brkm(TBROK, cleanup, memory reattach failed);
 		}
 
@@ -216,7 +220,7 @@
 	/* attach the shared memory segment */
 	shared = (int *)shmat(shm_id_1, 0, 0);
 
-	if (*shared == -1) {
+	if (shared == (void *)-1) {
 		tst_brkm(TBROK, cleanup, Couldn't attach shared memory);
 	}
 


signature.asc
Description: This is a digitally signed message part.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


Re: [LTP] [RFC PATCH] file capabilities test update

2008-03-06 Thread Serge E. Hallyn
Quoting Andrew G. Morgan ([EMAIL PROTECTED]):
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 [EMAIL PROTECTED] wrote:
 | Figure in the meantime I can at least send it out for some
 | more comments from Andrew.  Andrew, I'm also attaching the
 | new verify_caps_exec.c verbatim for easier review.
 
 Thanks.
 
 As per email to Chris F. the 'all' shorthand in 2.07 is broken when
 running on 32-bit capabilities systems. I've fixed it in the git tree,
 but need to make a 2.08 to release that fix. Perhaps this is related to
 your problem?

2.08 doesn't fix that problem for me.

At this point my best bet is probably to shift to another machine
with different userspace setup.  Will try to do that soon.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list