linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* my slab cache broken on sparc64
@ 2002-05-03 19:18 Holzrichter, Bruce
  2002-05-03 21:05 ` David S. Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Holzrichter, Bruce @ 2002-05-03 19:18 UTC (permalink / raw)
  To: 'sparclinux@vger.kernel.org'
  Cc: 'linux-kernel@vger.kernel.org'

Hello,

I am trying to troubleshoot why in 2.5.13, (Though I also saw this in 2.5.7)
on my UltraSparc, why my slabcache is broken.  Has anyone else seen this?

During boot, dmesg displays all the caches as "Cache with size (%d) has lost
its name" where it appears that all my slabs are broken, displayed in my cat
/proc/slabinfo below.

I'm trying to trace back through the slabcache code, (I'm not too
knowledgeable about the slab code, so go easy on me :o)) to determine why
that is.  I see in the slab.c why this is displayed, in the below code, just
looking for pointers on why all mine may be breaking?  

        /* Need the semaphore to access the chain. */
        down(&cache_chain_sem);
        {
                struct list_head *p;
 
                list_for_each(p, &cache_chain) {
                        kmem_cache_t *pc = list_entry(p, kmem_cache_t,
next);
                        char tmp;
                        /* This happens when the module gets unloaded and
doesn't
                           destroy its slab cache and noone else reuses the
vmalloc
                           area of the module. Print a warning. */
                        if (__get_user(tmp,pc->name)) {
                                printk("SLAB: cache with size %d has lost
its name\n",
                                        pc->objsize);
                                continue;
                        }
                        if (!strcmp(pc->name,name)) {
                                printk("kmem_cache_create: duplicate cache
%s\n",name);
                                up(&cache_chain_sem);
                                BUG();
                        }
                }
        }

Thanks for any pointers.

Bruce H.

slabinfo - version: 1.1
broken                89    104    152    2    2    1
broken                 5    119     64    1    1    1
broken                 5     31    256    1    1    1
broken                 1     41    192    1    1    1
broken                 0      0    736    0    0    1
broken                 0      0    704    0    0    1
broken                 5      6   1248    1    1    1
broken                93    104    608    8    8    1
broken                 0      0    160    0    0    1
broken                10    226     32    1    1    1
broken                 0     61    128    0    1    1
broken                 0     81     96    0    1    1
broken                 9    226     32    1    1    1
broken                53     70    224    2    2    1
broken                 4     41    192    1    1    1
broken                 0      0    608    0    0    1
broken                 1     14    576    1    1    1
broken                18     21   1120    3    3    1
broken                 0      0     96    0    0    1
broken                32     35   3072    7    7    2
broken                32     35   1536    7    7    1
broken                32     40    768    4    4    1
broken                32     42    384    2    2    1
broken                32     41    192    1    1    1
broken               512    533    192   13   13    1
broken                 0      0    640    0    0    1
broken                 0      0    608    0    0    1
broken                 0      0    800    0    0    1
broken                 0      0    160    0    0    1
broken             30301  30312    672 2526 2526    1
broken                 0      0     48    0    0    1
broken                 6     49    160    1    1    1
broken                 0      0     24    0    0    1
broken               256    256   4096  128  128    1
broken               256    256   2048   64   64    1
broken               256    256   1024   32   32    1
broken               256    279    256    9    9    1
broken               256    357     64    3    3    1
broken               256    904     32    2    4    1
broken               256    567     96    4    7    1
broken                 3     10    768    1    1    1
broken                 1    119     64    1    1    1
broken               120    132    640   11   11    1
broken               161    245    224    7    7    1
broken                 2     15    512    1    1    1
broken                 3     26    608    2    2    1
broken                 1     58    136    1    1    1
broken              9681   9688   1056 1383 1384    1
broken                20    595     64    5    5    1
broken                 4     61    128    1    1    1
broken                12     61    128    1    1    1
broken               128    140    576   10   10    1
broken             25525  25543    192  623  623    1
broken               942    943    192   23   23    1
broken                 0      2   4096    0    1    1
broken            100388 102465     96 1265 1265    1
broken                46     62    256    2    2    1
broken              2639   2940    160   54   60    1
broken                45    119     64    1    1    1
broken                45     54    832    5    6    1
broken                48     54   2592   16   18    1
broken                53     63   1152    8    9    1
broken                 0      0 131072    0    0   16
broken                 0      0 131072    0    0   16
broken                 1      1  65536    1    1    8
broken                 1      1  65536    1    1    8
broken                 0      0  32768    0    0    4
broken                 9     10  32768    9   10    4
broken                 0      0  16384    0    0    2
broken                 2      3  16384    2    3    2
broken                 0      0   8192    0    0    1
broken                10     10   8192   10   10    1
broken                 0      0   4096    0    0    1
broken                32     38   4096   16   19    1
broken                 0      0   2048    0    0    1
broken                86     92   2048   22   23    1
broken                 0      0   1024    0    0    1
broken                29     40   1024    4    5    1
broken                 0      0    512    0    0    1
broken                55    105    512    5    7    1
broken                 0      0    256    0    0    1
broken                14     31    256    1    1    1
broken                 0      0    192    0    0    1
broken               506    574    192   13   14    1
broken                 0      0    128    0    0    1
broken                61     61    128    1    1    1
broken                 0      0     96    0    0    1
broken               114    162     96    2    2    1
broken                 0      0     64    0    0    1
broken              3918   4165     64   35   35    1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: my slab cache broken on sparc64
  2002-05-03 19:18 my slab cache broken on sparc64 Holzrichter, Bruce
@ 2002-05-03 21:05 ` David S. Miller
  2002-05-03 22:58   ` Andi Kleen
  0 siblings, 1 reply; 8+ messages in thread
From: David S. Miller @ 2002-05-03 21:05 UTC (permalink / raw)
  To: bruce.holzrichter; +Cc: sparclinux, linux-kernel

   From: "Holzrichter, Bruce" <bruce.holzrichter@monster.com>
   Date: Fri, 3 May 2002 14:18:55 -0500 

   I am trying to troubleshoot why in 2.5.13, (Though I also saw this in 2.5.7)
   on my UltraSparc, why my slabcache is broken.  Has anyone else seen this?
   
The technique used by the slabcache to verify to pointer
is %100 non-portable and totally wrong.

get_user() MUST be used only on "user pointers", it is being
used on a kernel pointer here.

It would work if the access was surrounded by:

	old_fs = get_fs();
	set_fs(KERNEL_DS);
	... get_user(kernel_pointer) ...
	set_fs (old_fs);

But it is not.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: my slab cache broken on sparc64
  2002-05-03 21:05 ` David S. Miller
