Commit Graph

3876 Commits

Author SHA1 Message Date
Conrad Pankoff
54ceabd48d Kernel: Use WeakPtr<NetworkAdapter> instead of NetworkAdapter* in net code 2019-08-09 07:09:26 +02:00
Andreas Kling
d6bce37756 ProcessManager: Add a "Network" tab with live adapter and socket stats
This fetches info from /proc/netadapters and /proc/net_tcp, updating
every second. Very cool. :^)
2019-08-08 20:43:30 +02:00
Andreas Kling
899366da9d GTableView: Debug-log the current column width while resizing
This makes it easier to decide on a good initial width for a column.
2019-08-08 20:41:24 +02:00
Andreas Kling
eb3c19773e ProcessManager: Tweak memory stats widget layout to fit more text
After a while, the kmalloc/kfree counts got too wide for the label.
2019-08-08 19:50:33 +02:00
Andreas Kling
865a1b913c AK: Add Optional<T>(const U&)
This replaces Optional<T>(U&&) which clang-tidy complained may hide the
regular copy and move constructors. That's a good point, clang-tidy,
and I appreciate you pointing that out!
2019-08-08 18:34:59 +02:00
Andreas Kling
533b5c0adc Kernel: Reorder some Process members to shrink the class by 8 bytes 2019-08-08 14:57:45 +02:00
Andreas Kling
6d32b8fc36 Kernel: Use some more InlineLinkedList range-for iteration 2019-08-08 14:40:30 +02:00
Andreas Kling
eb6609124e ProcFS: Remove /proc/kmalloc, that info is already in /proc/memstat 2019-08-08 14:02:21 +02:00
Andreas Kling
9104d32341 Kernel: Use range-for with InlineLinkedList 2019-08-08 13:40:58 +02:00
Andreas Kling
028e834bb4 WindowServer: Use range-for with InlineLinkedList 2019-08-08 13:40:47 +02:00
Andreas Kling
bb9909548b AK: Add an iterator class for InlineLinkedList
This makes it possible to iterate over these with range-for. :^)
2019-08-08 13:39:40 +02:00
Andreas Kling
318068fe1b Kernel: Turns global Custody and Inode tables into InlineLinkedLists
Yet more of this same thing. Each one of these patches has a small but
noticeable impact on the steady-state kmalloc numbers. :^)
2019-08-08 11:11:22 +02:00
Andreas Kling
07425580a8 Kernel: Put all Regions on InlineLinkedLists (separated by user/kernel)
Remove the global hash tables and replace them with InlineLinkedLists.
This significantly reduces the kernel heap pressure from doing many
small mmap()'s.
2019-08-08 11:11:22 +02:00
Andreas Kling
a96d76fd90 Kernel: Put all VMObjects in an InlineLinkedList instead of a HashTable
Using a HashTable to track "all instances of Foo" is only useful if we
actually need to look up entries by some kind of index. And since they
are HashTable (not HashMap), the pointer *is* the index.

Since we have the pointer, we can just use it directly. Duh.
This increase sizeof(VMObject) by two pointers, but removes a global
table that had an entry for every VMObject, where the cost was higher.
It also avoids all the general hash tabling business when creating or
destroying VMObjects. Generally we should do more of this. :^)
2019-08-08 11:11:22 +02:00
Conrad Pankoff
fffd3a67ad Userland: Implement -l, -v, -N, -s, and -p for netcat 2019-08-08 10:32:01 +02:00
Conrad Pankoff
fbcf51f81b Userland: Implement nc command
This is a very simple version of the nc (netcat) command. It only
supports outgoing TCP connections, and has no options aside from the
target host and port.
2019-08-08 06:47:30 +02:00
Conrad Pankoff
7ed54d86d5 Kernel: Record network statistics and expose as JSON
This is comprised of five small changes:

* Keep a counter for tx/rx packets/bytes per TCP socket
* Keep a counter for tx/rx packets/bytes per network adapter
* Expose that data in /proc/net_tcp and /proc/netadapters
* Convert /proc/netadapters to JSON
* Fix up ifconfig to read the JSON from netadapters
2019-08-08 06:44:49 +02:00
Conrad Pankoff
061c092fae Kernel: Prevent RST spam when we get an unexpected packet 2019-08-08 06:42:41 +02:00
Andreas Kling
98ce498922 Kernel: Remove unused MemoryManager::remove_identity_mapping()
This was not actually used and just sitting there being confusing.
2019-08-07 22:13:10 +02:00
Andreas Kling
c258c9a4b2 FormCompiler: Oops, need to use JsonValue::serialized() for properties
When assigning properties, we were relying on the JSON serialization
code to wrap strings in double-quotes ("). JsonValue::to_string() does
not wrap string values, so what we want here is serialized(). :^)
2019-08-07 22:09:33 +02:00
Andreas Kling
351c354680 ChanViewer: Show "" instead of "undefined" for missing thread subjects
This broke due to a change in JsonValue API. JsonValue::to_string() now
returns the value serialized to a string, which may become "undefined".

