This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Add test for pthread_setname_np and pthread_getname_np.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: Allan McRae <allan at archlinux dot org>, Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>, libc-alpha at sourceware dot org
- Date: Wed, 05 Feb 2014 10:14:11 -0500
- Subject: Re: [PATCH] Add test for pthread_setname_np and pthread_getname_np.
- Authentication-results: sourceware.org; auth=none
- References: <52A6AF89 dot 6040903 at redhat dot com> <1386689266 dot 23049 dot 3227 dot camel at triegel dot csb> <52A94EAC dot 5020800 at redhat dot com> <52A957D3 dot 5090809 at redhat dot com> <52AF01B9 dot 4090601 at linux dot vnet dot ibm dot com> <52F064E6 dot 8020901 at redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1402041414581 dot 18044 at digraph dot polyomino dot org dot uk> <52F1ADD3 dot 50200 at redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1402051456020 dot 5367 at digraph dot polyomino dot org dot uk>
On 02/05/2014 10:00 AM, Joseph S. Myers wrote:
> On Tue, 4 Feb 2014, Carlos O'Donell wrote:
>
>> diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
>> index 3723535..d59531c 100644
>> --- a/sysdeps/unix/sysv/linux/kernel-features.h
>> +++ b/sysdeps/unix/sysv/linux/kernel-features.h
>> @@ -199,7 +199,10 @@
>>
>> /* Support for the recvmmsg syscall was added in 2.6.33. */
>> #if __LINUX_KERNEL_VERSION >= 0x020621
>> -# define __ASSUME_RECVMMSG 1
>> +# define __ASSUME_RECVMMSG 1
>> +/* Assume that /proc/self/task/$tid/comm and /proc/$pid/task/$tid/comm
>> + exist. */
>> +# define __ASSUME_PROC_PID_TASK_COMM 1
>> #endif
>
> This does not belong under the recvmmsg conditional; they should have
> separate #if conditionals, each with its own comment.
>
> (It seems quite likely recvmmsg could have the same issue as accept4, with
> that macro needing splitting into three, as discussed for accept4 in
> <https://sourceware.org/ml/libc-alpha/2013-12/msg00014.html>; all of
> accept4, recvmmsg and sendmmsg follow the same pattern of, depending on
> the architecture, possibly being implemented through socketcall, a more
> specific syscall or both, with the potential for a syscall being added
> later than the socketcall support. After moving the minimum to 2.6.32 I'm
> thinking of reviewing the remaining __ASSUME_* macros properly.)
Thanks, I've checked this in.
/
2014-02-05 Carlos O'Donell <carlos@rehdat.com>
* sysdeps/unix/sysv/linux/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x020621]
(__ASSUME_PROC_PID_TASK_COMM): Define.
nptl/
2014-02-05 Carlos O'Donell <carlos@redhat.com>
* sysdeps/unix/sysv/linux/tst-setgetname.c (do_test): Skip the
test if !__ASSUME_PROC_PID_TASK_COMM and get_self_comm returns
ENOENT.
diff --git a/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c b/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
index 2aceba5..f5693e2 100644
--- a/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
+++ b/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <kernel-features.h>
/* New name of process. */
#define NEW_NAME "setname"
@@ -99,6 +100,19 @@ do_test (int argc, char **argv)
if (res == 0)
{
res = get_self_comm (gettid (), name_check, TASK_COMM_LEN);
+
+#if !__ASSUME_PROC_PID_TASK_COMM
+ /* On this first test we look for ENOENT to be returned from
+ get_self_comm to indicate that the kernel is older than
+ 2.6.33 and doesn't contain comm within the proc structure.
+ In that case we skip the entire test. */
+ if (res == ENOENT)
+ {
+ printf ("SKIP: The kernel does not have /proc/self/task/%%lu/comm.\n");
+ return 0;
+ }
+#endif
+
if (res == 0)
{
if (strncmp (name, name_check, strlen (BIG_NAME)) == 0)
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 3723535..aabf69d 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -202,6 +202,12 @@
# define __ASSUME_RECVMMSG 1
#endif
+/* Support for /proc/self/task/$tid/comm and /proc/$pid/task/$tid/comm were
+ added in 2.6.33. */
+#if __LINUX_KERNEL_VERSION >= 0x020621
+# define __ASSUME_PROC_PID_TASK_COMM 1
+#endif
+
/* statfs fills in f_flags since 2.6.36. */
#if __LINUX_KERNEL_VERSION >= 0x020624
# define __ASSUME_STATFS_F_FLAGS 1
---
Cheers,
Carlos.