Skip to contentSkip to conversation

userspace-rcu test scripts patches (was: ports/168339: [patch] sysutils/userspace-rcu update to 0.7.2

DISCUSSION Hirohisa Yamaguchi 1 participant 2 messages May 28, 2012 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 86mx4tn165.wl%[email protected]

A message that is not in the archive (sent off-list or not yet received): 20120527184255.GA14719@Krystal

#2 lore raw

Hi, Mathieu

Thanks for your comments.

At Sun, 27 May 2012 14:42:55 -0400,

Quoted 10 lines · Mathieu Desnoyers
Quoted 2 lines

The changes for FreeBSD in test scripts are mainly consists of following:

This brings an interesting point: all the tests scripts start with "#!/bin/sh", but use bash-isms. I guess the first question would be:
should be simply choose make test execution depend on bash (and push #!/bin/bash prefix), since this is only needed for tests provided with the package sources, and not needed for deployment of the library on systems ? Of course, dependency on bash for in-source-tree tests would have to be documented in the README.

I think there're two different purposes of tests:
1. for developers to ensure the implementations are correct
2. for users to see his/her environment is safe to use the feature -- built without an error does not mean it runs okay

I think bashisms do not suit for latter purpose.

Quoted 4 lines
Quoted 2 lines

1. time(1) in FreeBSD does not have long argument name:

    change --append to -a and --output to -o

I will pull this change. See commit
383dac33797fd0858d6858527324a6a15aa06c09

thanks

Quoted 4 lines
Quoted 2 lines

2. ash (i.e. /bin/sh in FreeBSD) does not have += operator:

    replace a+="b" to a="${a}b"

The question on whether we specifically go for bash for in-source-tree test scripts needs to be cleared before I proceed to this change.

If the test scripts are not written for all users, there's no problem when its shown in a document or somewhere.

Quoted 10 lines
Quoted 2 lines

3. BSD flavoured system have jot(1) instead of seq(1). manual of jot(1) can be read at http://man.freebsd.org/jot/1

For some reason, "seq" is installed on my FreeBSD 9.0 system, but not on my 8.2. We could implement a seq-wrapper.sh in tests/ that can be sourced by test shell scripts which would use the right seq implementation underneath (and change the parameters accordingly).

Quoted 1 line

4. ash does not have PIPESTATUS:

Should decide for bash or sh first.

I agree, as I've mentioned above.

Quoted 6 lines
Quoted 1 line

5. NUM_CPUS might be determined at runtime:

So I would recommend making this a
parameter, and autodetect only if no parameter is provided. The autodetect would indeed have to be OS-specific. We could implement a get_nr_cpu.sh script within tests/ that detects the number of CPUs on the current OS.

That sounds good.

At Sun, 27 May 2012 15:44:12 -0400,

Quoted 7 lines · Mathieu Desnoyers

* Mathieu Desnoyers ([email protected]) wrote:
[...]

Quoted 2 lines
Quoted 2 lines

# btw, test_perthreadlock under FreeBSD 10-CURRENT always fails # (releases prior to 9.0 are okay).

-> I guess you mean "releases up to, and including 9.0, are OK".

Ah, yes.

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

# The change in FreeBSD libthr might cause the error. # I haven't looked into it yet.

What are the details of your test invokation ? (how many reader/writer threads, how many cores do you have ? Is this on hardware or virtualized ?)

Actually, the most interesting thing to know here would be your architecture. Moreover, as a hint, the fact that the problem seems to only arise in the perthreadlock test, which generates a lot of contention when the writer takes all the reader locks, I would guess that the bug would sit somewhere in the contention handling code, which could be either at the user-space library or kernel-level side.

I've found the error first on a build farm called redports.org, which is opened for FreeBSD port maintainers to run build and tests. I'm not sure the architecture of the build farm, but some test shows it runs on Phenom II X6 1075T. There's no way to know it is on hardware or virtualized.
# The test on the build farm ran with NUM_CPUS=6, I don't have logs # currently since they're expired.
Any parameters in runall.sh lead to error.

My box that reproduce the error is a VMware guest on my MacBook.
# Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
It is a dual-core CPU, and I ran the tests with NUM_CPUS=2.

I attach a backtrace of a corefile when I ran:
test_perthreadlock 1 1 10 -d 0 -b 32768
I only have stripped libthr in my environment, I haven't managed to build one.

Regards,

Signature · 2 lines
	Hirohisa Yamaguchi
	  [email protected]

GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "amd64-marcel-freebsd"...
Core was generated by `test_perthreadlock'.
Program terminated with signal 10, Bus error.
Reading symbols from /lib/libthr.so.3...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x000000080082d09b in pthread_mutex_lock () from /lib/libthr.so.3 (gdb) info thread

  3 process 100144  0x0000000800b3207c in nanosleep () from /lib/libc.so.7
  2 process 101026  0x0000000800826b90 in pthread_create () from /lib/libthr.so.3
* 1 process 101025  0x000000080082d09b in pthread_mutex_lock () from /lib/libthr.so.3

(gdb) thread apply all bt full

Thread 3 (process 100144):
#0 0x0000000800b3207c in nanosleep () from /lib/libc.so.7
No symbol table info available.
#1 0x0000000800a952e8 in sleep () from /lib/libc.so.7
No symbol table info available.
#2 0x0000000800828e18 in sleep () from /lib/libthr.so.3
No symbol table info available.
#3 0x00000000004011a8 in main (argc=1, argv=0x7fffffffda90) at test_perthreadlock.c:397
err =
Thread 2 (process 101026):
#0 0x0000000800826b90 in pthread_create () from /lib/libthr.so.3
No symbol table info available.
#1 0x0000000000000000 in ?? ()
No symbol table info available.

Thread 1 (process 101025):
#0 0x000000080082d09b in pthread_mutex_lock () from /lib/libthr.so.3 No symbol table info available.
#1 0x00000000004016a3 in thr_reader (data=) at test_perthreadlock.c:211

	tidx = 0
	__func__ = "thr_reader"

#2 0x0000000800826cdd in pthread_create () from /lib/libthr.so.3 No symbol table info available.
#3 0x0000000000000000 in ?? ()
No symbol table info available.
(gdb) q

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): 867gvxgmuf.wl%[email protected]

A message that is not in the archive (sent off-list or not yet received): 20120528150036.GA17067@Krystal

#5 lore raw

Hi,

At Mon, 28 May 2012 11:00:36 -0400,

Quoted 10 lines · Mathieu Desnoyers
Quoted 6 lines

I think there're two different purposes of tests:
1. for developers to ensure the implementations are correct
2. for users to see his/her environment is safe to use the feature -- built without an error does not mean it runs okay

I think bashisms do not suit for latter purpose.

I agree that we should not depend on "bash" for any script installed into the system.

Quoted 7 lines

However, the "tests/" subdirectory is not currently installed on the user system. It's only used for in-tree testing, and "make check" execution.

There might come a point where we want to deploy some tests into the system so the library users can run them, I don't know. Maybe not yet though, as we would need to clean them up first.

I meant `users' to be a person who wants to port the product to his/her environment or maintain package of the product.

I doubt that end users such as one who brings binaries from the OS's package repository would run the test scripts when they're installed into the system.

Quoted 2 lines

So at this stage, I would be fine with specifying in the README that running tests depends on bash.

I understand.

Quoted 28 lines

However, if we can provide a wrapper for
all the commands we need, which would be sourced by all scripts in the tests/ directory, which implements all wrappers into per-wrapper files, sourced by one toplevel wrapper file, I would be open to that too, given that it would make deployment of tests simpler for systems lacking bash support. e.g.

tests/wrapper/all.sh

           . wrapper/seq.sh
           .....

tests/wrapper/seq.sh
tests/wrapper/....

each test script:

#!/bin/sh
. wrapper/all.sh

.....

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

5. NUM_CPUS might be determined at runtime:

So I would recommend making this a
parameter, and autodetect only if no parameter is provided. The autodetect would indeed have to be OS-specific. We could implement a get_nr_cpu.sh script within tests/ that detects the number of CPUs on the current OS.

Quoted 3 lines
Quoted 1 line

That sounds good.

Can you prepare a patch for this ?

I'll try next weekend.

Quoted 4 lines
Quoted 4 lines

At Sun, 27 May 2012 15:44:12 -0400,

Quoted 2 lines · Mathieu Desnoyers
Quoted 2 lines
Quoted 2 lines

# btw, test_perthreadlock under FreeBSD 10-CURRENT always fails # (releases prior to 9.0 are okay).

[...]

Quoted 2 lines

OK, so it seems to be reproducible on both AMD and Intel, that's good news.

I observed the error on both 32bits and 64bits, to add.

Quoted 7 lines

You might want to compile userspace rcu with:

make CFLAGS=-g

to get debug symbols for the library. It will provide a more helpful backtrace. We should consider that the issue can come from a race between pthread_create and pthread_mutex_lock too.

Here's another log file.
https://gist.github.com/2821618

I've built urcu with -g flag but, there still seems to be some problem getting backtrace.

Regards,
--

Hirohisa Yamaguchi
[email protected]