Featured post

What they don’t tell you about demand paging in school

This post details my adventures with the Linux virtual memory subsystem, and my discovery of a creative way to taunt the OOM (out of memory) killer by accumulating memory in the kernel, rather than in userspace.

Keep reading and you’ll learn:

  • Internal details of the Linux kernel’s demand paging implementation
  • How to exploit virtual memory to implement highly efficient sparse data structures
  • What page tables are and how to calculate the memory overhead incurred by them
  • A cute way to get killed by the OOM killer while appearing to consume very little memory (great for parties)
Continue reading

Tips for submitting your first Linux kernel patch

Congratulations! You just finished developing your first contribution to the Linux kernel, and are excited to submit it. The process for doing so is tricky, with many conventions that the community has developed over time, so here is what I learned after doing so for the first time. This is intended to be a succinct supplement to the official contribution documentation.

Continue reading

3 Key Habits I Used to Learn Chinese

After failing three times, on my third try learning Chinese I actually became conversational. Here’s what I did, which is generally applicable to any language:

  1. I used Duolingo for 30 minutes every day for over a year.
  2. I went to Chinese language exchanges twice a month, for a year and a half.
  3. I used Hellotalk to find a great language partner to chat and do video calls with. I also used it to crowd source corrections for my bad Chinese.

That’s it! The key is consistent effort over a long time (2 years), mixing solo practice and real conversation.

Other tips:

Continue reading

Don’t confuse std::move and std::forward

This was a pretty interesting buggy scenario I found while reading the clang-tidy checks. If you’re writing a function that takes a forwarding reference (what looks like an rvalue reference, but whose type is a template argument), you need to be careful to not call std::move on it. You need to make sure to call std::forward instead. Otherwise, you might accidentally trigger a move on an object passed by a caller! This would be confusing, since their object would be moved from, and they never explicitly called std::move on it.

Continue reading