Where did vm_operations_struct->unmap in 2.4.0 go?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
I ran into this while hacking the Nvidia kernel driver to work with 2.4.0. I got the driver working but it's not 100%
Also where did
get_module_symbol()andput_module_symbol()go?Patches for the NVIDIA binary X drivers following all these kernel changes can be gotten from IRC server irc.openprojects.net, channel #nvidia. Or from http://ex.shafted.com.au/nvidia/
Quoted 9 lines
And what a pile of crud those patches are!! Instead of using the clean replacement interface for
get_module_symbol, nvidia/patch-2.4.0-PR hard codes the oldget_module_symbolalgorithm as inline code.This patch violates the modules interface by accessing
modules.cinternal data. It still suffers from all the problems thatget_module_symbolhad. Because it is hard coded as inline code instead of a common function, will be much harder to fix when it breaks.
The way I understand the inter_module mechanism, module A registers one or several of its symbols using inter_module_register to make it or them available to other modules. Module B can then request any of the symbols with inter_module_request and get a pointer. The inter_module mechanism guarantees that the symbol will be available until module B decides that the symbol is no longer needed and releases it by calling inter_module_put.
Saying that I should have made use of this mechanism for the specific code in the Nvidia driver that we are talking about clearly shows that you didn't look at it. The module used get_module_symbol to search its own symbol table for parameters that may have been passed to it at load time. Arguably, this is bad practise, but it is also the reason why using your mechanism doesn't make any sense. Obviously, the module wouldn't want to register private data to request it later on; the information that would have to be passed to inter_module_register is the same that the code in question intends to retrieve in the first place.
Contrary to what you're saying, the patch does not just inline the old get_module_symbol algorithm nor does it access any of module.c's internal data. What is does is to browse the list of the modules's _own_ symbols looking for a match. If it finds one, it returns the desired data.
Quoted 3 lines
Whoever coded that patch should be taken out and shot, hung, drawn and quartered then forced to write COBOL for the rest of their natural life.
Excellent comment - it is just as appropriate as it is helpful.
--
----------------------------------------------------------------------
christian zander we come to bury dos, not to praise it.
[email protected] -- paul vojta
----------------------------------------------------------------------
Quoted 5 lines · Christian Zander
Saying that I should have made use of this mechanism for the specific code in the Nvidia driver that we are talking about clearly shows that you didn't look at it. The module used
get_module_symbolto search its own symbol table for parameters that may have been passed to it at load time.
My apologies. I read the patch, not the full source code and the patch does not have enough programming context to show that the driver is only searching its own symbol space. In my own defense, the references to spinlock_t unload_lock and MOD_CAN_QUERY(mp) in the patch are highly misleading, those statements only make sense when you are looking at a symbol table for another module. When searching your own symbol table the current module must be live with a non-zero use count, not being unloaded and it can always be queried.
Quoted 3 lines
Contrary to what you're saying, the patch does not just inline the old
get_module_symbolalgorithm nor does it access any of module.c's internal data.
unload_lock and MOD_CAN_QUERY were copied verbatim from the old get_module_symbol, even though they are completely unnecessary. That looks like inlining the old algorithm to me.
struct module_symbol, mp->nsyms and mp->syms are module.c internal data. If it is ever necessary to change those structures, nothing outside module.c, the 32/64 handlers for module system calls and modutils should be affected. Now if I change module_symbol, other bits of the kernel will unexpectedly break, this is not good.
Quoted 5 lines
Quoted 3 lines
Whoever coded that patch should be taken out and shot, hung, drawn and quartered then forced to write COBOL for the rest of their natural life.
Excellent comment - it is just as appropriate as it is helpful.
Over emphasis for humorous effect. Must remember to add smiley.
What this patch and David Woodhouse's comments show is that I need to look at a generic and safe mechanism for kernel/module symbol lookup. The existing static mechanism works for fixed symbol names but does not work for symbol names that are generated at run time nor for symbols that may or may not be present.
get_module_symbol() "worked" but was horribly unsafe. It broke with module versions, it did zero type checking which left the code open to version skew and it assumed that all addresses are equivalent to an unsigned long.
That last point is especially important for IA64 where function pointers do not reference the function directly, instead they point to a function descriptor with two fields, one of which is the function address. Casting the unsigned long address of a function into a function pointer fails miserably on IA64, and gcc does not even give any warnings. foo = (int (*)(int))get_module_symbol(NULL, "funcname") is architecture dependent.
Using EXPORT_SYMBOL_NOVERS() to "fix" the modversions problem for get_module_symbol() removes all inter module checks on the relevant symbols. Not just for the caller of get_module_symbol for all modules that access those symbols. This leaves too much code open to version skew and is not acceptable.
inter_module_xxx is modversions safe. It still does no type checking because it uses void * for the data structure, but the exporter and user have to declare their common data area which reduces the chance of version skew. I am still not happy about this possibility of skew but anything is better than no checks at all. Passing a data structure which contains real declarations for function pointers instead of assuming you can cast a number to a function pointer makes inter_module_xxx architecture independent.
I will look at a general kernel and module symbol lookup routine that does the job properly. The hard part is making sure that the provider and consumer have exactly the same types for a symbol. Both get_module_symbol and inter_module_xxx completely bypass the modversions checks and are wide open to undetectable version skew, although inter_module_xxx is a little bit safer. Any replacement for these functions must be able to do type checking at run time, which probably means it is 2.5 code. And yes, David, it should be able to handle static data.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 1 line · Keith Owens
Over emphasis for humorous effect. Must remember to add smiley.
Heh. But it does deserve to get into the fortune file.
Quoted 5 lines
What this patch and David Woodhouse's comments show is that I need to look at a generic and safe mechanism for kernel/module symbol lookup. The existing static mechanism works for fixed symbol names but does not work for symbol names that are generated at run time nor for symbols that may or may not be present.
Actually, my testing showed that modutils was quite OK with symbols which may or may not be present. But compiling such code into the kernel, at least on MIPS and m68k, didn't work.
cat >weaktest.c <<EOF
#include <linux/module.h>
extern char *myfun(void) __attribute__((weak));
int init_module(void)
{
char *txt= "myfun() not present\n";
if (myfun)
txt = myfun();
printk(txt);
return 0;
}EOF
cat > myfun.c <<EOF
#include <linux/module.h>
char *myfun(void)
{
return "Hello World\n";
}
EOF
I doubt this would have implemented weak symbols completely, though. Fixing up the reference in weaktest.o if myfun.o was loaded later, etc. And we don't really want to 'fix' that either.
So it'd still have needed request_module(); get_module_symbol() if it found that myfun wasn't present and it needed it. So it might as well have used get_module_symbol() from the start instead of the weak declaration.
Quoted 5 lines
get_module_symbol()"worked" but was horribly unsafe. It broke with module versions, it did zero type checking which left the code open to version skew and it assumed that all addresses are equivalent to an unsigned long.
Quoted 7 lines
That last point is especially important for IA64 where function pointers do not reference the function directly, instead they point to a function descriptor with two fields, one of which is the function address. Casting the unsigned long address of a function into a function pointer fails miserably on IA64, and gcc does not even give any warnings. foo = (int (*)(int))get_module_symbol(NULL, "funcname") is architecture dependent.
But fixable.
Quoted 5 lines
Using
EXPORT_SYMBOL_NOVERS()to "fix" the modversions problem forget_module_symbol()removes all inter module checks on the relevant symbols. Not just for the caller ofget_module_symbolfor all modules that access those symbols. This leaves too much code open to version skew and is not acceptable.
I'm not sure there's anything which was expected to be obtained by get_module_symbol() which was also obtained by normal linking. The nature of these routines is that they're optional. Usually, the routine would be optional for all callers or it'd be mandatory for all callers. Rarely a mixture.
But what about keeping a separate table, with PUBLISH_SYMBOL() or something slightly more sensibly named? That way, get_published_symbol() can only get at those symbols which were supposed to be listed, and if someone really wants EXPORT_SYMBOL() and PUBLISH_SYMBOL() they can do that.
Quoted 4 lines
Quoted 1 line
inter_module_xxxis modversions safe. It still does no type checkingbecause it uses void * for the data structure, but the exporter and user have to declare their common data area which reduces the chance of version skew.
I'm not sure I follow. The exporter and the user have to each declare their common data area, which means they don't have to declare it identically, and there's just as much chance of version skew as before, surely? With get_module_symbol both had to declare it, too.
And 'modversions safe' just means that there's no attempt to mangle the names so it's identical to the EXPORT_SYMBOL_NOVERS case above?
Quoted 5 lines
I am still not happy about this possibility of skew but anything is better than no checks at all. Passing a data structure which contains real declarations for function pointers instead of assuming you can cast a number to a function pointer makes
inter_module_xxxarchitecture independent.
On the other hand, it's also simple enough to define a macro which does the arch-dependent equivalent of the 'foo=(fnptr_t)get_module_symbol()' above, isn't it? But I'm not particularly attached to the method. The static initialisation is what I miss.
Quoted 2 lines
I will look at a general kernel and module symbol lookup routine that does the job properly.
Thanks.
Quoted 2 lines
The hard part is making sure that the provider and consumer have exactly the same types for a symbol.
That would be useful, but it's not 100% imperative. Runtime type-checking is a nice sanity check where it's almost free, as it was in the modversions case, but I don't want to program in Java.
Signature · 6 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · David Woodhouse
On Sat, 13 Jan 2001, Keith Owens wrote:
Actually, my testing showed that modutils was quite OK with symbols which may or may not be present. But compiling such code into the kernel, at least on MIPS and m68k, didn't work.
Weak symbols were added to gcc somewhere between 2.7.2.3 and 2.91.66. At least two architectures are using versions of gcc that predate (by a few days) the addition of weak symbols. Davem hit this problem on sparc with the weak references to kallsyms, he had to define the symbols instead of letting them resolve to zero, gcc on sparc silently ignored weak.
Quoted 3 lines
I doubt this would have implemented weak symbols completely, though. Fixing up the reference in weaktest.o if myfun.o was loaded later, etc. And we don't really want to 'fix' that either.
Weak is not enough. We need dynamic symbol binding if we plan to support a cooperative model for objects instead of a strict hierarchic model.
BTW, modutils cannot automatically fill in upward references when a module is loaded. A reference is a use count, an automatic reference would be an automatic use count with no way of removing it. Code that calls upwards to a symbol must perform an overt action to get the reference and cope with the case when the symbol is not there. Think of it as a probe, "do I have facility XXX yet?". It is up to the caller to probe as often as required. Hot plugging for symbols, wheee!
Quoted 9 lines
Quoted 7 lines
That last point is especially important for IA64 where function pointers do not reference the function directly, instead they point to a function descriptor with two fields, one of which is the function address. Casting the unsigned long address of a function into a function pointer fails miserably on IA64, and gcc does not even give any warnings. foo = (int (*)(int))get_module_symbol(NULL, "funcname") is architecture dependent.
But fixable.
Probably not. The generated IA64 object code for this case is completely wrong, not surprising since we are lying to gcc.
x.o: file format elf64-ia64-little
Disassembly of section .text:
0000000000000000 <test1>:
unsigned long value = 0xc0002000; // example, not a real ia64 address
void test1(void)
{
0: [MII] alloc r34=ar.pfs,4,4,0
void (*test2)(void);
6: mov r35=r12 // &test2
c: adds r12=-16,r12 // adjust stack pointer
10: [MII] nop.m 0x0
test2 = (void (*)(void))value;
16: mov r33=b0 // save return address
12: GPREL22 value
1c: addl r14=0,r1;; // &value
20: [MMI] ld8 r14=[r14];; // value
26: st8 [r35]=r14 // test2 = value 0xc0002000
2c: nop.i 0x0
test2();
30: [MII] ld8 r14=[r35] // read test2, 0xc0002000
36: mov r32=r1;; // save current global pointer
3c: nop.i 0x0
40: [MII] ld8 r15=[r14] // dereference test2, wrong
46: adds r14=8,r14;; // test2 + 8, 0xc0002008
4c: nop.i 0x0
50: [MII] ld8 r1=[r14] // new gp from 0xc0002008, wrong
56: mov b6=r15;; // & target function, wrong
5c: nop.i 0x0
60: [MIB] nop.m 0x0
66: nop.i 0x0
6c: br.call.sptk.many b0=b6;; // call indirect function, oops
70: [MII] mov r1=r32 // restore gpBy casting 'test2 = (void (*)(void))value' we claim that value is the address of the the function descriptor which must contain
{ actual address of function, global data pointer for function }
gcc trusts us and tries to use the data at location 0xc0002000 as a function descriptor. Because get_module_symbol() returns the address of the first instruction in a function, that code would load the actual address and global pointer from the first 16 bytes of the function's code area. Needless to say, it does not work.
Fixing this would mean tweaking get_module_symbol() on IA64 to recognise that the symbol is a function, build a function descriptor on the fly and return the address of the descriptor. But the information about the types of symbols is not available in the kernel nor in modules after they are loaded, get_module_symbol() cannot differentiate between functions and anything else. There is also the small matter of grubbing around in the arch dependent bit of struct modules to find the global pointer for the target function, more complexity.
Quoted 5 lines
But what about keeping a separate table, with
PUBLISH_SYMBOL()or something slightly more sensibly named? That way,get_published_symbol()can only get at those symbols which were supposed to be listed, and if someone really wantsEXPORT_SYMBOL()andPUBLISH_SYMBOL()they can do that.
I don't see the point. EXPORT_SYMBOL() says that the symbol can be accessed by anybody. The current hierarchical binding model restricts access to modules that load after this module. If we remove the strict hierarchical binding of module symbols, why worry whether the caller is above or below this module? IOW, there is no need for a different definition that says the symbol can also be accessed by the kernel or by earlier module loads. Upward references to a symbol are another story.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
inter_module_xxxis modversions safe. It still does no type checkingbecause it uses void * for the data structure, but the exporter and user have to declare their common data area which reduces the chance of version skew.
I'm not sure I follow. The exporter and the user have to each declare their common data area, which means they don't have to declare it identically, and there's just as much chance of version skew as before, surely? With
get_module_symbolboth had to declare it, too.
get_module_symbol() was usually used with a cast from unsigned long to some type that was defined in the calling .c file. That made the caller code responsible for using the correct declaration. It is better to define interfaces as shared data in a shared header. Not perfect, but better.
Quoted 2 lines
And 'modversions safe' just means that there's no attempt to mangle the names so it's identical to the
EXPORT_SYMBOL_NOVERScase above?
With inter_module_xxx you have no type checking on the registered data. But you do not have to use EXPORT_SYMBOL_NOVERS on the shared symbols which means that any other users of the symbols will still get type checking. Again, not perfect, but better.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 7 lines · Keith Owens
BTW, modutils cannot automatically fill in upward references when a module is loaded. A reference is a use count, an automatic reference would be an automatic use count with no way of removing it. Code that calls upwards to a symbol must perform an overt action to get the reference and cope with the case when the symbol is not there. Think of it as a probe, "do I have facility XXX yet?". It is up to the caller to probe as often as required. Hot plugging for symbols, wheee!
We don't need to overdesign it. get_module_symbol() basically provided this for us. The only thing really wrong with it was the lack of use count handling, which I fixed a while ago.
Lack of runtime typechecking isn't a showstopper. Otherwise we'd have thrown out GCC by now and rewritten the kernel in Modula-3.
That leaves the IA64 problem.
Quoted 8 lines
Fixing this would mean tweaking
get_module_symbol()on IA64 to recognise that the symbol is a function, build a function descriptor on the fly and return the address of the descriptor. But the information about the types of symbols is not available in the kernel nor in modules after they are loaded,get_module_symbol()cannot differentiate between functions and anything else. There is also the small matter of grubbing around in the arch dependent bit of struct modules to find the global pointer for the target function, more complexity.
This is already handled by modutils, presumably. How? By 'grubbing arouund in the arch dependent bit of struct modules'? There's already a handful of gp handling surrounded by #ifdef __alpha__ in module.c which doesn't seem too unreasonable.
The caller knows what it's expecting to find. How about separate get_module_function() and get_module_data() routines? Which are identical on most architectures, but on (Alpha and?) IA64 could be defined to return an appropriate structure.
Quoted 5 lines
get_module_symbol()was usually used with a cast from unsigned long to some type that was defined in the calling .c file. That made the caller code responsible for using the correct declaration. It is better to define interfaces as shared data in a shared header. Not perfect, but better.
We could quite happily define the function type in a shared header file, and coding the original function and the subsequent cast from get_module_symbol() using that definition.
Conversely, nothing stops you from using only local definitions for the inter_module_xxx objects, rather than a single shared definition.
Nothing's changed. You just changed the users to use shared definitions while you converted them to inter_module_xxx. But there's no fundamental difference in the interface used, in this respect.
Quoted 4 lines
With
inter_module_xxxyou have no type checking on the registered data. But you do not have to useEXPORT_SYMBOL_NOVERSon the shared symbols which means that any other users of the symbols will still get type checking. Again, not perfect, but better.
Slightly. But for the cases where inter_module_xxx or get_module_symbol are used,
A. AFAIK there are no such 'direct' users who get the
benefit of the runtime typechecking.
B. The authors are already having to pay attention to any
changes in the type of the exported data, rather than just pretending that they're writing Java code and expecting the runtime system to wipe the dribble from their chins.
Signature · 7 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 3 lines · David Woodhouse
We don't need to overdesign it.
get_module_symbol()basically provided this for us. The only thing really wrong with it was the lack of use count handling, which I fixed a while ago.
And the fact that it doesn't work if you turn module support off, which you'd want to do on an embedded kernel. Unfortunately, this is one of the times when you do want the MTD stuff. You either have to put up with no MTD support, write your own, or put up with the extra space of module symbols.
Therefore, get_module_symbol() as it stood was the wrong interface to use, and I completely agree with Keiths decision to remove it. However, I'm not sure that the inter_* stuff that replaced it is much better for the reasons David has highlighted previously wrt link ordering.
_____
|_____| ------------------------------------------------- ---+---+- | | Russell King [email protected] --- --- | | | | http://www.arm.linux.org.uk/personal/aboutme.html / / | | +-+-+ --- -+- / | THE developer of ARM Linux |+| /|\ / | | | --- | +-+-+ ------------------------------------------------- /\\\ |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 1 line · David Woodhouse
Lack of [module symbol] runtime typechecking isn't a showstopper.
It is when users try to insert modules from kernel A into kernel B when the ABI changed between A and B. This is not type checking to catch kernel programmers, it is ABI checking to catch user errors.
This is becoming more important as the kernel moves towards hot plugging devices, especially for binary only drivers. It is far better for the kernel community if modutils can say "cannot load module foo because its interfaces do not match the kernel, upgrade module foo". That forces the maintenance load back onto the binary supplier and removes the questions from l-k, including many of the oops reports with binary only drivers in the module list.
Module symbol versions are the only way to catch ABI changes. I do not want to add a mechanism for accessing symbols dynamically if it cannot detect ABI changes, it leaves the kernel open to difficult to diagnose user errors. I'm doing the hard work now to save everybody time later.
Ignore the fact that the existing module symbol version implementation is broken as designed. http://gear.torque.net/kbuild/archive/1280.html
lists the major problems with make dep, genksyms has all those problems plus several of its own. As part of the Makefile rewrite for 2.5, I am redesigning module symbol versions from scratch.
I agree that inter_module_xxx does not check ABI. That was not for lack of trying, but it cannot be done in 2.4, it needs a major redesign of module symbols and the makefiles. It will be possible in 2.5.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 7 lines · Keith Owens
This is becoming more important as the kernel moves towards hot plugging devices, especially for binary only drivers. It is far better for the kernel community if modutils can say "cannot load module foo because its interfaces do not match the kernel, upgrade module foo". That forces the maintenance load back onto the binary supplier and removes the questions from l-k, including many of the oops reports with binary only drivers in the module list.
No. The correct response to that is _already_ "You have a binary-only module. Even in the kernel it was compiled against, you are not supported. Goodbye".
To quote our Lord and Master:
(http://lwn.net/1999/0211/a/lt-afs.html)
Quoted 5 lines
Quoted 5 lines
I will strive for binary compatibility for modules, but I _expect_ that it will be broken. It's just too easy to have to make changes that break binary-only modules, and I have too little incentive to try to avoid it.
Quoted 7 lines
Quoted 7 lines
If people feel this is a problem, I see a few alternatives:
- don't use stuff with binary-only modules. Just say no.
- work hard at making a source-version of the thing available (it doesn't have to be under the GPL if it's a module, but it has to be available as source so that it can be recompiled).
- don't upgrade
- drop Linux
(http://lwn.net/1999/0211/a/lt-binary.html)
Quoted 5 lines
Quoted 5 lines
Basically, I want people to know that when they use binary-only modules, it's THEIR problem. I want people to know that in their bones, and I want it shouted out from the rooftops. I want people to wake up in a cold sweat every once in a while if they use binary-only modules.
Quoted 9 lines · [email protected] wrote:
Ignore the fact that the existing module symbol version implementation is broken as designed. http://gear.torque.net/kbuild/archive/1280.html
lists the major problems with make dep, genksyms has all those problems plus several of its own. As part of theMakefilerewrite for 2.5, I am redesigning module symbol versions from scratch.I agree that
inter_module_xxxdoes not check ABI. That was not for lack of trying, but it cannot be done in 2.4, it needs a major redesign of module symbols and the makefiles. It will be possible in 2.5.
This is a good thing, as long as it doesn't get in the way of real functionality. We don't _need_ to make life easier for people running binary-only modules. But if we can do it without making life harder for real people, then that's nice.
Signature · 7 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 8 lines · David Woodhouse
Quoted 3 lines · Keith Owens
That forces the maintenance load back onto the binary supplier and removes the questions from l-k, including many of the oops reports with binary only drivers in the module list.
No. The correct response to that is _already_ "You have a binary-only module. Even in the kernel it was compiled against, you are not supported. Goodbye".
I wish that Linus had never agreed to binary only modules. But as long as they are allowed, I want to detect problems with binary only modules before they hit the rest of the kernel and end up as questions on l-k.
Note I said allowed, not supported. I refuse to support any binary only modules, my standard response to problems logged against binary modules is "remove them and reproduce the problem". Checking for ABI violations is not supporting binary modules, it is detecting that they are stuffed and telling the user to go pester their supplier instead of polluting l-k with questions that will be ignored.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 6 lines · Keith Owens
Note I said allowed, not supported. I refuse to support any binary only modules, my standard response to problems logged against binary modules is "remove them and reproduce the problem". Checking for ABI violations is not supporting binary modules, it is detecting that they are stuffed and telling the user to go pester their supplier instead of polluting l-k with questions that will be ignored.
Sensible. As long as it doesn't give rise to reports of the type "modutils didn't whinge so it's not the binary-only module's fault."
Signature · 7 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
In article <[email protected]>,
Quoted 4 lines · David Woodhouse
We don't need to overdesign it.
get_module_symbol()basically provided this for us. The only thing really wrong with it was the lack of use count handling, which I fixed a while ago.
NO NO NO!
You miss _entirely_ the reason why "get_module_symbol()" was removed, and why I will not _ever_ accept it coming back.
Hint #1: get_MODULE_symbol().
Hint #2: compiled in functionality.
The fact is, that get_module_symbol() was seriously and totally mis-designed from the very beginning, and it was removed for THAT reason, and it had nothing at all to do with the count handling.
So stop this discussion. It's not coming back. Live with the current interfaces.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines · Linus Torvalds
You miss _entirely_ the reason why "
get_module_symbol()" was removed, and why I will not _ever_ accept it coming back.Hint #1:
get_MODULE_symbol().
Hint #2: compiled in functionality.
Er,... forgive me if I'm being overly dense here, but I can't see anything fundamentally wrong in the above that wouldn't be fixed with a judicious application of s/module_//
But I have no particular attachment to it. All I'm asking for is a way to avoid having init order dependencies where previously there was no need for them, by having a way to put entries in the inter_module_get() table at compile time.
Signature · 7 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines · David Woodhouse
But I have no particular attachment to it. All I'm asking for is a way to avoid having init order dependencies where previously there was no need for them, by having a way to put entries in the
inter_module_get()table at compile time.
Note that previously there _were_ order dependencies. In fact, I consider it very tasteless to have modules that act differently on whether another module is loaded. I saw some arguments saying that this is th "right thing", and I disagree completely.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · Linus Torvalds
Note that previously there _were_ order dependencies. In fact, I consider it very tasteless to have modules that act differently on whether another module is loaded. I saw some arguments saying that this is th "right thing", and I disagree completely.
The only valid behaviour I can think of is...
if (!feature_present)
try_to_load_it();
if (feature_present)
use_it(); else if (we_can_live_without()) deal_with_it(); else whinge_and_die();
In this case, it's not really depending on whether the desired feature has been loaded yet or not. It's depending on whether the desired feature is available or not. In this sense, inter_module_get_request() is an improvement, because it makes that explicit.
Obviously, in the case where we'd eventually just whinge_and_die(), usually it's best to just make this code depend on whatever feature it is that's being used, by referencing it directly.
But in the case of the CFI probe code and also I believe DRM, we don't actually know precisely which feature we're going to require until we've done the hardware probe at runtime. We don't want the generic code having a hard dependency on each possible submodule, and doing it with ifdefs according to what happens to be compiled in is just ugly. So the above logic was useful, and get_module_symbol(), even though it wasn't wonderful, provided it.
The reason you didn't get the current CFI code with the rest of the update I gave you for 2.4.0-test12 is because I'm intending to rewrite it first, and hopefully deal with this issue in a better way while I'm at it.
But as it stands, the best option I can see is to have the generic probe code have ifdefs on the chipset-specific options, and reference only the ones which are present. It's not the end of the world, and as rmk suggests, many embedded systems are run without module support in production anyway.
--
dwmw2
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · David Woodhouse
But in the case of the CFI probe code and also I believe DRM, we don't actually know precisely which feature we're going to require until we've done the hardware probe at runtime.
That's ok.
This is what "request_module()" and "kmod" is all about. Once we probe the hardware, the drievr itself can ask for more drivers.
I completely fail to see the arguments that have been brought up for drm doing ugly things. The code should simply do
drm_agp_head_t * head = inter_module_get("drm_agp");
if (!head) {
request_module("drm-agp");
head = inter_module_get("drm_agp");
if (!head)
return -ENOAGP;
}and be done with it. THE ABOVE MAKES SENSE. The code says _exactly_ what the module wants to do: it wants to find the AGP support, and if it cannot find the AGP support it wants to load them.
The arguments about how the user should load things in some specific order or whatever are complete crap. All the support is there, and whining about it is not going to change my opinion in the least.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 15 lines · Linus Torvalds
This is what "
request_module()" and "kmod" is all about. Once we probe the hardware, the drievr itself can ask for more drivers.I completely fail to see the arguments that have been brought up for drm doing ugly things. The code should simply do
drm_agp_head_t * head = inter_module_get("drm_agp"); if (!head) { request_module("drm-agp"); head = inter_module_get("drm_agp"); if (!head) return -ENOAGP; }
Quoted 3 lines
and be done with it. THE ABOVE MAKES SENSE. The code says _exactly_ what the module wants to do: it wants to find the AGP support, and if it cannot find the AGP support it wants to load them.
It's the same with CFI command-set-specific code. Except that the command-set specific code didn't previously have to be initialised at all, and now we've got to initialise it (and have it call inter_module_register) before it's required by the cfi_probe code.
The difference here is that while drm_agp actually had to do some hardware initialisation, the CFI command set handlers didn't - the only thing their module_init routine does is call inter_module_register(). So we've introduced the init order dependencies where previously they weren't necessary.
That's the one flaw in the inter_module_get() stuff - we could do with a way to put entries in the table at _compile_ time, rather than _only_ at run time.
While I accept that we can't eliminate init order dependencies completely, I still think we should avoid them where it's possible. Which it would be in this case, without much difficulty at all.
Signature · 7 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · David Woodhouse
That's the one flaw in the
inter_module_get()stuff - we could do with a way to put entries in the table at _compile_ time, rather than _only_ at run time.
Ok, I can buy that. Not having to initialize explicitly would be nice, but if so we should make module loading do it automatically too, so that we don't generate unnecessary differences between module and compiled in (ie I'd rather avoid the situation that "if you're a module, you need to explicitly export your inter_module_stuff(), while if you're compiled-in it will be exported automatically").
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 11 lines · Linus Torvalds
Quoted 3 lines · David Woodhouse
That's the one flaw in the
inter_module_get()stuff - we could do with a way to put entries in the table at _compile_ time, rather than _only_ at run time.Ok, I can buy that. Not having to initialize explicitly would be nice, but if so we should make module loading do it automatically too, so that we don't generate unnecessary differences between module and compiled in (ie I'd rather avoid the situation that "if you're a module, you need to explicitly export your
inter_module_stuff(), while if you're compiled-in it will be exported automatically").
Yep. Modutils can probably handle that case without too much difficulty, if we go with sticking the static inter_module_entries in a special ELF section as I originally suggested. Keith?
Signature · 9 lines
dwmw2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · David Woodhouse
That's the one flaw in the
inter_module_get()stuff - we could do with a way to put entries in the table at _compile_ time, rather than _only_ at run time.Ok, I can buy that. Not having to initialize explicitly would be nice, but if so we should make module loading do it automatically too ...
It might be nice but it is also expensive. Adding static inter_module_xxx tables requires
* changes to linux/modules.h to define the new table format and
* changes to vmlinux.lds for _every_ architecture to bring all the static tables together in vmlinux and
* new initialisation code in module.c to read and load all the static tables at boot time and
* extra code in modutils to find any static tables in modules and
* an extension to struct modules to let modutils pass information about the static tables to the kernel and
* the kernel code will only work with an upgraded modutils.
That is a lot of work for a very few special cases. OTOH, you could just add a few lines of __initcall code in two source files (which I did when I wrote inter_module_xxx) and swap the order of 3 lines in drivers/mtd/Makefile. Guess which alternative I am going for?
IMHO any automatic method that relies on ELF sections and/or modutils support is the wrong approach, it is a complex solution with external dependencies when we already have a simple solution with no external dependencies. What next, static tables for file system registration, for device registration?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · [email protected] said:
That is a lot of work for a very few special cases. OTOH, you could just add a few lines of
__initcallcode in two source files (which I did when I wroteinter_module_xxx) and swap the order of 3 lines indrivers/mtd/Makefile. Guess which alternative I am going for?
I've already worked round it for the 2.[024] case by reintroducing the ifdefs. I assume here that we're planning for 2.5. As part of the many changes that are going to be introduced during 2.5, this shouldn't be too intrusive.
Once it's actually usable for the common case, it won't just be 'a very few special cases' any more. But that's all 2.5 material.
--
dwmw2
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 17 lines · On Sat, Jan 13, 2001 at 12:11:31PM +1100, [email protected] wrote:
My apologies. I read the patch, not the full source code and the patch does not have enough programming context to show that the driver is only searching its own symbol space. In my own defense, the references to
spinlock_tunload_lockandMOD_CAN_QUERY(mp)in the patch are highly misleading, those statements only make sense when you are looking at a symbol table for another module. When searching your own symbol table the current module must be live with a non-zero use count, not being unloaded and it can always be queried.Quoted 3 lines
Contrary to what you're saying, the patch does not just inline the old
get_module_symbolalgorithm nor does it access any of module.c's internal data.
unload_lockandMOD_CAN_QUERYwere copied verbatim from the oldget_module_symbol, even though they are completely unnecessary. That looks like inlining the old algorithm to me.
Quoted 5 lines
struct
module_symbol,mp->nsymsandmp->symsaremodule.cinternal data. If it is ever necessary to change those structures, nothing outsidemodule.c, the 32/64 handlers for module system calls and modutils should be affected. Now if I changemodule_symbol, other bits of the kernel will unexpectedly break, this is not good.
I see what you mean. What do you suggest should be done in the context of the driver? As you can easily tell, I'm not overly familiar with the internal workings of the kernel. That and the mere impossibility to get any kind of help at the mere mention of the Nvidia driver module ("go bitch at nvidia", "who cares", ...) do not exactly make it easier to fix problems that arise from changes to the kernel.
--
----------------------------------------------------------------------
christian zander we come to bury dos, not to praise it.
[email protected] -- paul vojta
----------------------------------------------------------------------
Quoted 6 lines · Christian Zander
I see what you mean. What do you suggest should be done in the context of the driver? As you can easily tell, I'm not overly familiar with the internal workings of the kernel. That and the mere impossibility to get any kind of help at the mere mention of the Nvidia driver module ("go bitch at nvidia", "who cares", ...) do not exactly make it easier to fix problems that arise from changes to the kernel.
Hmm, can I charge Nvidia for this fix?
The only reason you are looking at symbols is to map Nvidia registry names to module symbols. There are 9 registry names, 4 of which are #ifdeffed out.
MODULE_PARM(NVreg_resman_debuglevel, "i");MODULE_PARM(NVreg_VideoMemoryTypeOverride, "i"); #ifdeffed outMODULE_PARM(NVreg_EnableVia4x, "i");MODULE_PARM(NVreg_ReqAGPRate, "i"); #ifdeffed outMODULE_PARM(NVreg_SkipBiosPost, "i"); #ifdeffed outMODULE_PARM(NVreg_UseKernelAGP, "i");MODULE_PARM(NVreg_UpdateKernelAGP, "i"); #ifdeffed outMODULE_PARM(NVreg_ReqAGPSBA, "i");MODULE_PARM(NVreg_ReqAGPFW, "i");
Simple fix is an array to map names to addresses.
struct {
const char *name;
int *value;
} linux_registry[] = {
{ "resman_debuglevel", &NVreg_resman_debuglevel },
{ "EnableVia4x", &NVreg_EnableVia4x },
{ "UseKernelAGP", &NVreg_UseKernelAGP },
{ "ReqAGPSBA", &NVreg_ReqAGPSBA },
{ "ReqAGPFW", &NVreg_ReqAGPFW },
};Changing osRegistryLookup to scan that array for the registry name and return the address of the corresponding variable is left as an exercise for the reader.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/