You kinda want JsonValue::as_string(), but that is only callable when
the JsonValue *is* a string. Thankfully there is now as_string_or(alt).
2019-08-07 22:05:04 +02:00
Andreas Kling
9889d170b9 JsonValue: Add as_string_or(String)
Return the contained string if the value *is* a string, otherwise it
returns the alternative string passed in the parameter.
2019-08-07 22:03:25 +02:00
Andreas Kling
f5ff796970 Kernel: Always give back VM to the RangeAllocator when unmapping Region
We were only doing this in Process::deallocate_region(), which meant
that kernel-only Regions never gave back their VM.

With this patch, we can start reusing freed-up address space! :^)
2019-08-07 21:57:39 +02:00
Andreas Kling
37ba2a7b65 Kernel: Use KBufferBuilder to build ProcFS files and backtraces
This is not perfect as it uses a lot of VM, but since the buffers are
supposed to be temporary it's not super terrible.

This could be improved by giving back the unused VM to the kernel's
RangeAllocator after finishing the buffer building.
2019-08-07 21:52:43 +02:00
Andreas Kling
f6998b1817 JSON: Templatize the JSON serialization code
This makes it possible to use something other than a StringBuilder for
serialization (and to produce something other than a String.) :^)
2019-08-07 21:29:32 +02:00
Andreas Kling
43ec733b61 AK: Add a basic unit test for FileSystemPath
Just to make sure that things are on the up-and-up.
2019-08-07 21:07:02 +02:00
Andreas Kling
1f9b8f0e7c Kernel: Don't create Function objects in the scheduling code
Each Function is a heap allocation, so let's make an effort to avoid
doing that during scheduling. Because of header dependencies, I had to
put the runnables iteration helpers in Thread.h, which is a bit meh but
at least this cuts out all the kmalloc() traffic in pick_next().
2019-08-07 20:43:54 +02:00
Andreas Kling
2e416b1b87 Vector: Add a test for growing a Vector beyond its inline capacity 2019-08-07 20:43:13 +02:00
Andreas Kling
308461ca9a Kernel: Disable kmalloc backtraces during backtrace generation
If kmalloc backtraces are enabled during backtracing, things don't go
super well when the backtrace code calls kmalloc()..

With this fixed, it's basically possible to get all kmalloc backtraces
on the debugger by running (as root):

sysctl kmalloc_stacks=1
2019-08-07 20:37:05 +02:00
Andreas Kling
b67200dfea Kernel: Use a FixedArray for VMObject::m_physical_pages
This makes VMObject 8 bytes smaller since we can use the array size as
the page count.

The size() is now also computed from the page count instead of being
a separate value. This makes sizes always be a multiple of PAGE_SIZE,
which is sane.
2019-08-07 20:12:50 +02:00
Andreas Kling
5096eaa845 AK: Add a FixedArray<T> container
This is a simple array wrapper that knows its size. It has begin/end
so you can use range-for. It also has a resize() that reallocates.
2019-08-07 20:05:36 +02:00
Andreas Kling
6bdb81ad87 Kernel: Split VMObject into two classes: Anonymous- and InodeVMObject
InodeVMObject is a VMObject with an underlying Inode in the filesystem.
AnonymousVMObject has no Inode.

I'm happy that InodeVMObject::inode() can now return Inode& instead of
VMObject::inode() return Inode*. :^)
2019-08-07 18:09:32 +02:00
Andreas Kling
cb2d572a14 Kernel: Remove "allow CPU caching" flag on VMObject
This wasn't really thought-through, I was just trying anything to see
if it would make WindowServer faster. This doesn't seem to make much of
a difference either way, so let's just not do it for now.

It's easy to bring back if we think we need it in the future.
2019-08-07 16:34:00 +02:00
Andreas Kling
3364da388f Kernel: Remove VMObject names
The VMObject name was always either the owning region's name, or the
absolute path of the underlying inode.

