Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to implement a proof of concept as some academic work, for this I want to manipulate the implementation of linked lists (/include/linux/list.h) in the KVM module. More specifically, I want to execute my code and then delegate it to the real implementation. Now I have thought of two ways to do this and I am not sure which one is preferred (if any).
1. Make a Loadable Linux Module, which has macros named 'add_list2' and 'HAED_LIST_INIT2' and so on, and change the implemenetation of the KVM to address these new functions and macros. This requires me to change every function call and useage of the macros in KVM, and recompile as a module also.
2. Changing the kernels implementation in the list.h file. This will make me compile the hole kernel every time (does it?)
I'll be happy to hear any thoughts about the two options and about other options.
My read is that list.h is pervasive throughout the entire kernel and therefore you will always need to rebuild the kernel.
If you feel you need to perform your testing using the kernel, then what I'd recommend is to write a wrapper to replace the functions available by list.h and have a global control variable which when un-set directs it to use the classical list functions as offered by the kernel now, and when set directs it to use your replacement functions.
The two problems here are (1) I'm not sure that the list functions are not also used in other loadable modules, therefore it would cause you to need to unload and re-load those, or find some alternative, and (2) adding a test of the variable will therefore add one extra step to all of these functions.
The other alternative is to build the kernel twice, placing in whatever diagnostics you wish for each case and then observing the current implementation during one boot and your proposed implementation with the other boot. As a result, the metrics you'd have to gather would then need to be something which you can compare when you have two different boot instances.
My further assumption is that you're not merely playing with linked lists and really wish to test stability and/or performance of the kernel with your alternative code. Otherwise if you just wish to play with linked lists in general, then there's no reason to involve the kernel, but instead to copy to functions provided by the kernel and make a custom application and then make your changes and rebuild your custom application. That may be a good way to start though, which is to "use" the available linked list capabilities provided by the kernel in an application, and then rewrite that app to use your replacement LL capabilities and do your analysis. Since you haven't described your endgame here, I can only guess what your intentions are.
My end game actually is stated, I want to look at the LL while the KVM is using it, e.g. the vm_list is exactly this type, and I wish to intercept the process while adding, removing an entry, or just doing a list_for_each_entry call. Say I want to go over the list each time and log how many vcpus each VM has (see below). I wanted to copy the implementation to my module, and just recompile it, that would be perfect, but then I realized that I have to copy the whole KVM module to make it work. Thats where my dilemma started.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.