failed to write 1 to memory.kmem.limit_in_by

问题描述:

Message: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:297: applying cgroup configuration for process caused \"failed to write 1 to memory.kmem.limit_in_bytes: write /sys/fs/cgroup/memory/kubepods/burstable/pod1xxx/517xxx/memory.kmem.limit_in_bytes: operation not supported\"": unknown

解决方式:

给 /sys/fs/cgroup/memory 添加可执行权限:

chmod +x /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes

`kmem_cache_create`是Linux内核中用于动态内存分配的一种函数,它属于kmalloc模块,负责创建一块内存缓存池。这个缓存池可以高效地管理内存,通常用于存储大小固定的数据结构,如硬件驱动程序中的设备私有数据等。 当需要创建一个新的内存块时,开发者会先通过`kmem_cache_create`指定缓存的名称、大小、对齐方式、内存页大小以及一些其他的配置选项。每次从缓存池获取内存都是原子操作,释放时将内存返回给缓存,以便下次复用。这提高了内存的利用率,并减少了内存碎片。 使用`kmem_cache_create`的示例代码可能如下: ```c struct my_data { /* ... */ }; struct my_data_cachep { struct kmem_cache *cachep; }; static inline struct my_data *my_data_alloc(void) { return kmalloc(sizeof(struct my_data), GFP_KERNEL); } static int __init my_init(void) { struct my_data_cachep *cache_info = kmalloc(sizeof(*cache_info), GFP_KERNEL); if (!cache_info) { printk(KERN_ERR "Failed to allocate cache info\n"); return -ENOMEM; } cache_info->cachep = kmem_cache_create("my_data_cache", sizeof(struct my_data), 0, SLAB_HWCACHE_ALIGN, NULL); if (IS_ERR(cache_info->cachep)) { printk(KERN_ERR "Failed to create cache: %ld\n", PTR_ERR(cache_info->cachep)); kfree(cache_info); return PTR_ERR(cache_info->cachep); } // 使用 cachep 进行内存分配 struct my_data *data = kmem_cache_zalloc(cache_info->cachep, GFP_KERNEL); if (!data) { kmem_cache_destroy(cache_info->cachep); kfree(cache_info); return -ENOMEM; } // 初始化 data... ... return 0; } ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卢子墨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值