Skip to contentSkip to conversation

Linux 2.4.5-ac14

DISCUSSION Dieter Nützel 3 participants 6 messages Jun 15, 2001

lore
Share & tools
lore
#0 lore raw

Hello Alan,

I see 4.29 GB under shm with your latest try.
something wrong?

Regards,
Dieter

SunWave1>cat /proc/meminfo
total: used: free: shared: buffers: cached:

Mem:  327802880 322592768  5210112 4294184960  8417280 253640704
Swap: 1052794880 95768576 957026304
MemTotal:       320120 kB
MemFree:          5088 kB
MemShared:    4294966532 kB
Buffers:          8220 kB
Cached:         247696 kB
Active:         228008 kB
Inact_dirty:     24552 kB
Inact_clean:      2592 kB
Inact_target:      468 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       320120 kB
LowFree:          5088 kB
SwapTotal:     1028120 kB
SwapFree:       934596 kB
#1 lore raw
Quoted 5 lines · Dieter Nützel

Hello Alan,

I see 4.29 GB under shm with your latest try.
something wrong?

total: used: free: shared: buffers: cached:

Mem:  1053483008 431419392 622063616   122880 24387584 260923392
Swap: 394764288        0 394764288
MemTotal:      1028792 kB
MemFree:        607484 kB
MemShared:         120 kB
Buffers:         23816 kB
Cached:         254808 kB
Active:         225536 kB
Inact_dirty:     53208 kB
Inact_clean:         0 kB
Inact_target:       44 kB
HighTotal:      131056 kB
HighFree:         1048 kB
LowTotal:       897736 kB
LowFree:        606436 kB
SwapTotal:      385512 kB
SwapFree:       385512 kB

I don't seem to have the problem...

John

#2 lore raw
In reply to Dieter Nützel

Am Freitag, 15. Juni 2001 04:30 schrieb John Cavan:

Quoted 25 lines
Quoted 4 lines · Dieter Nützel

Hello Alan,

I see 4.29 GB under shm with your latest try.
something wrong?

total: used: free: shared: buffers: cached:

Mem:  1053483008 431419392 622063616   122880 24387584 260923392
Swap: 394764288        0 394764288
MemTotal:      1028792 kB
MemFree:        607484 kB
MemShared:         120 kB
Buffers:         23816 kB
Cached:         254808 kB
Active:         225536 kB
Inact_dirty:     53208 kB
Inact_clean:         0 kB
Inact_target:       44 kB
HighTotal:      131056 kB
HighFree:         1048 kB
LowTotal:       897736 kB
LowFree:        606436 kB
SwapTotal:      385512 kB
SwapFree:       385512 kB
Quoted 1 line

I don't seem to have the problem...

You are using HIGHMEM?!

-Dieter

#3 lore raw
In reply to Dieter Nützel

Am Freitag, 15. Juni 2001 05:32 schrieb Dieter Nützel:

Quoted 26 lines

Am Freitag, 15. Juni 2001 04:30 schrieb John Cavan:

Quoted 25 lines
Quoted 4 lines · Dieter Nützel

Hello Alan,

I see 4.29 GB under shm with your latest try.
something wrong?

total: used: free: shared: buffers: cached:

Mem:  1053483008 431419392 622063616   122880 24387584 260923392
Swap: 394764288        0 394764288
MemTotal:      1028792 kB
MemFree:        607484 kB
MemShared:         120 kB
Buffers:         23816 kB
Cached:         254808 kB
Active:         225536 kB
Inact_dirty:     53208 kB
Inact_clean:         0 kB
Inact_target:       44 kB
HighTotal:      131056 kB
HighFree:         1048 kB
LowTotal:       897736 kB
LowFree:        606436 kB
SwapTotal:      385512 kB
SwapFree:       385512 kB
Quoted 3 lines
Quoted 1 line

I don't seem to have the problem...

You are using HIGHMEM?!

I tested some more and found this.

It is XFree86 4.1.0 DRI (tdfx driver) related. During my first run I used the 2.4.5-ac14 kernel DRM module. Now I am running with the latest DRI trunk DRM module. Both show the same symptoms.

After system and first Xserver start everything is fine.

SunWave1>cat /proc/meminfo
total: used: free: shared: buffers: cached:

Mem:  327802880 256114688 71688192   487424 60665856 106491904
Swap: 1052794880        0 1052794880
MemTotal:       320120 kB
MemFree:         70008 kB
MemShared:         476 kB
Buffers:         59244 kB
Cached:         103996 kB
Active:         156332 kB
Inact_dirty:      7384 kB
Inact_clean:         0 kB
Inact_target:     1092 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       320120 kB
LowFree:         70008 kB
SwapTotal:     1028120 kB
SwapFree:      1028120 kB

