Category Archives: Favorite

You don’t even need to be successful

Something I’ve learned through my streaming project is that you don’t even need to be super “successful” at what you’re doing to build an audience of people that are excited for you and want to support you.

Based on my experience, you just need to be:

  • trying hard
  • at something hard
  • consistently
  • in public

I wouldn’t say I’ve been so “successful” at building an OS. It currently doesn’t even really boot or do anything yet. It does not support running programs at all. All it can do is kind of initialize the hardware and slowly initialize itself to the point where it’s almost ready to run programs. (And I didn’t even write a lot of that code. A lot of it was provided by the base foundation for the course I’m following.)

And none of that matters. People are still excited about what I’m doing, even though it’s not novel in the slightest, and I’m not that “successful”. What matters is simply that I’ve been trying, a lot, and talking about it.

Life is a business; life is a game; life is art

Here are three ways to view your life:

Life as a business

Life is a business, and you are the Founder & CEO.

You have goals, resources, and agency. The idea is to build the strongest business and life for yourself. You do this by making good decisions and generating profit.

The most savvy founders look for holes in the fabric of society, the market, their industry — and exploit them. They seek trends that allow them to be ahead of the curve.

Life as a game

Life is a game, and you are a player.

You are initialized with random parameters that inform your strengths, weaknesses, and initial environment. There’s an endless world in front of you to explore and play in.

The idea is to do well at the game — build points, power, connections. You encounter other players, transact with them, exchange moves, determine if they are trustworthy or hostile.

You learn the rules over time and understand what game you are even playing. You discover that within the greater context of “the game”, there are many sub-games you can play.

Randomness and luck are all built into the game.

Life as an art piece

Life is an art project, and you are the artist.

You have a blank canvas in front of you and an infinite number of creative decisions to make. The idea is to find a beautiful & satisfying creative endpoint for your piece.

There are many creative paths to take, leading to different ends. There is no best end, but some ends are better than others.

Like any other artist, you must apply techniques to manage the decision space. You apply constraints — sometimes artificially, sometimes destructively — to move forward.

Sometimes, you just need to be willing

Sometimes, you just need to be willing. No special skills or particular competence necessary — simply just being willing to do something others can but won’t do.

I learned and have profited from this realization at work in the past year. A certain set of important tasks on my team are somewhat hands-on in nature and not compatible with remote work. Our colleague that usually does these left the team. I stepped up and filled this gap.

The work is not particularly difficult — my teammates are smarter than me and could surely do it also. But I’m the only one that was willing and able to sacrifice remote work and commute every day. So I’ve been doing it.

Although it’s not the hardest, the work is nonetheless very important — critical, even. So I’ve been getting a lot of credit, brownie points, and even a raise from doing it.

Not because I’m smart — just willing.

How to be happy

Note to self:

  1. Remember: You are already enough just as you are, right here, right now. You don’t need to achieve or do anything. 1
  2. Remember: The only competition in life — if you must think of it that way — is to know yourself as fully as possible, and act with maximum authenticity towards that truth.
  3. Remember: All things considered, you have it good — so many around the world would kill to switch places and inherit every single one of your problems.

Linux Internals: How /proc/self/mem writes to unwritable memory

Introduction

An obscure quirk of the /proc/*/mem pseudofile is its “punch through” semantics. Writes performed through this file will succeed even if the destination virtual memory is marked unwritable. In fact, this behavior is intentional and actively used by projects such as the Julia JIT compiler and rr debugger.

This behavior raises some questions: Is privileged code subject to virtual memory permissions? In general, to what degree can the hardware inhibit kernel memory access?

By exploring these questions2, this article will shed light on the nuanced relationship between an operating system and the hardware it runs on. We’ll examine the constraints the CPU can impose on the kernel, and how the kernel can bypass these constraints.

Continue reading

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)

Note: Victor Michel wrote a great follow up to this post here.

Continue reading

How setjmp and longjmp work (2016)

Pretty recently I learned about setjmp() and longjmp(). They’re a neat pair of libc functions which allow you to save your program’s current execution context and resume it at an arbitrary point in the future (with some caveats3). If you’re wondering why this is particularly useful, to quote the manpage, one of their main use cases is “…for dealing with errors and interrupts encountered in a low-level subroutine of a program.” These functions can be used for more sophisticated error handling than simple error code return values.

I was curious how these functions worked, so I decided to take a look at musl libc’s implementation for x86. First, I’ll explain their interfaces and show an example usage program. Next, since this post isn’t aimed at the assembly wizard, I’ll cover some basics of x86 and Linux calling convention to provide some required background knowledge. Lastly, I’ll walk through the source, line by line.

Continue reading