As an interesting aside, we use the well-known gnuplot(1) utility to plot a graph from the previously gathered data. Actually, we have to minimally modify the kernel module to only output what we'd like to graph: the required (or requested) amount of memory to allocate (x axis), and the percentage of waste that actually occurred at runtime (y axis). You can find the code of our slightly modified kernel module in the book's GitHub repository here: ch8/slab4_actualsz_wstg_plot (https://github.com/PacktPublishing/Linux-Kernel-Programming/tree/master/ch8/slab4_actualsize).
So, we build and insert this kernel module, "massage" the kernel log, saving the data in an appropriate column-wise format as required by gnuplot (in a file called 2plotdata.txt). While we do not intend to delve into the intricacies of using gnuplot(1) here (refer to the Further reading section for a tutorial link), in the following code snippet, we show the essential commands to generate...