Then after the first DRI (OpenGL/Mesa) app was running I get this:

SunWave1>l /dev/dri/card0
crw-rw---- 1 root video 226, 0 Jun 15 06:40 /dev/dri/card0

NO double /dev/dri entry. OK.

SunWave1>cat /proc/meminfo
total: used: free: shared: buffers: cached:

Mem:  327802880 222384128 105418752 4294873088  2973696 168341504
Swap: 1052794880 72327168 980467712
MemTotal:       320120 kB
MemFree:        102948 kB
MemShared:    4294967204 kB
Buffers:          2904 kB
Cached:         164396 kB
Active:         124212 kB
Inact_dirty:      3692 kB
Inact_clean:     39304 kB
Inact_target:       76 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       320120 kB
LowFree:        102948 kB
SwapTotal:     1028120 kB
SwapFree:       957488 kB

4.29 GB shm...

SunWave1>cat /proc/dri/0/*
a dev pid uid magic ioctls

y 0 693 0 0 25
total counts | outstanding
type alloc freed fail bytes freed | allocs bytes

system        0     0    0     320120 kB         |
locked        0     0    0          0 kB         |
dmabufs       0     0    0          0          0 |      0          0
sareas        0     0    0          0          0 |      0          0
driver        2     0    0         25          0 |      2         25
magic         1     0    0         12          0 |      1         12
ioctltab      0     0    0          0          0 |      0          0
maplist      10     2    0        144         12 |      8        132
vmalist       8     7    0         96         84 |      1         12
buflist       0     0    0          0          0 |      0          0
seglist       0     0    0          0          0 |      0          0
pagelist      0     0    0          0          0 |      0          0
files         2     1    0         80         40 |      1         40
queues        0     0    0          0          0 |      0          0
commands      0     0    0          0          0 |      0          0
mappings      2     0    0  100663296          0 |      2  100663296
buflists      0     0    0          0          0 |      0          0
agplist       0     0    0          0          0 |      0          0
totalagp      0     0    0          0          0 |      0          0
boundagp      0     0    0          0          0 |      0          0
ctxbitmap     1     0    0       4096          0 |      1       4096
stub          1     0    0        192          0 |      1        192

tdfx 0xe200 PCI:1:5:0
ctx/flags use fin blk/rw/rwf wait flushed queued locks

slot offset size type flags address mtrr

   0 0xd8000000 0x02000000  REG  0x00 0xd9099000 none
   1 0xe0000000 0x04000000   FB  0x00 0xd5098000    3
   2 0xd5096000 0x00001000  SHM  0x20 0xd5096000 none

vma use count: 1, high_memory = d3ff0000, 0x13ff0000

693 0x46182000-0x46183000 rw-sl- 0xd5096000 pwubca-kl

Who is to blame?
XFree? DRI? Kernel?

-Dieter

#4 lore raw
In reply to Dieter Nützel

Hi Dieter,

Quoted 2 lines · Dieter Nützel

I see 4.29 GB under shm with your latest try.
something wrong?

Yes, this is nasty. The appended patch fixes that. (I am not really happy to need the PG_marker flag for writepage.)

The patch also fixes two other problems:
- shmem_file_setup has to check the given size. Else we can corrupt kernel memory on 64bit machines. (Thanks to Oliver Paukstadt for detecting this)
- shmem_remount_fs does not initialize the parameters and thus corrupts the sizes (detected by Joris van Rantwijk)

Alan, please apply.

Greetings
Christoph

include/linux/mm.h +1 -0
diff -uNr 5-ac14/include/linux/mm.h 5-ac14-fix/include/linux/mm.h
@@ -357,6 +357,7 @@
 
 #define PageMarker(page)	test_bit(PG_marker, &(page)->flags)
 #define SetPageMarker(page)	set_bit(PG_marker, &(page)->flags)
+#define ClearPageMarker(page)	clear_bit(PG_marker, &(page)->flags)
 
 #ifdef CONFIG_HIGHMEM
 #define PageHighMem(page)		test_bit(PG_highmem, &(page)->flags)
mm/shmem.c +17 -10
diff -uNr 5-ac14/mm/shmem.c 5-ac14-fix/mm/shmem.c
@@ -34,6 +34,7 @@
 #define TMPFS_MAGIC	0x01021994
 
 #define ENTRIES_PER_PAGE (PAGE_SIZE/sizeof(unsigned long))
+#define SHMEM_MAX_BLOCKS (SHMEM_NR_DIRECT + ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
 
 #define SHMEM_SB(sb) (&sb->u.shmem_sb)
 
@@ -56,10 +57,12 @@
 	struct inode *inode = (struct inode *)page->mapping->host;
 	struct shmem_sb_info * sbinfo = SHMEM_SB(inode->i_sb);
 
-	inode->i_blocks -= BLOCKS_PER_PAGE;
-	spin_lock (&sbinfo->stat_lock);
-	sbinfo->free_blocks++;
-	spin_unlock (&sbinfo->stat_lock);
+	if (!PageMarker(page)) {
+		inode->i_blocks -= BLOCKS_PER_PAGE;
+		spin_lock (&sbinfo->stat_lock);
+		sbinfo->free_blocks++;
+		spin_unlock (&sbinfo->stat_lock);
+	}
 	atomic_dec(&shmem_nrpages);
 }
 
@@ -241,9 +244,10 @@
 	*entry = swap;
 	error = 0;
 	/* Remove the page from the page cache */
-	atomic_dec(&shmem_nrpages);
 	lru_cache_del(page);
+	SetPageMarker(page);
 	remove_inode_page(page);
+	ClearPageMarker(page);
 
 	/* Add it to the swap cache */
 	add_to_swap_cache(page, swap);
@@ -1062,6 +1066,8 @@
 	unsigned long max_inodes, inodes;
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
+	max_blocks = sbinfo->max_blocks;
+	max_inodes = sbinfo->max_inodes;
 	if (shmem_parse_options (data, NULL, &max_blocks, &max_inodes))
 		return -EINVAL;
 
@@ -1110,7 +1116,7 @@
 	sbinfo->free_blocks = blocks;
 	sbinfo->max_inodes = inodes;
 	sbinfo->free_inodes = inodes;
-	sb->s_maxbytes = (unsigned long long)(SHMEM_NR_DIRECT + (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)) << PAGE_CACHE_SHIFT;
+	sb->s_maxbytes = (unsigned long long) SHMEM_MAX_BLOCKS << PAGE_CACHE_SHIFT;
 	sb->s_blocksize = PAGE_CACHE_SIZE;
 	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
 	sb->s_magic = TMPFS_MAGIC;
@@ -1311,9 +1317,11 @@
 	struct qstr this;
 	int vm_enough_memory(long pages);
 
-	error = -ENOMEM;
+	if (size > (unsigned long long) SHMEM_MAX_BLOCKS << PAGE_CACHE_SHIFT)
+		return ERR_PTR(-EINVAL);
+
 	if (!vm_enough_memory((size) >> PAGE_SHIFT))
-		goto out;
+		return ERR_PTR(-ENOMEM);
 
 	this.name = name;
 	this.len = strlen(name);
@@ -1321,7 +1329,7 @@
 	root = tmpfs_fs_type.kern_mnt->mnt_root;
 	dentry = d_alloc(root, &this);
 	if (!dentry)
-		goto out;
+		return ERR_PTR(-ENOMEM);
 
 	error = -ENFILE;
 	file = get_empty_filp();
@@ -1347,7 +1355,6 @@
 	put_filp(file);
 put_dentry:
 	dput (dentry);
-out:
 	return ERR_PTR(error);	
 }
 /*
#5 lore raw
In reply to Dieter Nützel
Quoted 31 lines · Dieter Nützel

Am Freitag, 15. Juni 2001 05:32 schrieb Dieter Nützel:

Quoted 29 lines

Am Freitag, 15. Juni 2001 04:30 schrieb John Cavan:

Quoted 25 lines
Quoted 4 lines · Dieter Nützel

Hello Alan,

I see 4.29 GB under shm with your latest try.
something wrong?

total: used: free: shared: buffers: cached:

Mem:  1053483008 431419392 622063616   122880 24387584 260923392
Swap: 394764288        0 394764288
MemTotal:      1028792 kB
MemFree:        607484 kB
MemShared:         120 kB
Buffers:         23816 kB
Cached:         254808 kB
Active:         225536 kB
Inact_dirty:     53208 kB
Inact_clean:         0 kB
Inact_target:       44 kB
HighTotal:      131056 kB
HighFree:         1048 kB
LowTotal:       897736 kB
LowFree:        606436 kB
SwapTotal:      385512 kB
SwapFree:       385512 kB
Quoted 1 line

I don't seem to have the problem...

You are using HIGHMEM?!

Sort of necessary when you have 1gb of RAM. My machine is also a dual CPU box.

Quoted 6 lines

I tested some more and found this.

It is XFree86 4.1.0 DRI (tdfx driver) related. During my first run I used the 2.4.5-ac14 kernel DRM module. Now I am running with the latest DRI trunk DRM module. Both show the same symptoms.

Well, I'm running XFree86 4.1.0 DRI with the Radeon driver and I don't show the symptoms. I use the Radeon module from DRI on SourceForge.

Have you tried it with CONFIG_HIGHMEM in the kernel?

John