From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15108 invoked by alias); 28 Jan 2009 18:11:07 -0000 Received: (qmail 14857 invoked by uid 22791); 28 Jan 2009 18:11:05 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_45 X-Spam-Check-By: sourceware.org Received: from tomts10.bellnexxia.net (HELO tomts10-srv.bellnexxia.net) (209.226.175.54) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Jan 2009 18:10:57 +0000 Received: from toip3.srvr.bell.ca ([209.226.175.86]) by tomts10-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20090128181054.SANH1703.tomts10-srv.bellnexxia.net@toip3.srvr.bell.ca> for ; Wed, 28 Jan 2009 13:10:54 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuwEAOAsgElMQWt2/2dsb2JhbACBbstIhUcG Received: from bas5-montreal19-1279355766.dsl.bell.ca (HELO krystal.dyndns.org) ([76.65.107.118]) by toip3.srvr.bell.ca with ESMTP; 28 Jan 2009 13:05:57 -0500 Received: from localhost (localhost [127.0.0.1]) (uid 1000) by krystal.dyndns.org with local; Wed, 28 Jan 2009 13:10:53 -0500 id 0013AC90.49809FAD.00002B37 Date: Wed, 28 Jan 2009 18:13:00 -0000 From: Mathieu Desnoyers To: Masami Hiramatsu Cc: Nick Piggin , LKML , Ananth N Mavinakayanahalli , Jim Keniston , systemtap-ml , "Frank Ch. Eigler" Subject: Re: [BUG][kprobes][vunmap?]: kprobes may cause memory corruption Message-ID: <20090128181053.GC9908@Krystal> References: <497FC3B1.7050805@redhat.com> <497FE895.1080708@redhat.com> <20090128154824.GA6025@Krystal> <49808EEF.1020700@redhat.com> <20090128171331.GA9006@Krystal> <49809CCE.40409@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <49809CCE.40409@redhat.com> X-Editor: vi User-Agent: Mutt/1.5.16 (2007-06-11) X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00285.txt.bz2 * Masami Hiramatsu (mhiramat@redhat.com) wrote: > Mathieu Desnoyers wrote: > > * Masami Hiramatsu (mhiramat@redhat.com) wrote: > >> Mathieu Desnoyers wrote: > [...] > >>> All this called in a loop. This would help isolating the "vmap" part of > >>> the issue. If this test is not enough, then we should maybe try > >>> something like this in a kernel module (which does what text_poke does > >>> with vmalloc, more or less) in a loop : > >>> > >>> char somedata[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); > >>> char copydata[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); > >> Should both of them have PAGE_SIZE*2? > >> > > > > Yes. > > > >>> void test_vmap(void) > >>> } > >>> struct page *pages[2]; > >>> char *vaddr; > >>> int i; > >>> > >>> for (i = 0; i < 2 * PAGE_SIZE; i++) > >>> copydata[i] = somedata[i]; > >>> page[0] = virt_to_page(&somedata); > >>> BUG_ON(!page[0]); > >>> page[1] = virt_to_page(&somedata + PAGE_SIZE); > >>> BUG_ON(!page[1]); > > Oops, these should be vmalloc_to_page(), shouldn't it? > Yes, my bad. That should fix your oopses. Mathieu > >>> vaddr = vmap(pages, 2, VM_MAP, PAGE_KERNEL); > >>> BUG_ON(!vaddr); > >>> > >>> for (i = 0; i < 2 * PAGE_SIZE; i++) > >>> vaddr[i] = copydata[i] + 1; > >>> > >>> vunmap(vaddr); > >>> > >>> for (i = 0; i < 2 * PAGE_SIZE; i++) > >>> BUG_ON(somedata[i] != copydata[i] + 1); > >>> } > >> Hmm, when I ran above code, it hit the last BUG_ON(). > >> I checked that somedata[i] didn't updated. > >> > > > > Do you hit the BUG_ON after the first loop ? > > At the first loop, it hit the BUG_ON. > > >>> Given you don't seem to have hit the > >>> for (i = 0; i < len; i++) > >>> BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]); > >>> test at the end of text_poke, > >> However, when I ran kprobe-based test, it doesn't hit the BUG_ON() > >> in text_poke(). > >> > > > > The variable declarations should have been 2*PAGE_SIZE, hopefully you > > fixed them. > > Sure, > > > There is also a sync_core() in text_poke. It should not matter, but > > maybe that could help ? > > Adding sync_core() could not help me... anyway, I'll try again > with using vmalloc_to_page(). > > >>> I suspect the write through the vmapped > >>> area is correctly done, but that the problem may lay in the mm layer. > >>> Maybe it's running out of pre-allocated vmap areas or something like > >>> this ? > >> I haven't seen vmalloc failure message on 2.6.29-rc2. > >> > > > > It could be because the available vmalloc space is slightly higher. > > Looking into the lazy vunmap threshold would be useful. > > > > You could also try with loop values higher than 400. > > OK, Thanks, > > -- > Masami Hiramatsu > > Software Engineer > Hitachi Computer Products (America) Inc. > Software Solutions Division > > e-mail: mhiramat@redhat.com > -- Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68