Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
02f9a04
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
accounting
arch
bootconfig
bpf
build
cgroup
counter
debugging
edid
firewire
firmware
gpio
hv
iio
include
io_uring
kvm
laptop
leds
lib
api
bpf
perf
subcmd
symbol
traceevent
argv_split.c
bitmap.c
ctype.c
find_bit.c
hweight.c
list_sort.c
rbtree.c
slab.c
str_error_r.c
string.c
vsprintf.c
zalloc.c
memory-model
objtool
pci
pcmcia
perf
power
rcu
scripts
spi
testing
thermal
time
tracing
usb
virtio
vm
wmi
Makefile
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
lib
/
slab.c
Blame
Blame
Latest commit
History
History
38 lines (31 loc) · 664 Bytes
Breadcrumbs
linux
/
tools
/
lib
/
slab.c
Top
File metadata and controls
Code
Blame
38 lines (31 loc) · 664 Bytes
Raw
// SPDX-License-Identifier: GPL-2.0 #include <stdio.h> #include <string.h> #include <urcu/uatomic.h> #include <linux/slab.h> #include <malloc.h> #include <linux/gfp.h> int kmalloc_nr_allocated; int kmalloc_verbose; void *kmalloc(size_t size, gfp_t gfp) { void *ret; if (!(gfp & __GFP_DIRECT_RECLAIM)) return NULL; ret = malloc(size); uatomic_inc(&kmalloc_nr_allocated); if (kmalloc_verbose) printf("Allocating %p from malloc\n", ret); if (gfp & __GFP_ZERO) memset(ret, 0, size); return ret; } void kfree(void *p) { if (!p) return; uatomic_dec(&kmalloc_nr_allocated); if (kmalloc_verbose) printf("Freeing %p to malloc\n", p); free(p); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
You can’t perform that action at this time.