@ 2002-05-03 22:58   ` Andi Kleen
  0 siblings, 0 replies; 8+ messages in thread
From: Andi Kleen @ 2002-05-03 22:58 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel, bruce.holzrichter

"David S. Miller" <davem@redhat.com> writes:
> 
> It would work if the access was surrounded by:
> 
> 	old_fs = get_fs();
> 	set_fs(KERNEL_DS);
> 	... get_user(kernel_pointer) ...
> 	set_fs (old_fs);
> 
> But it is not.

It was supposed to be. I think we discussed it some time ago, but for 
some reason it was never changed. Will submit a patch in a jiffie.

-Andi (to blame for that code) 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: my slab cache broken on sparc64
@ 2002-05-05 12:44 Holzrichter, Bruce
  0 siblings, 0 replies; 8+ messages in thread
From: Holzrichter, Bruce @ 2002-05-05 12:44 UTC (permalink / raw)
  To: 'David S. Miller'; +Cc: linux-kernel, 'zippel@linux-m68k.org'

>Do it like this instead.
>
>	int fault;
>	mm_segment_t old_fs;
>
>	...
>
>	old_fs = get_fs();
>	set_fs(KERNEL_DS);
>	fault = __get_user(tmp, pc->name);
>	set_fs(old_fs);
>
>	if (fault) {
>	...

Hmm.  Just got back to this, and I thought I had taken that into account and
left all the important parts out of a loop, or if, context.  I'll look at
what I DID do, though, and maybe I'll file that last patch under my things
you shouldn't do while half asleep folder...

Thanks
Bruce H.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: my slab cache broken on sparc64
  2002-05-04  3:07 ` David S. Miller
@ 2002-05-04  9:46   ` Roman Zippel
  0 siblings, 0 replies; 8+ messages in thread
From: Roman Zippel @ 2002-05-04  9:46 UTC (permalink / raw)
  To: David S. Miller; +Cc: bruce.holzrichter, linux-kernel, ak

Hi

On Fri, 3 May 2002, David S. Miller wrote:

> If the __get_user() fails, you will leave the kernel in the
> KERNEL_DS segment.
> 
> Do it like this instead.
> 
> 	int fault;
> 	mm_segment_t old_fs;
> 
> 	...
> 
> 	old_fs = get_fs();
> 	set_fs(KERNEL_DS);
> 	fault = __get_user(tmp, pc->name);
> 	set_fs(old_fs);
> 
> 	if (fault) {
> 	...

He can also simply move it outside of the loop to avoid this problem.

bye, Roman


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: my slab cache broken on sparc64
@ 2002-05-04  3:15 Holzrichter, Bruce
  2002-05-04  3:07 ` David S. Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Holzrichter, Bruce @ 2002-05-04  3:15 UTC (permalink / raw)
  To: 'davem@redhat.com'
  Cc: 'linux-kernel@vger.kernel.org', 'ak@muc.de'

