Subject: RAMDISK problem on 79s334A board.

From: Venkata Rajesh Bikkina <[email-masked]>
Date: Wed, 15 May 2002 14:12:25 +0530 (IST)

Hi All,

I am working on 79s334A board with 32MB RAM and Linux 2.4.13 kernel. 
I have module to be inserted into kernel. The size of the module will be
around 1 MB.
I am using two file systems while building kernel image, one is NFS and
the other is RAMDISK.
When i work with NFS i do not have any problem.

But when i build RAMDISK image and insert the module, insmod is
doing fine. But after that i could not invoke any other application ( even
ps -ef is also giving segmentation fault.)
The RAMDISK size choosen is 10MB and the memory on board is 32MB.
When i did cat /proc/meminfo i found strange thing. All the figures are
corrupted.

The statistics before and after insmod are as follows:

# cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  29237248 15319040 13918208        0 10240000  2908160
Swap:        0        0        0
MemTotal:        28552 kB
MemFree:         13592 kB
MemShared:           0 kB
Buffers:         10000 kB
Cached:           2840 kB
Active:          12840 kB
Inact_dirty:         0 kB
Inact_clean:         0 kB
Inact_target:       44 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        28552 kB
LowFree:         13592 kB
SwapTotal:           0 kB
SwapFree:            0 kB
#
#
# cd /igateway
# /sbin/insmod igateway
Intoto Firewall Installed.
#
#
# /sbin/lsmod
Module                  Size  Used by
igateway              967056   0 (unused)
#
#
# cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  %8lu %8lu %8lu %8lu %8lu %8u
Swap: %8lu %8lu %8lu
MemTotal:     %8lu kB
MemFree:      %8lu kB
MemShared:    %8lu kB
Buffers:      %8lu kB
Cached:       %8u kB
Active:       %8u kB
Inact_dirty:  %8u kB
Inact_clean:  %8u kB
Inact_target: %8lu kB
HighTotal:    %8lu kB
HighFree:     %8lu kB
LowTotal:     %8lu kB
LowFree:      %8lu kB
SwapTotal:    %8lu kB
SwapFree:     %8lu kB
#
#
# ps -ef
  PID  Uid      Gid State Command
Segmentation fault
# 

Can anybody give hint what is happening. 

Thanks and Regards,
--Rajesh

---

From: Alan Cox <[email-masked]>
Date: Wed, 15 May 2002 12:00:27 +0100 (BST)

> ps -ef is also giving segmentation fault.)

Looks like your module corrupts the kernel.

---

From: Venkata Rajesh Bikkina <[email-masked]>
Date: Wed, 15 May 2002 17:30:50 +0530 (IST)

Hi Alan,

Thankyou for your response.

But the same module is working fine and kernel is also fine if i use NFS
and insert the module.
Any further info ?

--Rajesh

---

From: Alan Cox <[email-masked]>
Date: Wed, 15 May 2002 14:28:59 +0100 (BST)

> But the same module is working fine and kernel is also fine if i use NFS

Not really. The fact it works with NFS and not ramdisk may simply be that
in one case it corrupts memory that is used, and the other it corrupts
memory that isnt

---

From: "Tommy S. Christensen" <[email-masked]>
Date: Thu, 16 May 2002 10:52:52 +0200

> in one case it corrupts memory that is used, and the other it corrupts

Using a ramdisk increases the pressure on memory. So the difference could
be that one case hits the cache aliasing problem, the other doesn't.

Try this patch and see if it helps.

 -Tommy

Index: mm/vmalloc.c
===================================================================
RCS file: /cvs/linux/mm/vmalloc.c,v
retrieving revision 1.28
retrieving revision 1.28.2.1
diff -u -r1.28 -r1.28.2.1
--- mm/vmalloc.c        2001/10/19 01:25:06     1.28
+++ mm/vmalloc.c        2001/12/28 21:06:01     1.28.2.1
@@ -163,6 +163,7 @@
                ret = 0;
        } while (address && (address < end));
        spin_unlock(&init_mm.page_table_lock);
+       flush_cache_all();
        return ret;
 }

---

From: Venkata Rajesh Bikkina <[email-masked]>
Date: Thu, 16 May 2002 15:52:57 +0530 (IST)

Hi Tommy,

I am using 2.4.3 code and in that linux/mm/vmallo.c contains the following
code which is slightly different from the patch you gave.

        unlock_kernel();
        flush_tlb_all();
        return ret;

Can you please suggest how to modify this.

Regards,
--Rajesh

---

From: "Tommy S. Christensen" <[email-masked]>
Date: Thu, 16 May 2002 14:30:45 +0200

> Can you please suggest how to modify this.

2.4.3 is quite old, so upgrading the kernel would clearly be a good idea.

Anyway, if you want to try this fix then you should remove the call to
flush_cache_all() at the top of vmalloc_area_pages() and change the line
flush_tlb_all() to flush_cache_all().

 -Tommy