[Red Hat Enterprise Linux文档](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/?version=7) 。Red Hat Enterprise Linux(RHEL)是老牌Linux厂商Red Hat出品的面向商业的Linux发行版。Red Hat网站上的这个文档中有很多很有价值的内容,值得一看。
[Learn Linux Kernel from Android Perspective](http://learnlinuxconcepts.blogspot.com/2014/10/this-blog-is-to-help-those-students-and.html) ,从Android的角度来学习Linux内核,这个站点上的Blog相对于前面的比较简单易读一些。
[Optimizing web servers for high throughput and low latency](https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/) ,这是一篇非常底层的系统调优的文章,来自DropBox,从中你可以学到很多底层的性能调优的经验和知识。
# 内存相关
计算机内存管理是每一个底层程序员需要了解的非常重要的事儿。当然,这里我们重点还是Linux操作系统相关的内存管理上的知识。
首先,LWN.net上有一系列的 “**What every programmer should know about memory**” 文章你需要读一下。当然,你可以直接访问一个完整的 [PDF文档](http://futuretech.blinkenlights.nl/misc/cpumemory.pdf)。下面是这个系列文章的网页版列表。读完这个列表的内容,你基本上就对内存有了一个比较好的知识体系了。
- [Part 1: Introduction](https://lwn.net/Articles/250967/) ,中译版为 “[每个程序员都应该了解的内存知识【第一部分】](https://www.oschina.net/translate/what-every-programmer-should-know-about-memory-part1)”
- [Part 2: CPU caches](https://lwn.net/Articles/252125/)
- [Part 3 (Virtual memory)](http://lwn.net/Articles/253361/)
- [Part 4 (NUMA systems)](http://lwn.net/Articles/254445/)
- [Part 5 (What programmers can do - cache optimization)](http://lwn.net/Articles/255364/)
- [Part 6 (What programmers can do - multi-threaded optimizations)](http://lwn.net/Articles/256433/)
- [Part 7 (Memory performance tools)](http://lwn.net/Articles/257209/)
- [Part 8 (Future technologies)](https://lwn.net/Articles/258154/)
- [Part 9 (Appendices and bibliography)](https://lwn.net/Articles/258188/)
然后是几篇和内存相关的论文。下面这三篇论文是我个人觉得能对你非常有帮助的文章,尤其是你要做一些程序的性能优化方面。
[Memory Barriers: a Hardware View for Software Hackers](http://irl.cs.ucla.edu/~yingdi/web/paperreading/whymb.2010.06.07c.pdf)。内存的读写屏障是线程并发访问共享的内存数据时,从程序本身、编译器到CPU都必须遵循的一个规范。有了这个规范,才能保证访问共享的内存数据时,一个线程对该数据的更新能被另一个线程以正确的顺序感知到。在SMP(对称多处理)这种类型的多处理器系统(包括多核系统)上,这种读写屏障还包含了复杂的缓存一致性策略。这篇文章做了详细解释。
[A Tutorial Introduction to the ARM and POWER Relaxed Memory Models](http://www.cl.cam.ac.uk/~pes20/ppc-supplemental/test7.pdf),对ARM和POWER的宽松内存模型的一个教程式的简介。本篇文章的焦点是ARM和POWER体系结构下多处理器系统内存并发访问一致性的设计思路和使用方法。与支持较强的TSO模型的x86体系结构不同,ARM和POWER这两种体系结构出于对功耗和性能的考虑,使用了一种更为宽松的内存模型。本文详细讨论了ARM和POWER的模型。
[x86-TSO: A Rigorous and Usable Programmer’s Model for x86 Multiprocessors](http://www.cl.cam.ac.uk/~pes20/weakmemory/cacm.pdf),介绍x86的多处理器内存并发访问的一致性模型TSO。
关于网络调优,你可以看一下这个文档 [Red Hat Enterprise Linux Network Performance Tuning Guide](https://access.redhat.com/sites/default/files/attachments/20150325_network_performance_tuning.pdf)。
[Making Linux TCP Fast](https://netdevconf.org/1.2/papers/bbr-netdev-1.2.new.new.pdf) ,一篇非常不错的TCP调优的论文。
下面是在PackageCloud上的两篇关于Linux网络栈相关的底层文章,非常值得一读。
[Monitoring and Tuning the Linux Networking Stack: Receiving Data](https://blog.packagecloud.io/eng/2016/06/22/monitoring-tuning-linux-networking-stack-receiving-data/)
[Monitoring and Tuning the Linux Networking Stack: Sending Data](https://blog.packagecloud.io/eng/2017/02/06/monitoring-tuning-linux-networking-stack-sending-data/)
## 网络协议
接下来,想要学习网络协议最好的方式就是学习通讯相关的RFC。所以,在这里我会推荐一系列值得读的RFC给你。读RFC有几个好处,一方面可以学习技术,另一方面,你可以通过RFC学习到一个好的技术文档是怎么写的,还能看到各种解决问题的方案和思路。
对于第2层链路层,你可能需要了解一下ARP:
- [RFC 826 - An Ethernet Address Resolution Protocol](https://tools.ietf.org/html/rfc826)
以及Tunnel相关的协议:
- [RFC 1853 - IP in IP Tunneling](https://tools.ietf.org/html/rfc1853)
- [RFC 2784 - Generic Routing Encapsulation (GRE)](https://tools.ietf.org/html/rfc2784)
- [RFC 2661 - Layer Two Tunneling Protocol “L2TP”](https://tools.ietf.org/html/rfc2661)
- [RFC 2637 - Point-to-Point Tunneling Protocol (PPTP)](https://tools.ietf.org/html/rfc2637)
对于第4层,你最需要了解的是TCP/IP了。和TCP相关的RFC相当多,这里给一系列经典的RFC。这些RFC我都引用在了我在CoolShell上的《[TCP的那些事儿(上)](https://coolshell.cn/articles/11564.html)》和《[TCP的那些事儿(下)](https://coolshell.cn/articles/11609.html)》两篇文章中。如果你看不懂RFC,你也可以去看我上述的文章。
[RFC 793 - Transmission Control Protocol](https://tools.ietf.org/html/rfc793) - 最初的TCP标准定义,但不包括TCP相关细节。
[RFC 813 - Window and Acknowledgement Strategy in TCP](https://tools.ietf.org/html/rfc813) - TCP窗口与确认策略,并讨论了在使用该机制时可能遇到的问题及解决方法。
[RFC 879 - The TCP Maximum Segment Size and Related Topics](https://tools.ietf.org/html/rfc879) - 讨论MSS参数对控制TCP分组大小的重要性,以及该参数与IP分段大小的关系等。
[RFC 896 - Congestion Control in IP/TCP Internetworks](https://tools.ietf.org/html/rfc896) - 讨论拥塞问题和TCP如何控制拥塞。
[RFC 2581 - TCP Congestion Control](https://tools.ietf.org/html/rfc2581) - 描述用于拥塞控制的四种机制:慢启动、拥塞防御、快重传和快恢复。后面这个RFC被 [RFC 5681](https://tools.ietf.org/html/rfc5681) 所更新。还有 [RFC 6582 - The NewReno Modification to TCP’s Fast Recovery Algorithm](https://tools.ietf.org/html/rfc6582) 中一个改进的快速恢复算法。