Extended Berkeley Packet Filters (eBPF) is probably the most exciting additions to the Linux Kernel in recent times. To put it simply, eBPF is designed as a very nice middle-ground between native kernel changes, which have traditionally been very slow (arguably rightfully) to come into mainline, and kernel modules, which have become a popular footgun for anyone working at the kernel level.
My introduction to eBPF was through Pyroscope, which uses eBPF to provide continuous profiling (And anyone who's worked with code long enough knows the pain that it takes to profile a system running in Prod WITHOUT having a significant impact on performance), and over time, I've been playing around with more tools in the eBPF space, whether it's on the networking front (a la Caretta), or on the security/observability front (a la Cilium / Falco), to wilder shots like load balancing (a la Katran). But while I've grokked the "what" and "why" of eBPF, the "how" was something that was always a mystery to me.
So I dug a little to see how you can write your own eBPF-enabled program, and it turned out to be much easier than I assumed it would be... So let's see how we do it!
For this sample app, we'll write a simple Python program that will act as the userspace application and have it communicate with an eBPF program written in C (which the eBPF compiler will compile to bytecode and run at the kernel level). So let's get started.
First, let's install the bpfcc-tools and linux-headers package, which has what we need(*)
$ sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
And now we can write our code:
$ cat hello_ebpf.py
from bcc import BPF
ebpf_program = r"""
int process_start(void *ctx) {
bpf_trace_printk("A new process was started!");
return 0;
}
"""
prog = BPF(text=ebpf_program)
execve_syscall = prog.get_syscall_fnname("execve")
prog.attach_kprobe(event=execve_syscall, fn_name="process_start")
prog.trace_print()
And that's it! Our eBPF hello-worldis now ready for action. To run it, simply run the file in the terminal
$ sudo python3 hello_ebpf.py
# Depending on your package version, you may see some warnings here
In another terminal, you can kick off some processes by running commands like ls, echo, cat etc. and every time a new process starts (which internally uses the execve syscall), you'll see a message printed in the running python application.
b' bash-3713 [000] d...1 12276.629282: bpf_trace_printk: A new process was started!'
b' bash-3714 [000] d...1 12278.088251: bpf_trace_printk: A new process was started!'
b' python3-3715 [000] d...1 12278.244559: bpf_trace_printk: A new process was started!'
So, how does this work? Well, the code should be quite self-explanatory, but the important bit is the prog.attach_kprobe(event=execve_syscall, fn_name="process_start") line. What this does is create and attach a kprobe to each call to execve and runs a hook defined in process_start method, which is what is compiled to eBPF bytecode.
You can probably appreciate how this makes writing applications that can access kernel level data so much easier, and allow access at an incredibly detailed level. Want to know when a file is accessed? eBPF allows that. Want to know when a process talks to another? No problemo. Want to know when a network socket request is made? Easy, peasy!(^) eBPF's relatively straightforward interface means that even with so much fine-grained access to syscalls, picking, filtering, slicing, and dicing kernel calls is straightforward, without needing as much low-level kernel knowledge. Best of all, since eBPF is compiled to bytecode by the eBPF compiler and executed within the kernel rather than in userspace, the performance impact of these listeners is EXTREMELY low. This allows real-world applications like continuous profiling, network security, and load balancing to be driven through eBPF without worrying too much about real-world performance.
I've been playing with eBPF over the last year or so and would definitely recommend folks to look into this incredible kernel technology. Who knows, it may just be the system-level observability "silver bullet" you've been looking for.
---
(*) I'm running this on Ubuntu 22.04. Instructions may be a bit different depending on your distro. But as long as you have a fairly modern kernel version (4.1+) you should be able to get this up and running.
(^) If there's interest, I may just make this a multi-part series diving deeper into how to write these applications as well.
Well, it's that time of the year again isn't it? After a year that's brought us some incredible movies, it's time for the much awaited (or so I've been told) list of my favorite movies of 2022. I genuinely felt that this year was the first year since COVID began when movies really kicked back into high gear. So many great movies across the year that picking a single "Best Of" list really doesn't do justice. But let me try my best to put across my opinion nonetheless. Here we go!:
13. Rosaline
The story of Romeo and Juliet has been hashed and rehashed over and over for centuries at this point. But have you ever heard the story from the perspective of Romeo's ex-girlfriend, Rosaline? That's the one-line pitch for this quirky movie, which pretty much went under the radar this year. This genre of modern-day takes on classics is a guilty pleasure of mine, and if you add in some great comic timing, paired with a really fun jilted-girlfriend performance by
Kaitlyn Dever, then you have yourself a very enjoyable watch!
12. Happening
Annie Ernaux, who won the Nobel Prize for Literature this year, wrote the book that this movie is based on, which deals with the topic of an unwanted pregnancy in a country where abortions are illegal (1960s France). What should, in any decent democratic state, be a simple, straightforward process to give someone authority over their own body is unfortunately rarely the case. In a landmark year where the gReaTEsT DEmOCRaCY has taken away the rights of half their population's to choose, it really goes to show how history can be cyclic.
Three other movies that deal with the theme of women dealing with a system stacked against them from this year that I enjoyed were Saani Kaayidham, Gargi and Qala. In each of these, the central themes couldn't be more different from each other, nor could the director's vision. But all three movies tell stories of resiliency in the face of sheer adversity, led by excellent leading actors.
11. Triangle of Sadness
No annual "best of" list is complete without a dark satirical comedy cementing it's place in it, and boy oh boy, is Triangle of Sadness the most juicy satire you'll see all year! Since Force Majeure, Ruben Östlund has carved out a name for himself as a director to watch out for, and Triangle of Sadness really does deliver on that promise. The story, which starts off on a cruise-liner for the super-rich, deals with the class divide in a delightful way, and will leave you in splits when you watch it, but then kicks off an eternity thinking of the layers below the surface. And while the movie does leave you with a bit of an open ending, it's been interesting to discuss with friend how they interpret the ending, because it's a glimpse into their rationalization rather than the movie itself.
If you are a fan of quirky, satirical movies, then another fun movie from this year was Official Competition
10. Bullet Train
Cinema is all about escape, and no genre of cinema promises more escape than the action thriller/comedy. And you've got to admit, in recent years, the bar for action movies has been quite high. And for me, the movie that defined the genre this year was Bullet Train. The John Wick series is such a guilty pleasure for me, so when the new David Leitch movie came out, it was a must-watch! Set almost entirely on a single train (Snowpiercer vibes anyone?), the movie tracks a bunch of zany characters, connected to each other in one way or another, culminating in action set pieces that are oh-so-beautiful interspersed with a tonne of out-and-out comedy, and callbacks that'll give you major whiplash in all the best ways!
I maintain a list of movies that I enjoyed watching through the year, and the first movie that made it on was Ambulance which is in the similar genre, and truly Michael Bay doing what Michael Bay does best. And of course, Top Gun Maverick is another movie in the same genre from this year that deserves a watch! Monica, O My Darling and Knives Out: Glass Onion are other Action comedies I enjoyed this year
9. The Fabelmans
I'm an absolute sucker for movies that tell stories that are very personal to the director, and who better to tell a story about his own life then the king himself, Steven Spielberg. The Fabelmans is a story of a fictional family, but is based closely on the director's own childhood and details the coming-of-age story of a kid who loves movies and the extents he'll go to in order to be able to do what his heart tells him to do. Like classics like Cinema Paradiso, this movie is a love-letter to movie-making as much as it is the story of a cinema-obsessed child in a dysfunctional family in 1960s USA. As someone obsesses with movies, watching The Fabelmans was a throwback to the freedom and obsession that only young adulthood can provide.
Two other movies in a similar vein I enjoyed watching in 2022 were Licorice Pizza and Chello Show (Though the latter is a bit too "inspired" by Cinema Paradiso for my liking)
8. Love Today
Modern relationships are rarely captured well in Indian rom-coms, with most movies being written quite obviously by middle-aged teams trying to capture what modern relationships look like. And this means just randomly throwing in some Millenial/Gen Z lingo for brownie points and calling it a day. But out of the blue, a movie like
Love Today comes out and shows you how it's done. The premise is simple: A girl's father asks the couple to exchange their mobile phones with each other for a day as a precondition to accept their alliance, and all hell breaks loose. But the execution is where this movie shines! Fron the creative editing and jumpcuts, to the quirky background score, to the incorporation of tech in the movie, to storypoints that'll have you laughing out loud,
Love Today manages to craft an interpretation of a RomCom that I hope more folks try to emulate.
Hattip to
Pradeep Ranganathan, who both directs the movie and plays the main
doofus protagonist
of the movie
7. The Batman
This was finally the year when it happened. "Peak Superhero" was finally reached, and specifically with the MCU, it felt like I'm officially too old to see more CGI-heavy rehashes of the same story from the Russos. But like The Joker from a few years back, a new, refreshing take on the caped crusader was just what the doctor ordered! The Batman was by far the best superhero movie of the year IMO. I loved Matt Reeves' take on the hero, and returning him back to the detective roots was such a great creative decision (from whatever it is that the awful Justice League batman was). While I did initially have reservations about the choice of Pattinson as Batman, the screenplay of this entire movie played very well into his strengths as an actor. Not to mention Paul Dano in a very unique interpretation of The Riddler that was the cherry on the cake!
6. A Hero
From a superhero to a movie where performing a heroic act creates the central tension in the film.
A Hero is another installment of the "
slice of Iranian life presented in the form of a story" series of films by
Asghar Farhadi (
of The Salesman and A Seperation fame) that deals with the ramifications of a "
heroic act" that a prisoner performs while out on parole. There's few directors who manage to meld in distinct cultural markers of their cultures into their movie-making (
Panahi being the obvious other name for Iranian cinema,
and Zhangke for Chinese cinema), and with
A Hero,
Farhadi shows how he has perfected the balancing act of telling a story while offering a glimpse into society that it's based in.
5. Kantara
If you are from India, then you should just skip the next two movies on the list because you've probably heard enough about these movies for the better half of the last 3-4 months. But heck, the praise for both is extremely well deserved. Kantara by Rishab Shetty, who's also lead actor in the movie, is a movie that takes the much-explored "bad-landlord good-villagers" trope and blends together with elements from local mythology/folklore into a spectacle that's been causing waves across the country for months. Having grown up being part of the Dakshin Kannada culture and having experienced events like Bhuta-kola and others personally, seeing a action fantasy that incorporates these into it's story with arguably the best cinematography and sound design that Kannada cinema has ever seen was absolutely surreal. The movies I most closely compare Kantara to are Jallikattu and Tumbbad, both of which have made it onto my yearly lists in the past for many of the same reasons that I loved Kantara!
Kantara does have it's fair share of elements of horror, but this has been a great year for horror fans nonetheless with movies like Hatching, Nope, and Smile providing plenty of spooks.
4. Vikram
If Kannada cinema delivered us Kantara, then Tamil cinema was not one to be left behind with Vikram. Yes, I know all the problems this movie has. Yes, it may not have a deep social message behind it. Yes, it's "massy" in the most massy way possible. But I'll fight anyone who'll say Vikram wasn't an absolute blast of a movie. Kamal Hassan + Fahadh Faasil + Vijay Sethupati (+ Suriya being a tease) in a movie directed by Lokesh Kanagaraj and music by Anirudh Ravichander. What more can a Tamil movie fan ask for? Heck, I walked out of this movie and hummed "Plata o plomo" for a week. If there's one cinematic universe I'm in for for 2023, it has to be the Lokiverse (and yes, I know how ridiculous that sounds as well... bite me! 😆)
Speaking of massy, two other mainstream movies I enjoyed this year were 83 (which I still can't believe flopped quite badly), and Sita Ramam (which is a great example of romantic dramas done right)
3. Boiling Point
Folks who know me know my relationship with cooking that has developed over the years into a skill I want to master, and an escape I need to have. And as such, movies and documentaries based around cooking always pique my interest. Boiling Point is just that. The movie is a one-shot movie set in a restaurant over a single night, moving from person to person, between the head chef, the sous, the managers, the servers, the dishwashers, and the guests. I have a few friends working in the food industry, and their anecdotes of working in a professional restaurant aligned with this movie quite a bit while making me feel extra-cushy about my "sit in shorts and work with code" career. Boiling Point hammers in the stresses that hover below the surface of most restaurants. I promise you'll not complain about tardy waiters or food taking too long for a few weeks after watching this movie!
Another excellent movie based on the theme of food is The Menu, which features Ralph Fiennes as as mysterious chef at an exclusive luxury restaurant where a select group of people get invited for dinner.
2. Everything Everywhere All At Once
There was one movie about multiverses that was heavily publicized this year, and another one that was actually a great movie
. The latter was
Everything Everywhere All At Once. I really don't know how to even explain this movie to someone to get them interested in it, so I won't even try. Just know two things: 1) That this is a movie about a middle aged woman who discovers she can jump between multiverses and 2) That when you will walk out from this movie, you'll come out with a wide smile, a blown mind, and a full heart!
Michelle Yeoh puts forth an incredible performance as the protagonist, but is supported equally well by
Ke Huy Quan who playes her husband.
The Daniels' are slowly proving their mettle as the Absurdist duo (
their previous feature was the whimsical Swiss Army Man). As an addon, you
have to see
this WIRED feature on how they've mastered the art of building CGI on a budget in an age where Bollywood struggles even today with basic CGI.
1. Tár
A movie that I keep debating about with
Arch is the 2014 movie
Whiplash, which is one of my all time favorite movies. And the debate is always the same. Do the results justify the methods when we're talking about the process of learning?
Tár deals with the same subject but modifies the question a little to ask: Does brilliance justify the behaviour that it comes from? We've heard all the stories of
Steve Jobs being an A-hole which many folks justify would justify with some variant of "
He deeply cares about the product hence...". Or everytime you see
The Shining, and knowing that
Kubrick pretty much psychologically tortured Duvall, which translated into one of the best pieces of acting. And of course the eternal question of "
Can you seperate the art from the artist?".
Tár attempts to explore some of these questions
through the story of the titular Lydia Tár, who's a world famous orchestra conductor
. Cate Blanchett pulls a powerhouse performance in this (
I'll be surprised if she doesn't win the Oscar for this role). Long after the credits roll, you'll be left pondering about the questions this movie raises!
Honorable Mentions: Gehraiyaan, After Yang, Jalsa, The Northman, Kaun Pravin Tambe?, 7 Days, Chup, Prey, The Banshees of Inisherin, All Quiet On The Western Front, Fresh, Pleasure, Jana Gana Mana
All in all, 2022 was a momentous year in terms of the world returning to a semblance of normalcy after a couple of crazy years. And it looks like 2023 is only going to get bigger and better! So as always, here's hoping that 2023 brings with it more great experiences for everyone and I hope to see you all the movies!