Given the limited fixed size of kernel stack, my guess is that although theoretically we might have a recursive function if its recursion doesn't go too deep, pragmatism would suggest to do away with recursive functions all together, to be on a safer side. After all, too much of recursion can result in wiping off the *thread_info_t* struct and a resultant kernel panic
Yes!Maybe some of the recurive calls are either documented or part of function names? Then, a find/grep should reveal them. Here is a command to do it:
Piping this through | wc -l gives me 270, which is, since -ls prints one additional line per file, at least 135 files+functions. Let's have a look at the first match:
The match is a comment:
in front of the method
and in fact, line 2486 and neighbours are:
Since the question was, whether there is any recursive function, we don't have to visit the next 135 or more matches or search for not explicitly mentioned recursions. The answer is Yes! |
|||
|
|
|
The Linux kernel coding style does not prohibit recursive functions. You do need to be careful and not overflow the stack, but that caution is not specific to recursive functions. Don't gratuitously use recursion when a loop would do, and keep in mind that you and the functions calling you only get 8kB total, but occasionally recursion is the right tool. |
|||
|
|
|
Current kernels have over 10 million lines of code. I'm convinced somewhere some of all these lines of code are recursive. Recursive programming is very powerful and you don't have to run many levels deep to make it pay. |
|||
|
|
