kallsyms_lookup_name

2011-08-05 Thread Venkatram Tummala
Hi,

I need to use some unexported kernel symbols in my kernel module but in the
particular kernel version i am based on (2.6.18 - RHEL 5.7),
kallsyms_lookup_name is not exported and there is no kallsyms_on_each_symbol
in this kernel. And I can't change the kernel owing to reasons i have no
control over.

In this scenario, how do i use unexported symbols. Is there any other
mechanism by which i can lookup the address of a kernel symbol.


Thanks.

Venkatram
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Debugging the linux kernel core dump

2011-08-05 Thread Akash
On Fri, Aug 5, 2011 at 9:23 PM, Mulyadi Santosa
wrote:

> Hi...
>
> On Fri, Aug 5, 2011 at 12:23, Akash  wrote:
> > I think it was not built with -g otherwise the symbols would have been
> there
> > in the vmlinux itself, right ?
> > That is the reason I need to add symbols externally.
> > Please dont ask me to rebuild the kernel, this is vanilla OpenSUSE 11.3
> > symbols and debug kernel should be available somewhere. I just need to
> know
> > how/where to add the symbols. The problem is not reproducible, I need to
> > debug the core which I have on hand.
>
> try to check opensuse repo, see which one provide kinda "debuginfo"
> package for your kernel (at least that's how Fedora/RHEL call it).
> Usually it will be located under /boot with quite obvious name
> (suffixed with "debug" or similar) or you could just try to use
> vmlinux as the symbol file
>
> NB: make sure you use the very same debuginfo package with your
> current kernel version. Any slight difference could yield very
> different symbol addresses.
>


Thanks Malyudi. Thats sounds like a reasonable approach. I did try to search
kernel-debug RPMs for my kernel could not find any. May be I should just
keep looking.

On that note, I wonder what is the difference between kernel-base,
kernel-default, kernel-devel, and similar other RPMs. I guess some contain
binaries, some contain unstripped binaries and some contain soruces/headers.
But which is which ?? I hate distros for creating so many RPMs. They could
have included ALL of this in one RPM and users would not have minded.

->Akash


> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to freeze the 2.6 kernel on SMP m/c

2011-08-05 Thread Mulyadi Santosa
On Fri, Aug 5, 2011 at 17:24, san deep  wrote:
> Hi,
>
> Could you please suggest  how to freeze  the 2.6 kernel(SMP m/c) with
> my own dlkm with  less number of code.
>
> I tried the below mentioned code snippet, it hangs only the terminal
> on which i executed the insmod command.
>  Please correct the below code to freeze whole kernel.
>
> #include 
> #include 
> #include 
> #include 
>
> int init_module(void)
> {
>        spinlock_t lock = SPIN_LOCK_UNLOCKED;
>        while (1) {
>                spin_lock(&lock);
>                msleep(100);
>         }
>        //spin_unlock(lock);
>        printk(KERN_INFO "Hello world :).\n");
>        return 0;
> }

how about calling panic()?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Mapped more than Cached in /proc/meminfo

2011-08-05 Thread Mulyadi Santosa
On Fri, Aug 5, 2011 at 21:16, =/_00/\/\  wrote:
> Hi,
>
> I am trying to analyze memory usage on my system.
> As first step I am monitoring /proc/meminfo.
> Surprisingly I see Mapped value is more than Cached.
>
> So in which case is it possible to have Mapped more than Cached ?

your apps mmap() less than the amount of files content that are cached
through normal read() AFAIK


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Debugging the linux kernel core dump

2011-08-05 Thread Mulyadi Santosa
Hi...

On Fri, Aug 5, 2011 at 12:23, Akash  wrote:
> I think it was not built with -g otherwise the symbols would have been there
> in the vmlinux itself, right ?
> That is the reason I need to add symbols externally.
> Please dont ask me to rebuild the kernel, this is vanilla OpenSUSE 11.3
> symbols and debug kernel should be available somewhere. I just need to know
> how/where to add the symbols. The problem is not reproducible, I need to
> debug the core which I have on hand.

try to check opensuse repo, see which one provide kinda "debuginfo"
package for your kernel (at least that's how Fedora/RHEL call it).
Usually it will be located under /boot with quite obvious name
(suffixed with "debug" or similar) or you could just try to use
vmlinux as the symbol file

NB: make sure you use the very same debuginfo package with your
current kernel version. Any slight difference could yield very
different symbol addresses.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: can i simply "re-version" the kernel down to 2.x?

2011-08-05 Thread Josh Cartwright
On Fri, Aug 05, 2011 at 10:36:00AM -0400, Robert P. J. Day wrote:
> 
>   for reasons that don't need explaining, i need to rebuild my current
> 3.0.0... kernel so that it returns a "uname" version number of
> "2.whatever".  i simply have an app i want to run that checks the
> output of "uname" and if it doesn't see a major number of "2", it goes
> a bit squirrelly.

If it is just one poorly written app you are trying to deal with, it
might just be easier to create a wrapper dll that traps the glibc uname
wrapper and hijacks the returned version.  Something like this:

--- /dev/null   2011-08-02 20:23:03.358999850 -0500
+++ b/trapuname.c   2011-08-05 22:45:02.0 -0500
@@ -0,0 +1,43 @@
+/* trapuname: tool to fake uname release
+ * Copyright (C) 2011 Josh Cartwright 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ */
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int uname(struct utsname *u)
+{
+   const char *err;
+   int ret;
+   int (*old_uname)(struct utsname *u);
+
+   dlerror();
+   old_uname = dlsym(RTLD_NEXT, "uname");
+
+   if ((err = dlerror())) {
+   fprintf(stderr, "Unable to load uname: %s\n", err);
+   exit(EXIT_FAILURE);
+   }
+
+   if (!(ret = old_uname(u)))
+   strcpy(u->release, "2.6.40");
+
+   return ret;
+}

Build it into a dynamic library, the use LD_PRELOAD to load it before
your application is run:

$ gcc -shared -fPIC trapuname.c -ldl -o libtrapuname.so
$ LD_PRELOAD=./libtrapuname.so stupidapp

At least this way, you won't be carting around a local kernel patch just
for a version change :\.

-- 
joshc

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Compiling kernel module ...

2011-08-05 Thread Akash
Use #if like

*
*#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
   // New socket create function
#else
   // Old socket create function
#endif

LINUX_VERSION_CODE is defined somewhere in the kernel and you should get to
use it easily.


HTH

Akash


On Fri, Aug 5, 2011 at 12:34 PM, Abu Rasheda  wrote:

> I am compiling my driver and have run into following scenario.
>
> Socket create function got a new parameter in Vanila kenrel 2.6.33. while
> Scientific Linux has it back ported to 2.6.32. How do I handle this kind of
> situation ? so that my driver compiles for both kernel versions.
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Reboot not calling module_exit of LKM

2011-08-05 Thread Ramesh.P
Thanks Greg. Appreciate your reply.

Regards,
Ramesh

On Fri, Aug 5, 2011 at 12:06 PM, Greg KH  wrote:
> On Fri, Aug 05, 2011 at 11:39:16AM -0700, Ramesh.P wrote:
>> Hi,
>>
>> Good day!
>>
>> When a system is rebooted, the loadable kernel modules 'module_exit'
>> functions are not called. I see this behavior in a custom kernel. My
>> questions are
>>
>> a. Is this applicable in mainline/normal kernel too?
>
> Yes.
>
>> b. If yes, what are the reasons? (One reason may be, not to get into
>> new problems while cleaning up the module)
>
> You don't need to unload a module as the machine is about to be turned
> off.
>
>> c. Is there anyway for the kernel module to know the system is getting
>> rebooted? (Apart from letting userspace to indicate the kernel
>> module).
>
> Yes, hook to the reboot notifier.
>
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


trouble with __aquires(lock) __releases(lock)

2011-08-05 Thread Jim Cromie
Im trying to use macros from include/linux/compiler.h
and theyre giving me warnings that dont look right.

after thrashing on my own hacks, I looked to well established uses for guidance.
But make C=1 fs/file.o also gives errors, similar to mine.

What am I missing ?
or has some bitrot set in ?

 202static int expand_fdtable(struct files_struct *files, int nr)
 203__releases(files->file_lock)
 204__acquires(files->file_lock)
 205{
 206struct fdtable *new_fdt, *cur_fdt;
 207
 208spin_unlock(&files->file_lock);
 209new_fdt = alloc_fdtable(nr);
 210spin_lock(&files->file_lock);
...

 247int expand_files(struct files_struct *files, int nr)
 248{
 ...
268/* All good, so we try */
 269return expand_fdtable(files, nr);
 270}


  CHECK   /home/jimc/projects/lx/linux-2.6/fs/file.c
/home/jimc/projects/lx/linux-2.6/fs/file.c:32:5: warning: symbol
'sysctl_nr_open_min' was not declared. Should it be static?
/home/jimc/projects/lx/linux-2.6/fs/file.c:33:5: warning: symbol
'sysctl_nr_open_max' was not declared. Should it be static?
/home/jimc/projects/lx/linux-2.6/fs/file.c:416:21: warning: symbol
'init_files' was not declared. Should it be static?
/home/jimc/projects/lx/linux-2.6/include/linux/spinlock.h:325:2:
warning: context problem in 'expand_fdtable': '_raw_spin_unlock'
expected different context
/home/jimc/projects/lx/linux-2.6/include/linux/spinlock.h:325:2:
context 'lock': wanted >= 1, got 0
/home/jimc/projects/lx/linux-2.6/fs/file.c:269:23: warning: context
problem in 'expand_files': 'expand_fdtable' expected different context
/home/jimc/projects/lx/linux-2.6/fs/file.c:269:23:context
'file_lock': wanted >= 1, got 0

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Compiling kernel module ...

2011-08-05 Thread Abu Rasheda
I am compiling my driver and have run into following scenario.

Socket create function got a new parameter in Vanila kenrel 2.6.33. while
Scientific Linux has it back ported to 2.6.32. How do I handle this kind of
situation ? so that my driver compiles for both kernel versions.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Reboot not calling module_exit of LKM

2011-08-05 Thread Greg KH
On Fri, Aug 05, 2011 at 11:39:16AM -0700, Ramesh.P wrote:
> Hi,
> 
> Good day!
> 
> When a system is rebooted, the loadable kernel modules 'module_exit'
> functions are not called. I see this behavior in a custom kernel. My
> questions are
> 
> a. Is this applicable in mainline/normal kernel too?

Yes.

> b. If yes, what are the reasons? (One reason may be, not to get into
> new problems while cleaning up the module)

You don't need to unload a module as the machine is about to be turned
off.

> c. Is there anyway for the kernel module to know the system is getting
> rebooted? (Apart from letting userspace to indicate the kernel
> module).

Yes, hook to the reboot notifier.


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Reboot not calling module_exit of LKM

2011-08-05 Thread Ramesh.P
Hi,

Good day!

When a system is rebooted, the loadable kernel modules 'module_exit'
functions are not called. I see this behavior in a custom kernel. My
questions are

a. Is this applicable in mainline/normal kernel too?
b. If yes, what are the reasons? (One reason may be, not to get into
new problems while cleaning up the module)
c. Is there anyway for the kernel module to know the system is getting
rebooted? (Apart from letting userspace to indicate the kernel
module).

Appreciate your help and apologize if this is already answered in this forum.

Thanks,
Ramesh

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: can i simply "re-version" the kernel down to 2.x?

2011-08-05 Thread Robert P. J. Day
On Fri, 5 Aug 2011, Greg KH wrote:

> On Fri, Aug 05, 2011 at 10:36:00AM -0400, Robert P. J. Day wrote:
> >
> >   for reasons that don't need explaining, i need to rebuild my current
> > 3.0.0... kernel so that it returns a "uname" version number of
> > "2.whatever".  i simply have an app i want to run that checks the
> > output of "uname" and if it doesn't see a major number of "2", it goes
> > a bit squirrelly.
> >
> >   there's no *technical* reason i can see for the app to be that
> > restrictive, so i was just going to hack the top level Makefile of my
> > git clone and label this as a 2.99.99 kernel.  is there anything that
> > would break because of that kind of hackery?
>
> Why not just call it 2.6.40 like Fedora is doing for this very reason?

  i could do that as well, i just wanted to verify that manually
tweaking it this way wouldn't clash with any other versioning info
hidden somewhere else in the source tree.

  i'll know in about 10 minutes once this build is done.

rday

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: can i simply "re-version" the kernel down to 2.x?

2011-08-05 Thread Greg KH
On Fri, Aug 05, 2011 at 10:36:00AM -0400, Robert P. J. Day wrote:
> 
>   for reasons that don't need explaining, i need to rebuild my current
> 3.0.0... kernel so that it returns a "uname" version number of
> "2.whatever".  i simply have an app i want to run that checks the
> output of "uname" and if it doesn't see a major number of "2", it goes
> a bit squirrelly.
> 
>   there's no *technical* reason i can see for the app to be that
> restrictive, so i was just going to hack the top level Makefile of my
> git clone and label this as a 2.99.99 kernel.  is there anything that
> would break because of that kind of hackery?

Why not just call it 2.6.40 like Fedora is doing for this very reason?


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


can i simply "re-version" the kernel down to 2.x?

2011-08-05 Thread Robert P. J. Day

  for reasons that don't need explaining, i need to rebuild my current
3.0.0... kernel so that it returns a "uname" version number of
"2.whatever".  i simply have an app i want to run that checks the
output of "uname" and if it doesn't see a major number of "2", it goes
a bit squirrelly.

  there's no *technical* reason i can see for the app to be that
restrictive, so i was just going to hack the top level Makefile of my
git clone and label this as a 2.99.99 kernel.  is there anything that
would break because of that kind of hackery?

rday

-- 


Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca

Twitter:   http://twitter.com/rpjday
LinkedIn:   http://ca.linkedin.com/in/rpjday


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Mapped more than Cached in /proc/meminfo

2011-08-05 Thread =/_00/\/\
Hi,

I am trying to analyze memory usage on my system.
As first step I am monitoring /proc/meminfo.
Surprisingly I see Mapped value is more than Cached.

So in which case is it possible to have Mapped more than Cached ?


Regards,
  ~/
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Creating sparse file on XFS and EXT3 has different results

2011-08-05 Thread Greg Freemyer
Apologies for the top post.  I simply forgot to not do that.

On Aug 5, 2011 8:11 AM, "Greg Freemyer"  wrote:
>
> There are no "specs" as to how a sparse file is handled in response to
writes.
>
> Sparse is mostly beneficial when the holes are very large.
>
> If an app really wants to have minimal on disk space, you should
pre-allocate space with fallocate.
>
> You may even need to hole punch after the writes.  Both xfs and ext4
support both fallocate and hole punching. (I don't know the userspace call
to hole punch.  I think its a relatively new feature for ext4.)
>
> Greg
>
> On Aug 4, 2011 10:16 PM, "Ashish Sangwan" 
wrote:

Greg
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Creating sparse file on XFS and EXT3 has different results

2011-08-05 Thread Greg Freemyer
There are no "specs" as to how a sparse file is handled in response to
writes.

Sparse is mostly beneficial when the holes are very large.

If an app really wants to have minimal on disk space, you should
pre-allocate space with fallocate.

You may even need to hole punch after the writes.  Both xfs and ext4 support
both fallocate and hole punching. (I don't know the userspace call to hole
punch.  I think its a relatively new feature for ext4.)

Greg
On Aug 4, 2011 10:16 PM, "Ashish Sangwan"  wrote:
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


how to freeze the 2.6 kernel on SMP m/c

2011-08-05 Thread san deep
Hi,

Could you please suggest  how to freeze  the 2.6 kernel(SMP m/c) with
my own dlkm with  less number of code.

I tried the below mentioned code snippet, it hangs only the terminal
on which i executed the insmod command.
 Please correct the below code to freeze whole kernel.

#include
#include
#include 
#include 

int init_module(void)
{
spinlock_t lock = SPIN_LOCK_UNLOCKED;
while (1) {
spin_lock(&lock);
msleep(100);
 }
//spin_unlock(lock);
printk(KERN_INFO "Hello world :).\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world :(.\n");
}

Thanks and Regards,
Sandeep

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies