Commit graph

134 commits

Author SHA1 Message Date
Andreas Kling
97c497f9fe Kernel: Move {Process,Thread,Session,ProcessGroup}ID to Kernel/Forward.h 2021-08-14 19:58:11 +02:00
Andreas Kling
dcb015fa7e Kernel: Move VFS-internal O_FOO definitions to VirtualFileSystem.h 2021-08-14 19:58:11 +02:00
Andreas Kling
b47c7a2c38 Kernel: Remove unused integer typedefs from UnixTypes.h 2021-08-14 19:58:11 +02:00
Andreas Kling
e1273a8ff7 Kernel+LibC: Share definitions for sys/statvfs.h 2021-08-14 19:58:11 +02:00
Andreas Kling
dfd78b75d8 Kernel+LibC: Share definitions for sched.h 2021-08-14 19:58:11 +02:00
Andreas Kling
c9a5d83ccc Kernel+LibC: Share definitions for sys/uio.h 2021-08-14 19:58:11 +02:00
Andreas Kling
37e98a55b7 Kernel+LibC: Share definitions for sys/ptrace.h 2021-08-14 19:58:11 +02:00
Andreas Kling
6dc688a08d Kernel: Remove some redundant typedefs from UnixTypes.h 2021-08-14 19:58:11 +02:00
Andreas Kling
6b6eca0631 Kernel+LibC: Share definitions for sys/time.h 2021-08-14 19:58:11 +02:00
Andreas Kling
35b52338bb Kernel+LibC: Share definitions for sys/times.h 2021-08-14 19:58:11 +02:00
Andreas Kling
808ce594db Kernel+LibC: Share definitions for stdio.h 2021-08-14 19:58:11 +02:00
Andreas Kling
9c2212a60a Kernel+LibC: Share definitions for unistd.h 2021-08-14 19:58:11 +02:00
Andreas Kling
d33b43276c Kernel+LibC: Share definitions for poll.h 2021-08-14 19:58:11 +02:00
Andreas Kling
d794ed1de7 Kernel+LibC: Share definitions for utsname.h 2021-08-14 19:58:11 +02:00
Andreas Kling
c65a735d71 Kernel+LibC: Share definitions for dirent.h 2021-08-14 19:58:11 +02:00
Andreas Kling
77c2c0f620 Kernel+LibC: Share definitions for serenity.h 2021-08-14 19:58:11 +02:00
Andreas Kling
6f78377864 Kernel+LibC: Share definitions for sys/wait.h 2021-08-14 19:58:11 +02:00
Andreas Kling
661bd992b0 Kernel+LibC: Share definitions for net/{if,if_arp,route}.h 2021-08-14 19:58:11 +02:00
Andreas Kling
ff50122dc5 Kernel+LibC: Share definitions for futex.h 2021-08-14 19:58:11 +02:00
Andreas Kling
6fd7212476 Kernel+LibC: Share definitions for signal.h 2021-08-14 19:58:11 +02:00
Andreas Kling
9dc1350177 Kernel+LibC: Share definitions for netinet/in.h 2021-08-14 19:58:11 +02:00
Andreas Kling
b92e6b02e5 Kernel+LibC: Share definitions for sys/socket.h and sys/un.h 2021-08-14 19:58:11 +02:00
Andreas Kling
d277cdfd4c Kernel+LibC: Share definitions for termios.h 2021-08-14 19:58:11 +02:00
Andreas Kling
a8d1c2dde9 Kernel+LibC: Share definitions for sys/mman.h 2021-08-14 19:58:11 +02:00
Andreas Kling
0a78056453 Kernel+LibC: Share definitions for time.h and sys/stat.h 2021-08-14 19:58:11 +02:00
Andreas Kling
740140a661 Kernel+LibC: Share definitions in fcntl.h and sys/types.h
This patch begins the work of sharing types and macros between Kernel
and LibC instead of duplicating them via the kludge in UnixTypes.h.

The basic idea is that the Kernel vends various POSIX headers via
Kernel/API/POSIX/ and LibC simply #include's them to get the macros.
2021-08-14 19:58:11 +02:00
Liav A
bf1adc2d5d Kernel+LibC: Use 64 bit values for ino_t
Since the InodeIndex encapsulates a 64 bit value, it is correct to
ensure that the Kernel is exposing the entire value and the LibC is
aware of it.

This commit requires an entire re-compile because it's essentially a
change in the Kernel ABI, together with a corresponding change in LibC.
2021-08-12 20:57:32 +02:00
Andreas Kling
0d997d48ea Kernel+LibC: Add PERF_EVENT_SIGNPOST
This event will be used by userspace programs wanting to mark
interesting high-level events in the profile. :^)
2021-08-12 00:03:38 +02:00
Jean-Baptiste Boric
0286160b62 Kernel: Add syscall performance event type
This allows tracing the syscalls made by a thread through the kernel's
performance event framework, which is similar in principle to strace.

Currently, this merely logs a stack backtrace to the current thread's
performance event buffer whenever a syscall is made, if profiling is
enabled. Future improvements could include tracing the arguments and
the return value, for example.
2021-08-10 21:55:48 +02:00
Andreas Kling
f02d73db4d LibC+Kernel: Use an enum for clockid_t values 2021-08-10 13:01:39 +02:00
Luke
e3b588a43d Kernel+LibC: Add linger to sys/sockets.h
Also adds SO_BROADCAST in UnixTypes.h to match sys/sockets.h.
Required by bash 5.1.8.
2021-07-29 19:35:03 +01:00
brapru
8313d35749 Kernel: Support ioctl SIOCSARP and SIOCDARP
Creates ioctl calls necessary to set/delete an entry from the ARP table
2021-07-25 17:57:08 +02:00
Andreas Kling
09bc4cee15 Kernel: Remove unused madvise(MADV_GET_VOLATILE)
This was used to query the volatile state of a memory region, however
nothing ever actually used it.
2021-07-25 17:28:06 +02:00
Andreas Kling
2d1a651e0a Kernel: Make purgeable memory a VMObject level concept (again)
This patch changes the semantics of purgeable memory.