We can reconstitute this information if wanted, no need to keep copies
of these strings around.
2019-08-07 16:14:08 +02:00
Andreas Kling
5487f81b5d Vector: Use memcpy when dynamically growing Vectors of trivial types 2019-08-07 15:35:23 +02:00
Andreas Kling
6da6ca64d2 Vector: Use TypedTransfer in more parts of Vector
Make more Vector-of-trivial-type operations go fast :^)
2019-08-07 15:25:34 +02:00
Andreas Kling
e8e85f5457 Vector: Use memcmp for comparing two vectors with trivial elements 2019-08-07 15:05:10 +02:00
Andreas Kling
6d97caf124 JsonParser: Scan ahead to find the first special char in quoted strings
This allows us to take advantage of the now-optimized (to do memmove())
Vector::append(const T*, int count) for collecting these strings.

This is a ~15% speedup on the load_4chan_catalog benchmark.
2019-08-07 11:57:51 +02:00
Andreas Kling
b48b6c0caa Vector: Use memmove() for moving trivial types around more
This can definitely be improved with better trivial type detection and
by using the TypedTransfer template in more places.

It's a bit annoying that we can't get <type_traits> in Vector.h since
it's included in the toolchain compilation before we have libstdc++.
2019-08-07 11:55:20 +02:00
Andreas Kling
bebe7c4cff DiskDevice: Add missing override and remove unnecessary class_name()
This class needs to be fixed up to not hide the read()/write() virtuals
at some point.
2019-08-07 07:21:28 +02:00
Andreas Kling
60c25228ee AK: Fix -Wconsumed warnings in Optional move-ctor and move-assign
Our protocol says we have to call has_value() before release_value().
The code was already safe, but the compiler had no way of knowing that.
2019-08-07 07:17:52 +02:00
Andreas Kling
0f7eece141 Meta: Make Serenity run on Bochs once again
It's now possible to run Serenity inside Bochs by executing "./run b"
Note that it only works with a GRUB image (i.e ./build-image-grub.sh)
2019-08-06 21:09:24 +02:00
Andreas Kling
2abfab2892 ELFLoader: Remove an uninteresting debug log message
This is showing up at the boundary between kernel and userspace stack
frames in backtraces, and looks silly.
2019-08-06 20:49:36 +02:00
Andreas Kling
f083031a27 Kernel: Add KBufferBuilder, similar to StringBuilder but for KBuffer
This class works by eagerly allocating 1MB of virtual memory but only
adding physical pages on demand. In other words, when you append to it,
its memory usage will increase by 1 page whenever you append across a
page boundary (4KB.)
2019-08-06 20:04:12 +02:00
Andreas Kling
83fdad25ed Kernel: For signal-killed threads, dump backtrace from finalizer thread
Instead of dumping the dying thread's backtrace in the signal handling
code, wait until we're finalizing the thread. Since signalling happens
during scheduling, the less work we do there the better.

Basically the less that happens during a scheduler pass the better. :^)
2019-08-06 19:45:08 +02:00
Conrad Pankoff
73c998dbfc Kernel: Refactor TCP/IP stack
This has several significant changes to the networking stack.

* Significant refactoring of the TCP state machine. Right now it's
  probably more fragile than it used to be, but handles quite a lot
  more of the handshake process.
* `TCPSocket` holds a `NetworkAdapter*`, assigned during `connect()` or
  `bind()`, whichever comes first.
* `listen()` is now virtual in `Socket` and intended to be implemented
  in its child classes
* `listen()` no longer works without `bind()` - this is a bit of a
  regression, but listening sockets didn't work at all before, so it's
  not possible to observe the regression.
* A file is exposed at `/proc/net_tcp`, which is a JSON document listing
  the current TCP sockets with a bit of metadata.
* There's an `ETHERNET_VERY_DEBUG` flag for dumping packet's content out
  to `kprintf`. It is, indeed, _very debug_.
2019-08-06 16:21:17 +02:00
Andreas Kling
c973a51a23 Kernel: Make KBuffer lazily populated
KBuffers are now zero-filled on demand instead of up front. This means
that you can create a huge KBuffer and it will only take up VM, not
physical pages (until you access them.)
2019-08-06 15:06:31 +02:00
Andreas Kling
a0bb592b4f Kernel: Allow zero-fill page faults on kernel-only pages
We were short-circuiting the page fault handler a little too eagerly
for page-not-present faults in kernel memory.
If the current page directory already has up-to-date mapps for kernel
memory, allow it to progress to checking for zero-fill conditions.

This will enable us to have lazily populated kernel regions.
2019-08-06 15:06:31 +02:00
Conrad Pankoff
da615e46cd LibCore: Initialise m_port as zero in CSocketAddress 2019-08-06 15:06:20 +02:00
Conrad Pankoff
6f75d96689 Launcher: Add ChanViewer to default config 2019-08-06 15:05:56 +02:00