Podman 和 Docker Rootless 实践
最近在配置公用机器的环境,需求是很多用户需要使用 docker,但是众所周知,有 docker 权限就等于有了 root 权限,因此正好想尝试一下现在的 Rootless 容器化方案,例如 docket rootless 和 podman。
最近在配置公用机器的环境,需求是很多用户需要使用 docker,但是众所周知,有 docker 权限就等于有了 root 权限,因此正好想尝试一下现在的 Rootless 容器化方案,例如 docket rootless 和 podman。
有一台 AArch64 机器安装了 CentOS 7,想要升级到 CentOS 8,这篇博客主要讲讲折腾的整个过程,而不是教程:如果真要说,就是不要升级 CentOS 大版本,直接重装吧。如果真的想折腾,可以看看下面的内容。
VFIO 是 Linux 内核中的一个功能,目的是把 PCIe 设备暴露给用户态的程序,进而可以暴露给虚拟机内的系统,也就是常说的虚拟机 PCIe 直通。为了保证安全性,VFIO 还会配置好 IOMMU,保证用户态程序无法利用设备的 DMA 访问到其他地址空间的数据。
本文探讨 VFIO 暴露的用户态 API 以及如何在用户态中使用 VFIO 直接控制 PCIe 设备。
在密码学中,经常会涉及到模乘操作:\(a * b \bmod N\)。朴素的实现方法是,先求出 \(a * b\),再对 N 进行除法,那么余数就是模乘的结果。
但由于此时的 \(a\) \(b\) \(N\) 三个数都很大,在计算机上需要用大整数来表示,而大整数的乘法和除法都是需要耗比较多的时间的。如果用 Schönhage–Strassen 算法,计算两个 \(n\) 位大整数的乘法需要的时间是 \(O(n \log(n) \log(\log(n)))\)。
Montgomery 模乘是一种提高模乘的性能的方法。具体地,Montgomery 模乘需要一个参数 \(R\) 满足 \(R\) 和 \(N\) 互质,且 \(R > N\),那么 Montgomery 模乘实现的是如下计算:
前段时间,@lwpie 发现一段 C++ 代码在 macOS 下,分别用自带的 Clang 编译和用 Homebrew 的 GCC 编译,性能差距接近一个数量级,下面是运行时间:
bash 和 zsh 都实现了 POSIX shell 标准,因此写脚本的时候,比较容易兼容这两种常见的 shell。但现在 fish 也很流行,而 fish 不符合 POSIX shell 标准,很多地方语法多不兼容,能否写一个脚本,可以用 bash,zsh 和 fish 跑?
距离上一次 Jekyll 迁移到 Hugo 已经过去了四年,这次正好 mkdocs-material 发了新的 beta 版本,加入了对博客的支持,所以就当小白鼠,把博客迁移到了 Mkdocs + Mkdocs-Material。
这次迁移比较顺利,除了 tag 和 category 少了一些页面以外,原来的文章的链接都是正常的。为什么要迁移呢,主要是最近写各种文档,Mkdocs 用的比较多,但是 Mkdocs 的 Markdown 很多地方和 Hugo 不太一样,下面列一些最难以忍受的 Hugo 的问题:
\
需要转义,导致很多地方写数学公式都很麻烦,然后因为我经常要在 Hugo 和 Mkdocs 之间复制 Markdown,此时就需要很多手动工作。迁移的时候有很多细节上的不同,不过基本靠 VSCode 的正则表达式替换解决了。
不过,Mkdocs 又出现了 Jekyll 的老问题,就是性能比较差。当然了,不一定是 Mkdocs 本身的问题,也可能是 Mkdocs-Material 加各种插件的问题,目前还有待观察。无论如何,Python 调起来总归是比 Ruby 要容易。希望不要在未来的某一天,由从 Mkdocs 迁移回 Hugo。
上一次折腾 Gentoo/Prefix 是五年多以前,当时还是用的 Intel Mac,最近需要探索一下在现在的 macOS 系统上用 Gentoo/Prefix 会遇到哪些问题,因此今天在 Apple M1 上重新尝试一次。
本文的内容已经整合到知识库中。
STP(Spanning Tree Protocol)可以在 802.1D-1998 第 8 章中找到。STP 协议工作在交换机上,需要根据交换机连接的拓扑,自动计算出一个生成树,并且把不在生成树上的边禁用,这样即使连接的拓扑有环路,禁用以后就没有环了。有了 STP 以后,连接交换机的时候就可以刻意连成环,从而提供冗余。
之前用 libvirtd + virt-manager 做 Linux 上的虚拟化,好处是比较轻量级,但是远程控制起来比较麻烦,要么通过 RDP 访问 virt-manager 的 UI,要么就用 cockpit 在网页里去配置虚拟机。此时就会比较怀念 VMware ESXi 的网页,但是 ESXi 装完以后,宿主机就很不自由了,很多东西没法自定义。最后就想到在 Debian 上装一个 Proxmox VE,希望得到一个比较好的中间态。
OpenLDAP 是一个开源的用户系统实现,主要支持 LDAP 协议,可以给其他系统提供用户认证。下面讨论了如何在 Docker 中部署 OpenLDAP。
最近设计了一款 PMOD SPI NOR Flash 扩展板,搭载了 W25Q128 SPI NOR Flash 芯片。在 jlc 生产回来以后,通过 JLink 连接到电脑上进行测试,看看是否可以用 JLink 操作 SPI NOR Flash。
In short, the commit introduced by Linux 6.2.13:
commit 0d30989fe9a176565d360376d4bc2ea1c61cbbac
Author: Liam R. Howlett <Liam.Howlett@oracle.com>
Date: Fri Apr 14 14:59:19 2023 -0400
mm/mmap: regression fix for unmapped_area{_topdown}
commit 58c5d0d6d522112577c7eeb71d382ea642ed7be4 upstream.
The maple tree limits the gap returned to a window that specifically fits
what was asked. This may not be optimal in the case of switching search
directions or a gap that does not satisfy the requested space for other
reasons. Fix the search by retrying the operation and limiting the search
window in the rare occasion that a conflict occurs.
Link: https://lkml.kernel.org/r/20230414185919.4175572-1-Liam.Howlett@oracle.com
Fixes: 3499a13168da ("mm/mmap: use maple tree for unmapped_area{_topdown}")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reported-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
While fixing a BUG, a new BUG is introduced, causing MAP_32BIT to fail to work sometimes, and Xilinx's Digilent driver uses this parameter, causing mmap to fail and unable to recognize the FPGA.
The new BUG has been fixed in [PATCH v2] maple_tree: Make maple state reusable after mas_empty_area().
简单来说,Linux 6.2.13 引入的 commit:
commit 0d30989fe9a176565d360376d4bc2ea1c61cbbac
Author: Liam R. Howlett <Liam.Howlett@oracle.com>
Date: Fri Apr 14 14:59:19 2023 -0400
mm/mmap: regression fix for unmapped_area{_topdown}
commit 58c5d0d6d522112577c7eeb71d382ea642ed7be4 upstream.
The maple tree limits the gap returned to a window that specifically fits
what was asked. This may not be optimal in the case of switching search
directions or a gap that does not satisfy the requested space for other
reasons. Fix the search by retrying the operation and limiting the search
window in the rare occasion that a conflict occurs.
Link: https://lkml.kernel.org/r/20230414185919.4175572-1-Liam.Howlett@oracle.com
Fixes: 3499a13168da ("mm/mmap: use maple tree for unmapped_area{_topdown}")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reported-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
修复了 BUG 的同时,引入了新的 BUG,导致 MAP_32BIT 有时无法工作,而 Xilinx 的 Digilent 下载器代码使用了这个参数,导致 mmap 失败,无法识别 FPGA。
新 BUG 在 [PATCH v2] maple_tree: Make maple state reusable after mas_empty_area() 中被修复。