Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hugepage_uring_0copy_perf
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nils Goroll
hugepage_uring_0copy_perf
Commits
0b6a031c
Unverified
Commit
0b6a031c
authored
Mar 21, 2022
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
0 deletions
+128
-0
.gitignore
.gitignore
+1
-0
Makefile
Makefile
+16
-0
main.c
main.c
+111
-0
No files found.
.gitignore
0 → 100644
View file @
0b6a031c
hugepage_uring_0copy_perf
Makefile
0 → 100644
View file @
0b6a031c
programs
=
hugepage_uring_0copy_perf
sources
=
main.c
CC
=
gcc
LDFLAGS
=
-luring
all
:
$(programs)
$(programs)
:
$(sources)
$(CC)
$(CFLAGS)
$<
-o
$@
$(LDFLAGS)
check
:
$(programs)
./hugepage_uring_0copy_perf 1
.PHONY
:
check
main.c
0 → 100644
View file @
0b6a031c
/*
* simple demo to show long execution times of mmap of 1GB huge pages and
* io_uring configuration for zero copy
*
* March 2022, Nils Goroll <slink@uplex.de>
*/
#include <assert.h>
#include <errno.h>
#include <liburing.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/mman.h>
#include <linux/mman.h>
/* BEGIN from varnish-cache */
#define AZ(foo) do { assert((foo) == 0); } while (0)
#define AN(foo) do { assert((foo) != 0); } while (0)
static
double
VTIM_mono
(
void
)
{
struct
timespec
ts
;
AZ
(
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
));
return
(
ts
.
tv_sec
+
1e-9
*
ts
.
tv_nsec
);
}
/* END from varnish-cache */
#define ptime(t, d, x) printf(x "\t%.6fs\n", t[d] - t[d - 1])
static
void
usage
(
const
char
*
name
)
{
printf
(
"Usage: %s <gb>
\n\t
<gr> is gigabytes to mmap()
\n
"
,
name
);
exit
(
1
);
}
static
int
register_buffers
(
struct
io_uring
*
ring
,
void
*
base
,
unsigned
long
gb
)
{
unsigned
u
,
n
=
gb
+
1
;
struct
iovec
iov
[
n
];
const
size_t
sz
=
(
size_t
)
1
<<
30
;
uintptr_t
p
;
memset
(
iov
,
0
,
sizeof
iov
);
p
=
(
uintptr_t
)
base
;
for
(
u
=
0
;
u
<
gb
;
u
++
)
{
iov
[
u
].
iov_base
=
(
void
*
)
p
;
iov
[
u
].
iov_len
=
sz
;
p
+=
sz
;
}
return
(
io_uring_register_buffers
(
ring
,
iov
,
gb
));
}
int
main
(
int
argc
,
char
**
argv
)
{
double
t
[
5
];
unsigned
long
gb
;
char
*
p
;
void
*
base
;
struct
io_uring_probe
*
probe
;
struct
io_uring
ring
[
1
];
if
(
argc
!=
2
)
usage
(
argv
[
0
]);
gb
=
strtoul
(
argv
[
1
],
&
p
,
10
);
if
(
p
==
argv
[
1
]
||
*
p
!=
'\0'
)
usage
(
argv
[
0
]);
probe
=
io_uring_get_probe
();
AN
(
probe
);
assert
(
io_uring_opcode_supported
(
probe
,
IORING_OP_READ_FIXED
));
free
(
probe
);
AZ
(
io_uring_queue_init
(
1024
,
ring
,
0
));
t
[
0
]
=
VTIM_mono
();
base
=
mmap
(
NULL
,
(
size_t
)
gb
<<
30
,
PROT_READ
|
PROT_WRITE
,
MAP_ANONYMOUS
|
MAP_PRIVATE
|
MAP_LOCKED
|
MAP_HUGETLB
|
MAP_HUGE_1GB
,
-
1
,
0
);
t
[
1
]
=
VTIM_mono
();
if
(
base
==
MAP_FAILED
)
{
fprintf
(
stderr
,
"mmap() failed with %s (%d)
\n
"
"Hint: /sys/kernel/mm/hugepages/"
"hugepages-1048576kB/nr_hugepages
\n
"
"and ulimit -l must be configured
\n
"
,
strerror
(
errno
),
errno
);
exit
(
1
);
}
assert
(
base
!=
MAP_FAILED
);
ptime
(
t
,
1
,
"mmap()"
);
AZ
(
register_buffers
(
ring
,
base
,
gb
));
t
[
2
]
=
VTIM_mono
();
ptime
(
t
,
2
,
"io_uring_register_buffers()"
);
printf
(
"total
\t
%.6fs
\n
"
,
t
[
2
]
-
t
[
0
]);
return
(
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment