当前位置:网站首页>后备高速缓存api的使用
后备高速缓存api的使用
2022-07-13 18:13:00 【酸菜。】
一:背景
二:例程
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/fs.h>
#include<linux/slab.h>
#include<linux/interrupt.h>
MODULE_AUTHOR("Tan xujia");
MODULE_LICENSE("Dual BSD/GPL");
struct mem {
int count;
int size;
};
struct kmem_cache *p;
static int
__init mem_init(void)
{
printk("init\n");
p = kmem_cache_create("memtest", sizeof(struct mem), 0,
SLAB_HWCACHE_ALIGN, NULL);
if(!p){
return -1;
}else {
struct mem *p1 = (struct mem*)kmem_cache_alloc(p, GFP_KERNEL);
p1->count = 10;
p1->size = 12;
printk("p1->count = %d, p1->size = %d\n",
p1->count, p1->size);
kmem_cache_free(p, p1);
}
return 0;
}
static void
__exit mem_exit(void)
{
printk("exit\n");
kmem_cache_destroy(p);
p = NULL;
return;
}
module_init(mem_init);
module_exit(mem_exit);
obj-$(CONFIG_BNXT) += a.o
bnxt_en-y := a.o
all:
make -C /usr/src/kernels/$(shell uname -r) M=$(shell pwd) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean片
使用dmesg可以看到相关的打印信息。
边栏推荐
- 深度揭秘阿里云函数计算异步任务能力
- 测试报告别踩坑
- 数组或是对象、日期的操作
- Wechat applet development - (VIII) canvas drawing graphics
- Cocoscreator animation and particles move according to the painting path
- 看测试过来人总结的N年软件测试感悟
- Compare MySQL and pandas to count the number of people online at each time period in the live broadcast room
- [machine learning] summary of machine learning modeling and parameter adjustment methods
- Suddenly announce the dissolution!
- Review of linear algebra knowledge: rank of matrix, norm of matrix, condition number of matrix, eigenvalue and eigenvector of matrix
猜你喜欢
随机推荐
Prism navigation function
Thoroughly understand how Kube scheduler completes scheduling
Flutter 加载中视图、失败视图、空视图封装
cocoscreator动画与粒子根据绘制路径移动
RT_ Use of thread event set
leetcode 18. 四数之和
小程序毕设作品之微信教室预约小程序毕业设计(5)任务书
Axelar:什么是Moonbeam?可以在Moonbeam上构建什么?
Review of linear algebra knowledge: rank of matrix, norm of matrix, condition number of matrix, eigenvalue and eigenvector of matrix
自动化测试工具-Playwright(快速上手)
2022 云原生编程挑战赛启动!导师解析服务网格赛题
[u-boot] summary of compilation, construction and use of u-boot sandbox
常用的正则表达式
LeetCode 735 行星碰撞[栈 模拟] HERODING的LeetCode之路
JS Foundation: JS empty array element minimalist code example
TFIDF sklearn code call
无心剑英汉双语诗005.《浮生若云》
Leetcode 15. 三数之和
EasyCVR接入国标设备后,设备录像不能完整播放该如何解决?
Flutter:环境搭建、项目创建









