Skip to content

RFC Non disruptive application core dump infrastructure

Janani Venkataraman lkml util-linux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest33 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/33Configure and Make filesMakefile.am configure.ac+9 -00 replies
2/33Validity of argumentsMakefile.am configure.ac src/Makefile.am +1 more+113 -20 replies
3/33Process Statussrc/Makefile.am src/coredump.c src/coredump.h +1 more+104 -10 replies
4/33Hold threadssrc/coredump.c src/coredump.h src/proc.c+210 -13 replies
5/33Fetching Memory mapssrc/coredump.c src/coredump.h src/proc.c+114 -00 replies
6/33Check ELF classsrc/coredump.c src/coredump.h src/proc.c+51 -00 replies
7/33Do elf_coredumpsrc/Makefile.am src/coredump.c src/elf.c +2 more+107 -10 replies
8/33Fills elf headersrc/coredump.c src/coredump.h src/elf.c +2 more+108 -00 replies
9/33Adding notes infrastructuresrc/coredump.c src/coredump.h src/elf.c +2 more+103 -00 replies
10/33Populates PRPS infosrc/coredump.h src/elf-compat.h src/elf.c +2 more+118 -00 replies
11/33Populate AUXVsrc/elf.c+73 -00 replies
12/33Fetch File mapssrc/elf.c src/elf32.c src/elf64.c+80 -00 replies
13/33Fetching thread specific Notessrc/coredump.h src/elf-compat.h src/elf.c +2 more+283 -10 replies
14/33Populating Program Headerssrc/coredump.c src/coredump.h src/elf.c +2 more+119 -00 replies
15/33Updating Offsetsrc/elf.c+49 -10 replies
16/33Writing to core filesrc/coredump.c src/coredump.h src/elf.c+76 -00 replies
17/33Daemonizing the Processsrc/coredump.c+35 -00 replies
18/33Socket operationssrc/Makefile.am src/coredump.c+112 -10 replies
19/33Block till requestsrc/coredump.c+45 -00 replies
20/33Handling Requestssrc/coredump.c+110 -00 replies
21/33Get Clients PIDsrc/coredump.c+22 -00 replies
22/33Dump the tasksrc/coredump.c+60 -00 replies
23/33Handling SIG TERM of the daemonsrc/coredump.c+16 -00 replies
24/33Handling SIG TERM of the childsrc/coredump.c+17 -00 replies
25/33Systemd Socket ID retrievalsrc/coredump.c+32 -00 replies
26/33Setting up Connectionsrc/Makefile.am src/client.c+74 -00 replies
27/33Request for dumpsrc/Makefile.am src/client.c src/gencore.h+53 -00 replies
28/33Man pagesdoc/gencore.1 doc/gencore.3+59 -00 replies
29/33Automake files for the doc folderMakefile.am configure.ac doc/Makefile.am +1 more+4 -20 replies
30/33README, COPYING, ChangelogCOPYING COPYING.LIBGENCORE Changelog +1 more+163 -00 replies
31/33Spec fileMakefile.am configure.ac gencore.spec.in +1 more+81 -10 replies
32/33Socket and Service files.Makefile.am configure.ac gencore.service +3 more+65 -00 replies
33/33Support checksrc/coredump.c src/elf64.c+13 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/33] [RFC] Non disruptive application core dump infrastructure

Hi all,

The following series implements an infrastructure for capturing the core of an application without disrupting its process.

Kernel Space Approach:

1) Posted an RFD to LKML explaining the various kernel-methods being analysed.

https://lkml.org/lkml/2013/9/3/122

2) Went ahead to implement the same using the task_work_add approach and posted an RFC to LKML.

http://lwn.net/Articles/569534/

Based on the responses, the present approach implements the same in User-Space.

User Space Approach:

We didn't adopt the CRIU approach because our method would give us a head start, as all that the distro would need is the PTRACE_functionality and nothing more which is available from kernel versions 3.4 and above.

Basic Idea of User Space:

1) The threads are held using PTRACE_SEIZE and PTRACE_INTERRUPT.

2) The dump is then taken using the following:
1) The register sets namely general purpose, floating point and the arch specific register sets are collected through PTRACE_GETREGSET calls by passing the appropriate register type as parameter.
2) The virtual memory maps are collected from /proc/pid/maps.
3) The auxiliary vector is collected from /proc/pid/auxv.
4) Process state information for filling the notes such as PRSTATUS and PRPSINFO are collected from /proc/pid/stat and /proc/pid/status.
5) The actual memory is read through process_vm_readv syscall as suggested by Andi Kleen.
6) Command line arguments are collected from /proc/pid/cmdline