- AnonymousVMObject now has a "purgeable" flag. It can only be set when
  constructing the object. (Previously, all anonymous memory was
  effectively purgeable.)

- AnonymousVMObject now has a "volatile" flag. It covers the entire
  range of physical pages. (Previously, we tracked ranges of volatile
  pages, effectively making it a page-level concept.)

- Non-volatile objects maintain a physical page reservation via the
  committed pages mechanism, to ensure full coverage for page faults.

- When an object is made volatile, it relinquishes any unused committed
  pages immediately. If later made non-volatile again, we then attempt
  to make a new committed pages reservation. If this fails, we return
  ENOMEM to userspace.

mmap() now creates purgeable objects if passed the MAP_PURGEABLE option
together with MAP_ANONYMOUS. anon_create() memory is always purgeable.
2021-07-25 17:28:05 +02:00
Peter Elliott
3fa2816642 Kernel+LibC: Implement fcntl(2) advisory locks
Advisory locks don't actually prevent other processes from writing to
the file, but they do prevent other processes looking to acquire and
advisory lock on the file.

This implementation currently only adds non-blocking locks, which are
all I need for now.
2021-07-20 17:44:30 +04:30
Jelle Raaijmakers
e483de93ce LibC: Define MSG_OOB 2021-06-04 10:39:41 +02:00
Jelle Raaijmakers
496988de47 LibC: Add POSIX timer constants 2021-06-04 10:39:41 +02:00
Brian Gianforcaro
83fc591cea Kernel: Generate page fault events from the kernel profiler
Hook the kernel page fault handler and capture page fault events when
the fault has a current thread attached in TLS. We capture the eip and
ebp so we can unwind the stack and locate which pieces of code are
generating the most page faults.

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-19 22:51:42 +02:00
Gunnar Beutner
277f333b2b Kernel: Add support for profiling kmalloc()/kfree() 2021-05-19 22:51:42 +02:00
Gunnar Beutner
572bbf28cc Kernel+LibC: Add support for filtering profiling events
This adds the -t command-line argument for the profile tool. Using this
argument you can filter which event types you want in your profile.
2021-05-19 22:51:42 +02:00
Gunnar Beutner
8b2ace0326 Kernel: Track performance events for context switches 2021-05-19 22:51:42 +02:00
Justin
1c3badede3 Kernel: Add statvfs & fstatvfs Syscalls
These syscalls fill a statvfs struct with various data
about the mount on the VFS.
2021-05-19 21:33:29 +02:00
Mart G
e7310ba45a Kernel+LibC: Add fstatat
The function fstatat can do the same thing as the stat and lstat
functions. However, it can be passed the file descriptor of a directory
which will be used when as the starting point for relative paths. This
is contrary to stat and lstat which use the current working directory as
the starting for relative paths.
2021-05-14 23:32:10 +02:00
Sergey Bugaev
78459b92d5 Kernel: Implement IP multicast support
An IP socket can now join a multicast group by using the
IP_ADD_MEMBERSHIP sockopt, which will cause it to start receiving
packets sent to the multicast address, even though this address does
not belong to this host.
2021-05-05 21:16:17 +02:00
Justin
e6401d65bd Kernel: Add MSG_PEEK support for the IPv4Socket
This commit will add MSG_PEEK support, which allows a package to be
seen without taking it from the buffer, so that a subsequent recv()
without the MSG_PEEK flag can pick it up.
2021-04-29 08:09:53 +02:00
Gunnar Beutner
eb798d5538 Kernel+Profiler: Improve profiling subsystem
This turns the perfcore format into more a log than it was before,
which lets us properly log process, thread and region
creation/destruction. This also makes it unnecessary to dump the
process' regions every time it is scheduled like we did before.

Incidentally this also fixes 'profile -c' because we previously ended
up incorrectly dumping the parent's region map into the profile data.

Log-based mmap support enables profiling shared libraries which
are loaded at runtime, e.g. via dlopen().

This enables profiling both the parent and child process for
programs which use execve(). Previously we'd discard the profiling
data for the old process.

The Profiler tool has been updated to not treat thread IDs as
process IDs anymore. This enables support for processes with more
than one thread. Also, there's a new widget to filter which
process should be displayed.
2021-04-26 17:13:55 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
FalseHonesty
3123ffb19d Kernel: Add ptrace commands for reading/writing the debug registers
This adds PT_PEEKDEBUG and PT_POKEDEBUG to allow for reading/writing
the debug registers, and updates the Kernel's debug handler to read the
new information from the debug status register.
2021-04-18 17:02:40 +02:00
Gunnar Beutner
c33592d28c Kernel+LibC: Update struct stat to use struct timespec instead of time_t
Some programs unconditionally expect struct stat to have nanosecond support.
2021-04-17 11:12:42 +02:00
Jean-Baptiste Boric
7a079f7780 LibC+Kernel: Switch off_t to 64 bits 2021-03-17 23:22:42 +01:00