On Mon, 2006-03-06 at 18:08 +0100, Herbert Poetzl wrote: > > I'm wondering if, instead of having the .data field in that table, we > > can have a function pointer which, when called, gives a pointer to the > > data. I'll give it a shot. > > something similar to this? > > http://www.13thfloor.at/vserver/d_rel26/v2.1.0/split-2.6.14.4-vs2.1.0/15_2.6.14.4_virt.diff.hl > > (look for virt_handler() for sysctl ops) Yeah, that's the right general idea. However, I think for mainline we probably want to make it a little less of an add-on feature. I was thinking that we could replace all of the current, flat sysctl .data pointers with some simple helper functions. Something like this: #define SYSCTL_HELPER_FOR(name) sysctl_return_var_named##name #define DECLARE_HELPER_FOR(type, name) \ void *SYSCTL_HELPER_FOR(name)(void) \ { \ extern type name; \ return &name; \ } And, the declaration for max_threads: DECLARE_HELPER_FOR(int, max_threads)); and the ctl_table entry: { .ctl_name = KERN_MAX_THREADS, .procname = "threads-max", .data_access = &SYSCTL_HELPER_FOR(max_threads), .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dointvec, }, Note that the .data = &max_threads, line is gone. I hate multi-line #defines as much as the next guy, but it might be worth it. I've attached what I have so far, but it is a major work in progress. -- Dave