3) The threads are then released using PTRACE_DETACH.

Self Dump:

A self dump is implemented with the following approach which was adapted from CRIU:

Gencore Daemon

The programs can request a dump using gencore() API, provided through libgencore. This is implemented through a daemon which listens on a UNIX File socket. The daemon is started immediately post installation.

We have provided service scripts for integration with systemd.

NOTE:

On systems with systemd, we could make use of socket option, which will avoid the need for running the gencore daemon always. The systemd can wait on the socket for requests and trigger the daemon as and when required. However, since the systemd socket APIs are not exported yet, we have disabled the supporting code for this feature.

libgencore:

1) The client interface is a standard library call. All that the dump requester does is open the library and call the gencore() API and the dump will be generated in the path specified(relative/absolute).

To Do:

1) Presently we wait indefinitely for the all the threads to seize. We can add a time-out to decide how much time we need to wait for the threads to be seized. This can be passed as command line argument in the case of a third party dump and in the case of the self-dump through the library call. We need to work on how much time to wait.

2) Like mentioned before, the systemd socket APIs are not exported yet and hence this option is disabled now. Once these API's are available we can enable the socket option.

We would like to push this to one of the following packages:
a) util-linux
b) coreutils
c) procps-ng

We are not sure which one would suit this application the best. Please let us know your views on the same.

Patches 1 - 16 implements the dump generation.

Patches 17 - 24 implements the daemon approach.

Patch 25 implements the systemd socket approach.

Patches 26-27 implements the client-interface library.

Patches 28-33 handles the building and other packaging aspects.

Please let us know your reviews and comments.

Thanks.

Janani Venkataraman (33):
Configure and Make files
Validity of arguments
Process Status
Hold threads
Fetching Memory maps
Check ELF class
Do elf_coredump
Fills elf header
Adding notes infrastructure
Populates PRPS info
Populate AUXV
Fetch File maps
Fetching thread specific Notes
Populating Program Headers
Updating Offset
Writing to core file
Daemonizing the Process
Socket operations
Block till request
Handling Requests
Get Clients PID
Dump the task
Handling SIG TERM of the daemon
Handling SIG TERM of the child
Systemd Socket ID retrieval
[libgencore] Setting up Connection
[libgencore] Request for dump
Man pages
Automake files for the doc folder
README, COPYING, Changelog
Spec file
Socket and Service files.
Support check

 COPYING            |   24 ++
 COPYING.LIBGENCORE |   24 ++
 Changelog          |    7 
 Makefile.am        |   22 +
 README             |  108 +++++++
 configure.ac       |    8 +
 doc/Makefile.am    |    2 
 doc/gencore.1      |   31 ++
 doc/gencore.3      |   28 ++
 gencore.service    |    9 +
 gencore.socket     |   10 +
 gencore.spec.in    |   88 ++++++
 [email protected]   |    9 +
 libgencore.pc.in   |    8 +
 src/Makefile.am    |   13 +
 src/client.c       |  121 ++++++++
 src/coredump.c     |  764 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/coredump.h     |   74 +++++
 src/elf-compat.h   |  124 ++++++++
 src/elf.c          |  827 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/elf32.c        |   43 +++
 src/elf64.c        |   44 +++
 src/gencore.h      |    1 
 src/proc.c         |  278 +++++++++++++++++
 24 files changed, 2667 insertions(+)
 create mode 100644 COPYING
 create mode 100644 COPYING.LIBGENCORE
 create mode 100644 Changelog
 create mode 100644 README
 create mode 100644 doc/Makefile.am
 create mode 100644 doc/gencore.1
 create mode 100644 doc/gencore.3
 create mode 100644 gencore.service
 create mode 100644 gencore.socket
 create mode 100644 gencore.spec.in
 create mode 100644 [email protected]
 create mode 100644 libgencore.pc.in
 create mode 100644 src/Makefile.am
 create mode 100644 src/client.c
 create mode 100644 src/coredump.c
 create mode 100644 src/coredump.h
 create mode 100644 src/elf-compat.h
 create mode 100644 src/elf.c
 create mode 100644 src/elf32.c
 create mode 100644 src/elf64.c
 create mode 100644 src/gencore.h
 create mode 100644 src/proc.c
Signature · 1 line
Janani