>
>It would work if the access was surrounded by:
>
>	old_fs = get_fs();
>	set_fs(KERNEL_DS);
>	... get_user(kernel_pointer) ...
>	set_fs (old_fs);
>
>But it is not.

For what it's worth to you, the below patch fixes this issue, at least on my
box.  I have patched and tested on my Ultra5.  Thanks for the help!

Bruce H.

--- linus-2.5/mm/slab.c	Wed May  1 08:38:46 2002
+++ sparctest/mm/slab.c	Fri May  3 22:59:24 2002
@@ -846,11 +846,14 @@
 			/* This happens when the module gets unloaded and
doesn't
 			   destroy its slab cache and noone else reuses the
vmalloc
 			   area of the module. Print a warning. */
+			mm_segment_t old_fs = get_fs();
+			set_fs(KERNEL_DS);
 			if (__get_user(tmp,pc->name)) { 
 				printk("SLAB: cache with size %d has lost
its name\n", 
 					pc->objsize); 
 				continue; 
-			} 	
+			}
+			set_fs(old_fs); 	
 			if (!strcmp(pc->name,name)) { 
 				printk("kmem_cache_create: duplicate cache
%s\n",name); 
 				up(&cache_chain_sem); 
@@ -1963,10 +1966,13 @@
 
 	name = cachep->name; 
 	{
-	char tmp; 
+	char tmp;
+	mm_segment_t old_fs = get_fs();
+	set_fs(KERNEL_DS);
 	if (__get_user(tmp, name)) 
-		name = "broken"; 
-	} 	
+		name = "broken";
+	set_fs(old_fs); 
+	}
 
 	seq_printf(m, "%-17s %6lu %6lu %6u %4lu %4lu %4u",
 		name, active_objs, num_objs, cachep->objsize,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: my slab cache broken on sparc64
  2002-05-04  3:15 Holzrichter, Bruce
@ 2002-05-04  3:07 ` David S. Miller
  2002-05-04  9:46   ` Roman Zippel
  0 siblings, 1 reply; 8+ messages in thread
From: David S. Miller @ 2002-05-04  3:07 UTC (permalink / raw)
  To: bruce.holzrichter; +Cc: linux-kernel, ak

   From: "Holzrichter, Bruce" <bruce.holzrichter@monster.com>
   Date: Fri, 3 May 2002 22:15:56 -0500 

Your patch is buggy:

   +			mm_segment_t old_fs = get_fs();
   +			set_fs(KERNEL_DS);
    			if (__get_user(tmp,pc->name)) { 
    				printk("SLAB: cache with size %d has lost
   its name\n", 
    					pc->objsize); 
    				continue; 
   -			} 	
   +			}
   +			set_fs(old_fs); 	

If the __get_user() fails, you will leave the kernel in the
KERNEL_DS segment.

Do it like this instead.

	int fault;
	mm_segment_t old_fs;

	...

	old_fs = get_fs();
	set_fs(KERNEL_DS);
	fault = __get_user(tmp, pc->name);
	set_fs(old_fs);

	if (fault) {
	...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: my slab cache broken on sparc64
@ 2002-05-04  1:54 Holzrichter, Bruce
  0 siblings, 0 replies; 8+ messages in thread
From: Holzrichter, Bruce @ 2002-05-04  1:54 UTC (permalink / raw)
  To: 'David S. Miller'; +Cc: linux-kernel, 'ak@muc.de'

>get_user() MUST be used only on "user pointers", it is being
>used on a kernel pointer here.
>
>It would work if the access was surrounded by:
>
>	old_fs = get_fs();
>	set_fs(KERNEL_DS);
>	... get_user(kernel_pointer) ...
>	set_fs (old_fs);
>
>But it is not.

Ok, now I see it.   I'll change mine and try that out, though Andi Kleen
indicated he would fix it for real.  :o)

Thanks, Wow, two e-mails and a fix, that's got to be some kind of record
:o)
Bruce H.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-05-05 12:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-03 19:18 my slab cache broken on sparc64 Holzrichter, Bruce
2002-05-03 21:05 ` David S. Miller
2002-05-03 22:58   ` Andi Kleen
2002-05-04  1:54 Holzrichter, Bruce
2002-05-04  3:15 Holzrichter, Bruce
2002-05-04  3:07 ` David S. Miller
2002-05-04  9:46   ` Roman Zippel
2002-05-05 12:44 Holzrichter, Bruce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).