tools/testing/vsock/vsock_test_zerocopy.c
Source file repositories/reference/linux-study-clean/tools/testing/vsock/vsock_test_zerocopy.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/vsock/vsock_test_zerocopy.c- Extension
.c- Size
- 9375 bytes
- Lines
- 433
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstring.hsys/ioctl.hsys/mman.hunistd.hpoll.hlinux/errqueue.hlinux/kernel.hlinux/sockios.hlinux/time64.herrno.hcontrol.htimeout.hvsock_test_zerocopy.hmsg_zerocopy_common.h
Detected Declarations
struct vsock_test_datafunction test_clientfunction test_stream_msgzcopy_clientfunction test_seqpacket_msgzcopy_clientfunction test_serverfunction test_stream_msgzcopy_serverfunction test_seqpacket_msgzcopy_serverfunction test_stream_msgzcopy_empty_errq_clientfunction test_stream_msgzcopy_empty_errq_serverfunction test_stream_msgzcopy_mangle_clientfunction test_stream_msgzcopy_mangle_server
Annotated Snippet
struct vsock_test_data {
/* This test case if for SOCK_STREAM only. */
bool stream_only;
/* Data must be zerocopied. This field is checked against
* field 'ee_code' of the 'struct sock_extended_err', which
* contains bit to detect that zerocopy transmission was
* fallbacked to copy mode.
*/
bool zerocopied;
/* Enable SO_ZEROCOPY option on the socket. Without enabled
* SO_ZEROCOPY, every MSG_ZEROCOPY transmission will behave
* like without MSG_ZEROCOPY flag.
*/
bool so_zerocopy;
/* 'errno' after 'sendmsg()' call. */
int sendmsg_errno;
/* Number of valid elements in 'vecs'. */
int vecs_cnt;
struct iovec vecs[VSOCK_TEST_DATA_MAX_IOV];
};
static struct vsock_test_data test_data_array[] = {
/* Last element has non-page aligned size. */
{
.zerocopied = true,
.so_zerocopy = true,
.sendmsg_errno = 0,
.vecs_cnt = 3,
{
{ NULL, PAGE_SIZE },
{ NULL, PAGE_SIZE },
{ NULL, 200 }
}
},
/* All elements have page aligned base and size. */
{
.zerocopied = true,
.so_zerocopy = true,
.sendmsg_errno = 0,
.vecs_cnt = 3,
{
{ NULL, PAGE_SIZE },
{ NULL, PAGE_SIZE * 2 },
{ NULL, PAGE_SIZE * 3 }
}
},
/* All elements have page aligned base and size. But
* data length is bigger than 64Kb.
*/
{
.zerocopied = true,
.so_zerocopy = true,
.sendmsg_errno = 0,
.vecs_cnt = 3,
{
{ NULL, PAGE_SIZE * 16 },
{ NULL, PAGE_SIZE * 16 },
{ NULL, PAGE_SIZE * 16 }
}
},
/* Middle element has both non-page aligned base and size. */
{
.zerocopied = true,
.so_zerocopy = true,
.sendmsg_errno = 0,
.vecs_cnt = 3,
{
{ NULL, PAGE_SIZE },
{ (void *)1, 100 },
{ NULL, PAGE_SIZE }
}
},
/* Middle element is unmapped. */
{
.zerocopied = false,
.so_zerocopy = true,
.sendmsg_errno = ENOMEM,
.vecs_cnt = 3,
{
{ NULL, PAGE_SIZE },
{ MAP_FAILED, PAGE_SIZE },
{ NULL, PAGE_SIZE }
}
},
/* Valid data, but SO_ZEROCOPY is off. This
* will trigger fallback to copy.
*/
{
.zerocopied = false,
.so_zerocopy = false,
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`, `sys/mman.h`, `unistd.h`, `poll.h`, `linux/errqueue.h`.
- Detected declarations: `struct vsock_test_data`, `function test_client`, `function test_stream_msgzcopy_client`, `function test_seqpacket_msgzcopy_client`, `function test_server`, `function test_stream_msgzcopy_server`, `function test_seqpacket_msgzcopy_server`, `function test_stream_msgzcopy_empty_errq_client`, `function test_stream_msgzcopy_empty_errq_server`, `function test_stream_msgzcopy_mangle_client`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.