一个伪linux粉丝的blog

  1. 首页
  2. unix/linux
  3. 正文

SLUB: Unable to allocate memory on node -1

1 12 月, 2020 2270点热度 0人点赞 0条评论

补一篇几周前的小问题,涉及 linux 内核 bug,需要升级,或者改开机参数,关闭kmem支持的特性。

1. 问题描述

排查客户环境节点无法工作的时候,发现有一个节点有如下报错,这里单独记录一下。

报错类似如下 SLUB: Unable to allocate memory on node -1

[Tue Nov  3 10:21:58 2020] SLUB: Unable to allocate memory on node -1 (gfp=0x20)
[Tue Nov  3 10:21:58 2020]   cache: kmalloc-192(182:e36548f123662dfca13ff092a3ff89312391f15ce14c6a3c4a55865478299769), object size: 192, buffer size: 192, default order: 1, min order: 0
[Tue Nov  3 10:21:58 2020]   node 0: slabs: 142, objs: 5712, free: 0
[Tue Nov  3 10:21:58 2020]   node 1: slabs: 427, objs: 17871, free: 199
[Tue Nov  3 02:56:33 2020] SLUB: Unable to allocate memory on node -1 (gfp=0x20)
[Tue Nov  3 02:56:33 2020]   cache: nf_conntrack_ffff880e5b6a2880(183:4a2829c933ac6a583112215cfb3a7d83f77bd661617ea5a1d711e1003ab47157), object size: 312, buffer size: 320, default order: 2, min order: 0
[Tue Nov  3 02:56:33 2020]   node 0: slabs: 133, objs: 5613, free: 0
[Tue Nov  3 02:56:33 2020]   node 1: slabs: 206, objs: 10155, free: 255

 

2. 原因分析

找到一些介绍和redhat的知识库,这里摘抄一下:

This issue has been resolved in the RHEL 7.7 z-stream kernel version kernel-3.10.0-1062.4.1.el7 via Errata RHSA-2019:3055. The bug is being tracked in Bugzilla 1752421 respectively.

有人一句话总结--http://www.xuyasong.com/?p=2049

  • cgroup 的 kmem account 特性在 3.x 内核上有内存泄露问题,如果开启了 kmem account 特性 会导致可分配内存越来越少,直到无法创建新 pod 或节点异常。

 

3. 解决方法

  1. 升级内核至  kernel-3.10.0-1062.4.1.el7 以上版本。

目前在 arm架构的4.14 内核的机器上也发现了该问题,看来也要升到4.* 的最高版 (Linux 4.14.0-115.5.1.el7a.06.aarch64 aarch64)

2. grub 开机禁用kmem支持,如增加 cgroup.memory=nokmem 参数来启动机器,方法如下:

1
2
3
4
5
6
7
8
9
10
11
修改/etc/default/grub 为:
GRUB_CMDLINE_LINUX="crashkernel=auto net.ifnames=0 biosdevname=0 intel_pstate=disable cgroup.memory=nokmem"
生成配置:
/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
重启机器:
reboot
验证:
cat /sys/fs/cgroup/memory/kubepods/burstable/pod*/*/memory.kmem.slabinfo 无输出即可。

3.重新编译kubelet 和 runc,增加 make BUILDTAGS="nokmem" 参数,runc ,增加 make BUILDTAGS="seccomp nokmem 参数,实现起来太繁琐,pass。

以上 3 选 1,实现起来最简单的是 方式2

4. 验证

验证方法是查看新创建的 pod 的所有 container 已关闭 kmem,

  • 如果为下面结果则已关闭:

1
2
$ cat <span class="hljs-regexp">/sys/</span>fs<span class="hljs-regexp">/cgroup/m</span>emory<span class="hljs-regexp">/kubepods/</span>burstable<span class="hljs-regexp">/pod&lt;pod-uid&gt;/</span>&lt;container-id&gt;/memory.kmem.slabinfo
cat: memory.kmem.slabinfo: Input/output error

$ find /sys/fs/cgroup/memory/kubepods | grep slab | xargs cat $1

Input/output error

  • 有类似输出,表示问题依然存在

1
2
3
4
5
6
7
8
9
10
slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
radix_tree_node      112    112    584  112    1 : tunables    0    0    0 : slabdata      1      1      0
kmalloc-1024          64     64   1024   64    1 : tunables    0    0    0 : slabdata      1      1      0
kmalloc-128        15872  15872    128  512    1 : tunables    0    0    0 : slabdata     31     31      0
xfs_inode           3740   3740    960   68    1 : tunables    0    0    0 : slabdata     55     55      0
shmem_inode_cache    279    279    704   93    1 : tunables    0    0    0 : slabdata      3      3      0
ovl_inode           6336   6336    680   96    1 : tunables    0    0    0 : slabdata     66     66      0
kmalloc-512          640    640    512  128    1 : tunables    0    0    0 : slabdata      5      5      0
kmalloc-256         4864   4864    256  256    1 : tunables    0    0    0 : slabdata     19     19      0

5.  参考链接

https://access.redhat.com/solutions/4088471

下面这个链接有一个更加详细的介绍及几种解决方法,简而言之,升内核,升kubelet
https://en.pingcap.com/blog/try-to-fix-two-linux-kernel-bugs-while-testing-tidb-operator-in-k8s

https://github.com/torvalds/linux/commit/d6e0b7fa11862433773d986b5f995ffdf47ce672

https://github.com/kubernetes/kubernetes/issues/61937

https://github.com/opencontainers/runc/issues/1725

http://www.xuyasong.com/?p=2049

相关文章:

  1. Linux Kernel 5.4 on Debian 10
  2. CentOS Kernel Upgrade
  3. 有史以来最全面的UNIX/Linux命令Cheatcheet
  4. grub慢
标签: kernel kmem slub
最后更新:28 7 月, 2022

wanjie

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

This site uses Akismet to reduce spam. Learn how your comment data is processed.

归档
分类
  • network / 332篇
  • Uncategorized / 116篇
  • unix/linux / 121篇
  • 业界资讯 / 38篇
  • 公司杂事 / 11篇
  • 数码影像 / 12篇
  • 美剧 / 3篇
  • 美图共赏 / 21篇
  • 英语学习 / 3篇
标签聚合
邮件归档 网站运营 ldap ssh d90 postgres 天翼live Nginx wget Google google-chrome kubectl Ubuntu jira gitlab debian kernel nexus VPS dreamhost docker dreamhost空间 Google Voice 虚拟主机 泰国 openssl squid deepseek 浏览器 k8s

COPYRIGHT © 2008-2025 wanjie.info. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang