What’s inside Hongmeng Kernel, a.k.a HarmonyOS kernel?

Let’s take an insight and explore Huawei’s in-house Hongmeng Kernel, a.k.a HarmonyOS kernel

Weibo/Telegram post insight from Huawei’s engineer in HQ China and friends at Dresden, Germany R&D:

Many people pay attention to kernel research, but it has always been relatively unpopular. Compared with the application framework (AOSP/OpenHarmony), it is not very noticeable to users. However, the challenges faced (such as security, scheduling, performance and power consumption, and fault tolerance) are very arduous. Once they are not done well, they will become the target of public criticism. I hope that more friends can join the ranks of system/kernel research and solve these challenges together.
Secondly, I see a few high-frequency questions and respond briefly:

  1. Is the Hongmeng kernel a Linux shell?

No. The Hongmeng kernel (this time Next’s REE OS, not just TEE OS) includes the core kernel (Core Kernel) and a series of system services (OS Services, such as FS memory/process management), all of which are developed from scratch. Many friends have this question mainly because they think that the amount of work to redevelop a new kernel is too huge. In fact, the biggest challenge in the development of engineering is the construction of the ecosystem (such as the application ecosystem, the driver ecosystem, and the functional complementation of its use). The basic functions of the kernel itself are actually not as difficult as imagined and are completely feasible. One example is that the initial version of ChCore was built from scratch by several of our PhD brothers. At that time, the version could already run complex ROS2 through muslo (of course, the stability and functionality are not the same as the Hongmeng kernel). In terms of ecosystem construction, we have proposed a series of technologies that are compatible with the existing upper-layer software/driver ecosystem under the premise of controllable engineering workload. We will share them on OSDI.

Native OpenHarmony HDC shell toolchain of inside Hongmeng Kernel function blocks
Kernel info revealing HongMeng Kernel version 1.9.0.B100 on tablet and phone below

  1. Why replace Linux in the mobile phone scenario?

The main advantages of Linux are its ecosystem and excellent performance in scenarios such as servers. However, in the case of terminal hardware customization, power consumption performance is equally important (servers are not very concerned), and security demands are becoming more and more critical. The Hongmeng kernel is mainly focused on security (reducing TCB, system service isolation), customization cost. (System service decoupling), and evolution difficulty (deploying different products using different system services and different composition forms). We will also introduce them in detail in the OSDI paper.

  1. What are the main challenges of microkernels?

In fact, there is no shortage of microkernel research in academia and industry, such as 14, zircon, and QNX. Most of them are aimed at embedded and real-time scenarios. In fact, the challenges faced by everyone when using them in general scenarios are similar. On the one hand, compatibility issues are to solve ecological problems (mainly drivers and applications). On the other hand, performance issues caused by architecture (such as macro kernel function calls becoming cross-address space IPC) have always been difficult to solve. In the process of implementing and optimizing the Hongmeng kernel, we identified a series of performance issues (not just IPC) and proposed a series of technologies to solve these problems. Please stay tuned for OSDI for specific technologies. If you need to know in advance, you can take a look at our previous work (circle the key points): underbridge, skybridge@ etc…

  1. Performance comparison with Linux?

First, the results of the microbenchmark LMbench will be shown in the OSDI paper. As a microkernel, the Hongmeng kernel will not surpass all aspects of micro indicators (for example, Fork, even with architectural innovations, its semantics still cause architectural performance issues, you can refer to a series of works such as k42, fork in the road.

Second, end-to-end performance involves a lot, from the coordination between the framework and the kernel to the design of kernel-aware hardware (such as scheduling/frequency modulation). The microkernel architecture enables strategies that were previously difficult to implement due to tight coupling, which is the main reason for using microkernels. The OSDI paper will also show some end-to-end test results. There are still many challenges and opportunities in the system field. I hope we can face the challenges together and do something big.

Source: Weibo/Telegram