This provides common ceph entrypoints for the pthread_[gs]name functions which
will also cache a thread_local copy. This also removes the pthread_t parameter
which precipitated the bug i50743.
Obviously, the overall goal here is to avoid system calls.
See-also: https://tracker.ceph.com/issues/50743
Fixes: 0be8d01c9d
Fixes: https://tracker.ceph.com/issues/68691
Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
* pthread name is saved in a thread_local storage
* the thread_local name is copied into Entry object's ctor
* Log::dump_recent() reads the thread name from the Entry
object's data member when dumping logs
Fixes: https://tracker.ceph.com/issues/50743
Signed-off-by: Milind Changire <mchangir@redhat.com>
Especially when targeting Windows, llvm may not necessarily
use pthreads for std::thread. In this case, we must not use the
"native" thread handle with the pthreads API.
We'll update the ceph_pthread_getname and ceph_pthread_setname
wrappers, adding a new one: ceph_pthread_kill.
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
This reverts commit 41142c93a7.
With g++ 8 noexcept here does more harm than good. See the previous
patch for details.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Under the GNU system, thread cancellation takes the form of an
exception thrown from the cancellation point, so that the stack
unwinds and destructors are called. The thread entrypoints thus have
what is effectively a catch (...) that terminates on everything but
the thread cancellation exception.
Unfortunately this means the stack has been unwound and we have no
backtrace with which to debug.
Wrapping the actual entry point in noexcept means we call terminate
and get our backtrace as soon as the exception is thrown, assuming it
doesn't get caught by something in the middle.
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
4cd2b00d2a allows us to colocate seastar
allocator used by seastar reactors and libc allocator used by alien threads,
there is no need to configure seastar allocator for alien thread
anymore.
this change partially reverts
- f7715b86ef
- b55919071f
Signed-off-by: Kefu Chai <kchai@redhat.com>
Having Thread::create store a pointer to a string that is passed to
ceph_pthread_setname in Thread::entry_wrapper can lead to using a
pointer in the calling thread's stack that gets freed before use.
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
We're going to stub certain modules and functions for Windows builds.
Some of them will be implemented in subsequent commits, some are platform
specific and will be skipped.
Modules:
* module.c
* subprocess.cc
* blkdev.cc
* dns_resolve.cc
* numa.cc
* syslog.h
* statvfs.h
* libblk
* neorados
Functions:
x signal functions
x fork
x chown
* socketpair_cloexec
* dump_open_fds
* run_cmd
* is_symlink
* CInode::d_type
* nbd commands
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
pthread_setname_np() exists on OSX, but it only accepts a sinlge
argument. Defining a two parameters version pthread_setname_np()
does not work.
Signed-off-by: Yan, Zheng <zyan@redhat.com>
If this file is used, it is wise to include it a fist include file
at the top of the code.
Things added to compat.h:
- ENODATA versus ENOATTR
This is a very tricky one since ENOATTR is also defined in boost,
but with a totally diferent value again. We need to make sure
that the same value is used alt all places.
- O_DSYNC(freeBSD) versus O_SYNC(Linux)
fortunately they have the same value.
- HOST_NAME_MAX is undefined in FreeBSD
So hardcoded to the value that Linux uses
- pthread_set_name_np(FreeBSD) versus pthread_setname_np(Linux)
and the NON-Posix code lives in a separate include file
- Some compatiblility code for CLOCK_MONOTONIC_COARSE to rewite
to the FreeBSD equivalent CLOCK_MONOTONIC_FAST
compat.h is added to:
* src/common/Thread.cc
* src/common/obj_bencher.cc
* src/crush/CrushLocation.cc
* src/include/compat.h
* src/include/rados/librados.h
* src/os/filestore/FileStore.cc
* src/test/system/systest_runnable.cc
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
When using setuid/setgid, main thread don't have access to
/proc/self/task/[tid]/comm, which is owned by newly created
thread (root).
To fix this, pthread_setname_np() was moved to newly created
thread, and now it changes name for itself.
Signed-off-by: Igor Podoski <igor.podoski@ts.fujitsu.com>
Adding names to threads simplifies cpu usage realtime tracking
e.g. top -H -p <OSD_PID>
This commit changes Thread.create() method forcing to pass thread name.
Signed-off-by: Igor Podoski <igor.podoski@ts.fujitsu.com>
When a thread attributes object is no longer required, it should be destroyed using the
pthread_attr_destroy() function. Destroying a thread attributes object has no effect on threads that were created using that object.
Fixes: #12570
Signed-off-by: zqkqkz zheng.qiankun@h3c.com
There's no need for mallocing pthread_attr_t in Thread::try_create(),
it can be located on stack as it is freed in same function. This reduces
pressure put on memory manager.
Signed-off-by: Piotr Dałek <piotr.dalek@ts.fujitsu.com>
Ideally, set this before starting the thread. If you set it after, we
could potentially race with create() itself.
Signed-off-by: Sage Weil <sage@inktank.com>
This looks in /proc to count threads. Kludgey and no longer needed.
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
The kernel knows how many threads we have; just ask it. One less atomic
variable to carry around.
We will eventually have to avoid doing this check for non-daemon code,
but that's a separate issue.
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>