6 Commits
Author SHA1 Message Date
Fabricio VoznikaandgVisor bot 01d0fdb7d8 Add BSD-style license to list of licenses
PiperOrigin-RevId: 791931463
2025-08-06 18:46:54 -07:00
Ayush RanjanandgVisor bot 533c7b5188 Plumb restore context to load*() methods.
This allows for external information to be passed to restore code.
Similar to a9af2d309b ("Plumb restore context to afterLoad()").

Updates #1956.

PiperOrigin-RevId: 614125262
2024-03-08 20:28:02 -08:00
Andrei VaginandgVisor bot 890a66acd4 fdtable: avoid large arrays
FDTable.descriptorTable is a slice of unsafe.Pointer-s and its maximum length
is MaxInt32. It requires up to 16GB of memory. A process can use just a few
descriptors but sets one or more of them to high numbers. In this case,
FDTable.descriptorTable is extended to the maximum size.

The problem here is that go-runtime zeros memory regions when they are reused.
In the case of fdtable, the memory region is 16GB, so it is a time consuming
operation. Second, it forces the kernel to allocate physical pages to
the entire region.

This change adds another level to descriptorTable, so the first level is
a slice of buckets where each bucket is a slice of descriptors. The bucket
size is fixed to 512 entries to fit one page.

Before:
BenchmarkFDLookupAndDecRef-12              	50834290	        23.70 ns/op
BenchmarkCreateWithMaxFD-12                	       2	7194873988 ns/op
BenchmarkFDLookupAndDecRefConcurrent-12    	23775555	        49.68 ns/op
BenchmarkTableLookup-12                    	412888780	         2.835 ns/op
BenchmarkTableMapLookup-12                 	87944782	        12.84 ns/op

After:
BenchmarkFDLookupAndDecRef-12              	46229940	        25.03 ns/op
BenchmarkCreateWithMaxFD-12                	      13	  82573899 ns/op
BenchmarkFDLookupAndDecRefConcurrent-12    	21889380	        54.13 ns/op
BenchmarkTableLookup-12                    	415851230	         2.821 ns/op
BenchmarkTableMapLookup-12                 	97236267	        11.89 ns/op

Reported-by: [email protected]
PiperOrigin-RevId: 539138632
2023-06-09 11:49:28 -07:00
Adin ScannellandgVisor bot 2911d8c3b8 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Andrei VaginandAndrei Vagin dbe5cf54ae kvm: trap mmap syscalls to map new regions to the guest
We install seccomp rules so that the SIGSYS signal is generated for
each mmap system call. Then our signal handler executes the real mmap
syscall and if a new regions is created, it maps it to the guest.

Signed-off-by: Andrei Vagin <[email protected]>
2021-09-22 14:39:36 -07:00
Tamir DubersteinandgVisor bot 0ffc497d2c Move sync generics to their own packages
The presence of multiple packages in a single directory sometimes
confuses `go mod`, producing output like:
  go: downloading gvisor.dev/gvisor v0.0.0-20210601174640-101a132e9436
  $GOMODCACHE/gvisor.dev/[email protected]/pkg/linewriter/linewriter.go:21:2: found packages sync (aliases.go) and seqatomic (generic_atomicptr_unsafe.go) in $GOMODCACHE/gvisor.dev/[email protected]/pkg/sync
  imports.go:67:2: found packages tcp (accept.go) and rcv (rcv_test.go) in $GOMODCACHE/gvisor.dev/[email protected]/pkg/tcpip/transport/tcp

PiperOrigin-RevId: 376956213
2021-06-01 17:47:32 -07:00