From oleg at redhat.com Mon Jan 30 17:47:19 2012 From: oleg at redhat.com (Oleg Nesterov) Date: Mon, 30 Jan 2012 18:47:19 +0100 Subject: [PATCH 0/1] (Was: utrace for 3.3 kernel) In-Reply-To: <20120125211005.GI13655@zod.bos.redhat.com> References: <20120120184128.GA3198@zod.bos.redhat.com> <20120120184235.GA32521@redhat.com> <20120120190044.GC3198@zod.bos.redhat.com> <20120125181248.GA26600@redhat.com> <20120125181310.GB26600@redhat.com> <20120125211005.GI13655@zod.bos.redhat.com> Message-ID: <20120130174719.GA14182@redhat.com> On 01/25, Josh Boyer wrote: > > I'll get this into rawhide this evening. Thanks Josh. There is another simple change, I forgout about it. It is purely internal, has no effect outside of utrace.c. Oleg. From oleg at redhat.com Mon Jan 30 17:47:40 2012 From: oleg at redhat.com (Oleg Nesterov) Date: Mon, 30 Jan 2012 18:47:40 +0100 Subject: [PATCH 1/1] utrace: introduce UTRACE_ATTACH_ATOMIC In-Reply-To: <20120130174719.GA14182@redhat.com> References: <20120120184128.GA3198@zod.bos.redhat.com> <20120120184235.GA32521@redhat.com> <20120120190044.GC3198@zod.bos.redhat.com> <20120125181248.GA26600@redhat.com> <20120125181310.GB26600@redhat.com> <20120125211005.GI13655@zod.bos.redhat.com> <20120130174719.GA14182@redhat.com> Message-ID: <20120130174740.GB14182@redhat.com> Add the new UTRACE_ATTACH_ATOMIC flag for utrace_attach_task(). If it is set, UTRACE_ATTACH_CREATE uses GFP_ATOMIC for memory allocations and thus it can be used in atomic context. Suggested-by: Mark Wielaard Signed-off-by: Oleg Nesterov --- include/linux/utrace.h | 1 + kernel/utrace.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/utrace.h b/include/linux/utrace.h index f37373b..46959af 100644 --- a/include/linux/utrace.h +++ b/include/linux/utrace.h @@ -317,6 +317,7 @@ static inline enum utrace_syscall_action utrace_syscall_action(u32 action) #define UTRACE_ATTACH_MATCH_MASK 0x000f #define UTRACE_ATTACH_CREATE 0x0010 /* Attach a new engine. */ #define UTRACE_ATTACH_EXCLUSIVE 0x0020 /* Refuse if existing match. */ +#define UTRACE_ATTACH_ATOMIC 0x0040 /* For _CREATE, don't sleep */ /** * struct utrace_engine - per-engine structure diff --git a/kernel/utrace.c b/kernel/utrace.c index c817a46..a169e1b 100644 --- a/kernel/utrace.c +++ b/kernel/utrace.c @@ -113,9 +113,9 @@ void task_utrace_unlock(struct task_struct *task) * * This returns false only in case of a memory allocation failure. */ -static bool utrace_task_alloc(struct task_struct *task) +static bool utrace_task_alloc(struct task_struct *task, gfp_t gfp_flags) { - struct utrace *utrace = kmem_cache_zalloc(utrace_cachep, GFP_KERNEL); + struct utrace *utrace = kmem_cache_zalloc(utrace_cachep, gfp_flags); if (unlikely(!utrace)) return false; spin_lock_init(&utrace->lock); @@ -295,6 +295,7 @@ struct utrace_engine *utrace_attach_task( { struct utrace *utrace = task_utrace_struct(target); struct utrace_engine *engine; + gfp_t gfp_flags; int ret; if (!(flags & UTRACE_ATTACH_CREATE)) { @@ -317,13 +318,16 @@ struct utrace_engine *utrace_attach_task( */ return ERR_PTR(-EPERM); + gfp_flags = (flags & UTRACE_ATTACH_ATOMIC) + ? GFP_ATOMIC : GFP_KERNEL; + if (!utrace) { - if (unlikely(!utrace_task_alloc(target))) + if (unlikely(!utrace_task_alloc(target, gfp_flags))) return ERR_PTR(-ENOMEM); utrace = task_utrace_struct(target); } - engine = kmem_cache_alloc(utrace_engine_cachep, GFP_KERNEL); + engine = kmem_cache_alloc(utrace_engine_cachep, gfp_flags); if (unlikely(!engine)) return ERR_PTR(-ENOMEM); -- 1.5.5.1 From jwboyer at redhat.com Mon Jan 30 18:23:59 2012 From: jwboyer at redhat.com (Josh Boyer) Date: Mon, 30 Jan 2012 13:23:59 -0500 Subject: [PATCH 1/1] utrace: introduce UTRACE_ATTACH_ATOMIC In-Reply-To: <20120130174740.GB14182@redhat.com> References: <20120120184128.GA3198@zod.bos.redhat.com> <20120120184235.GA32521@redhat.com> <20120120190044.GC3198@zod.bos.redhat.com> <20120125181248.GA26600@redhat.com> <20120125181310.GB26600@redhat.com> <20120125211005.GI13655@zod.bos.redhat.com> <20120130174719.GA14182@redhat.com> <20120130174740.GB14182@redhat.com> Message-ID: <20120130182358.GB25956@zod.bos.redhat.com> On Mon, Jan 30, 2012 at 06:47:40PM +0100, Oleg Nesterov wrote: > Add the new UTRACE_ATTACH_ATOMIC flag for utrace_attach_task(). > If it is set, UTRACE_ATTACH_CREATE uses GFP_ATOMIC for memory > allocations and thus it can be used in atomic context. > > Suggested-by: Mark Wielaard > Signed-off-by: Oleg Nesterov I'll get this into rawhide today. Thanks! josh From jistone at redhat.com Tue Feb 7 02:44:30 2012 From: jistone at redhat.com (Josh Stone) Date: Mon, 06 Feb 2012 18:44:30 -0800 Subject: [PATCH 0/31] utrace for 3.1 kernel In-Reply-To: <451D9D152E615C41A9EF585F59D41CAB045F0B@SHSMSX101.ccr.corp.intel.com> References: <20110802174514.GA23073@redhat.com> <20110803190806.GA30619@redhat.com> <451D9D152E615C41A9EF585F59D41CAB045F0B@SHSMSX101.ccr.corp.intel.com> Message-ID: <4F30900E.4020103@redhat.com> On 02/06/2012 06:24 PM, Ying, Victor wrote: > I have problem to checkout utrace via "git clone > git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git > utrace-3.0", it always reports "fatal: the remote end hung up > unexpectedly"; I tried both utrace-3.0 and utrace-3.1, none of them > works. I don't think Oleg has restored his account since kernel.org was rebuilt. He's been posting utrace on github instead, so try: git://github.com/utrace/linux.git Josh From oleg at redhat.com Tue Feb 7 19:23:10 2012 From: oleg at redhat.com (Oleg Nesterov) Date: Tue, 7 Feb 2012 20:23:10 +0100 Subject: [PATCH 0/31] utrace for 3.1 kernel In-Reply-To: <4F30900E.4020103@redhat.com> References: <20110802174514.GA23073@redhat.com> <20110803190806.GA30619@redhat.com> <451D9D152E615C41A9EF585F59D41CAB045F0B@SHSMSX101.ccr.corp.intel.com> <4F30900E.4020103@redhat.com> Message-ID: <20120207192310.GA20230@redhat.com> On 02/06, Josh Stone wrote: > > On 02/06/2012 06:24 PM, Ying, Victor wrote: > > I have problem to checkout utrace via "git clone > > git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git > > utrace-3.0", it always reports "fatal: the remote end hung up > > unexpectedly"; I tried both utrace-3.0 and utrace-3.1, none of them > > works. > > I don't think Oleg has restored his account since kernel.org was > rebuilt. He's been posting utrace on github instead, so try: > git://github.com/utrace/linux.git Yes, thanks Josh. There are utrace-3.0 utrace-3.1 utrace-3.2 utrace-3.3 branches for different kernel versions. Oleg. From victor.ying at intel.com Tue Feb 7 02:24:55 2012 From: victor.ying at intel.com (Ying, Victor) Date: Tue, 7 Feb 2012 02:24:55 +0000 Subject: [PATCH 0/31] utrace for 3.1 kernel In-Reply-To: <20110803190806.GA30619@redhat.com> References: <20110802174514.GA23073@redhat.com> <20110803190806.GA30619@redhat.com> Message-ID: <451D9D152E615C41A9EF585F59D41CAB045F0B@SHSMSX101.ccr.corp.intel.com> Hi Oleg, I have problem to checkout utrace via "git clone git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git utrace-3.0", it always reports "fatal: the remote end hung up unexpectedly"; I tried both utrace-3.0 and utrace-3.1, none of them works. But have no issue to checkout kernel via "git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git", so I think my client should be ok. Any idea to fix this? Thanks. Best Regards, Victor -----Original Message----- From: utrace-devel-bounces at redhat.com [mailto:utrace-devel-bounces at redhat.com] On Behalf Of Oleg Nesterov Sent: Thursday, August 04, 2011 3:08 AM To: Dave Jones; Frank Ch. Eigler; Josh Boyer; Josh Stone; Kyle McMartin Cc: utrace-devel at redhat.com; kernel at lists.fedoraproject.org Subject: [PATCH 0/31] utrace for 3.1 kernel On 08/02, Oleg Nesterov wrote: > > utrace patches for 3.1 kernel. Untested, will try to do some tests > tomorrow. I tried to test it a bit, seems to work. But see the new "[PATCH 31/31] utrace_resume: check irqs_disabled() to shut up lockdep". The whole series is available in git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git utrace-3.1 Oleg. From tianhaox.liu at intel.com Tue Mar 27 03:10:49 2012 From: tianhaox.liu at intel.com (Liu, TianhaoX) Date: Tue, 27 Mar 2012 03:10:49 +0000 Subject: How can I user @cast in the user-space's program or have other ways to assign values to the user-space pointer to a structure. Message-ID: <3BF455748ADC99429424A88BBC4690619346B7@SHSMSX101.ccr.corp.intel.com> Hi, John. I have a problem to cast a pointer to a structure in the user-space's program. It always report "ERROR: kernel write fault at 0x0000000000400675 (addr) near identifier '@cast' at test.stp:3:8". Compile the source file and execute the stap command. liuth at liuthivb:~/$ gcc -g -o test test.c liuth at liuthivb:~/$ sudo stap -w -vg test.stp -c ./test Pass 1: parsed user script and 81 library script(s) using 49344virt/22060res/2024shr kb, in 130usr/0sys/125real ms. Pass 2: analyzed script: 2 probe(s), 9 function(s), 0 embed(s), 0 global(s) using 51992virt/23168res/2540shr kb, in 10usr/0sys/5real ms. Pass 3: using cached /home/liuth/.systemtap/cache/5c/stap_5c288dc4a44724d509924f222aedb626_9050.c Pass 4: using cached /home/liuth/.systemtap/cache/5c/stap_5c288dc4a44724d509924f222aedb626_9050.ko Pass 5: starting run. hello world call------------------------------call The value of a:[F] The value of b:[10] call------------------------------call ERROR: kernel write fault at 0x00000000004005b5 (addr) near identifier '@cast' at test.stp:3:8 Pass 5: run completed in 10usr/0sys/589real ms. Pass 5: run failed. Try again with another '--vp 00001' option. I have modified the test.stp as follows. probe process("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function("funcStruct").call { // compilation error // @cast($pStruct, "struct TestStruct", "test.h ")->a = 31 //@cast($pStruct, "struct TestStruct", "test.h ")->b = 32 // ERROR: kernel write fault at 0x00000000004005b5 (addr) near identifier '@cast' at test.stp:3:8 //@cast($pStruct, "struct TestStruct", " ")->a = 31 //@cast($pStruct, "struct TestStruct", " ")->b = 32 // ERROR: kernel read fault at 0x000000200000001f (addr) near identifier '$pStruct' at test.stp:5:60 //@cast(&$pStruct, "struct TestStruct", " ")->a = 31 //@cast(&$pStruct, "struct TestStruct", " ")->b = 32 @cast($pStruct, "struct TestStruct")->a = 31 @cast($pStruct, "struct TestStruct")->b = 32 printf("The value of a:[%X] The value of b:[%X]\n", $pStruct->a, $pStruct->b) } The following are the program and the script. ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Header file test.h: #include #include typedef struct TestStruct { int a; int b; }ST_Test_Struct; int func(ST_Test_Struct tmpStruct); int funcStruct(ST_Test_Struct* pStruct); source file test.c: #include "test.h" int func(ST_Test_Struct tmpStruct) { return tmpStruct.a + tmpStruct.b; } int funcStruct(ST_Test_Struct* pStruct) { return pStruct->a + pStruct->b; } int main(int argc, char** argv) { ST_Test_Struct tmpStruct = { 1,2 }; func(tmpStruct); funcStruct(&tmpStruct); printf("hello world\n"); return 0; } script test.stp: probe process("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function("funcStruct").call { @cast($pStruct, "struct TestStruct")->a = 31 @cast($pStruct, "struct TestStruct")->b = 32 printf("The value of a:[%X] The value of b:[%X]\n", $pStruct->a, $pStruct->b) } probe process("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function("func").call { printf("call------------------------------call\n") $tmpStruct->a =15; $tmpStruct->b =16; printf("The value of a:[%X] The value of b:[%X]\n", $tmpStruct->a, $tmpStruct->b) printf("call------------------------------call\n") } Best Regards, Tianhao -------------- next part -------------- An HTML attachment was scrubbed... URL: From tianhaox.liu at intel.com Tue Mar 27 03:06:23 2012 From: tianhaox.liu at intel.com (Liu Tianhao) Date: Tue, 27 Mar 2012 03:06:23 +0000 (UTC) Subject: How can I user @cast in the user-space's program or have other ways to aasign valus to the user-space pointer to a structure. Message-ID: I have a problem to cast a pointer to a structure in the user-space?s program. It always report ?ERROR: kernel write fault at 0x0000000000400675 (addr) near identifier '@cast' at test.stp:3:8?. Compile the source file and execute the stap command. liuth at liuthivb:~/$ gcc -g -o test test.c liuth at liuthivb:~/$ sudo stap -w -vg test.stp -c ./test Pass 1: parsed user script and 81 library script(s) using 49344virt/22060res/2024shr kb, in 130usr/0sys/125real ms. Pass 2: analyzed script: 2 probe(s), 9 function(s), 0 embed(s), 0 global(s) using 51992virt/23168res/2540shr kb, in 10usr/0sys/5real ms. Pass 3: using cached /home/liuth/.systemtap/cache/5c/stap_5c288dc4a44724d509924f222aedb626_90 50.c Pass 4: using cached /home/liuth/.systemtap/cache/5c/stap_5c288dc4a44724d509924f222aedb626_90 50.ko Pass 5: starting run. hello world call------------------------------call The value of a:[F] The value of b:[10] call------------------------------call ERROR: kernel write fault at 0x00000000004005b5 (addr) near identifier '@cast' at test.stp:3:8 Pass 5: run completed in 10usr/0sys/589real ms. Pass 5: run failed. Try again with another '--vp 00001' option. I have modified the test.stp as follows. probe process ("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function ("funcStruct").call { // compilation error // @cast($pStruct, "struct TestStruct", "test.h ")->a = 31 //@cast($pStruct, "struct TestStruct", "test.h ")->b = 32 // ERROR: kernel write fault at 0x00000000004005b5 (addr) near identifier '@cast' at test.stp:3:8 //@cast($pStruct, "struct TestStruct", " ")->a = 31 //@cast($pStruct, "struct TestStruct", " ")->b = 32 // ERROR: kernel read fault at 0x000000200000001f (addr) near identifier '$pStruct' at test.stp:5:60 //@cast(&$pStruct, "struct TestStruct", " ")->a = 31 //@cast(&$pStruct, "struct TestStruct", " ")->b = 32 @cast($pStruct, "struct TestStruct")->a = 31 @cast($pStruct, "struct TestStruct")->b = 32 printf("The value of a:[%X] The value of b:[%X]\n", $pStruct->a, $pStruct->b) } The following are the program and the script. ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- ----- Header file test.h: #include #include typedef struct TestStruct { int a; int b; }ST_Test_Struct; //int func(int a, int b, int c) int func(ST_Test_Struct tmpStruct); int funcStruct(ST_Test_Struct* pStruct); source file test.c: #include "test.h" int func(ST_Test_Struct tmpStruct) { return tmpStruct.a + tmpStruct.b; } int funcStruct(ST_Test_Struct* pStruct) { return pStruct->a + pStruct->b; } int main(int argc, char** argv) { ST_Test_Struct tmpStruct = { 1,2 }; func(tmpStruct); funcStruct(&tmpStruct); printf("hello world\n"); return 0; } script test.stp: probe process ("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function ("funcStruct").call { @cast($pStruct, "struct TestStruct")->a = 31 @cast($pStruct, "struct TestStruct")->b = 32 printf("The value of a:[%X] The value of b:[%X]\n", $pStruct->a, $pStruct->b) } probe process ("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function ("func").call { printf("call------------------------------call\n") $tmpStruct->a =15; $tmpStruct->b =16; printf("The value of a:[%X] The value of b:[%X]\n", $tmpStruct->a, $tmpStruct->b) printf("call------------------------------call\n") } From dsmith at redhat.com Tue Mar 27 18:11:33 2012 From: dsmith at redhat.com (David Smith) Date: Tue, 27 Mar 2012 13:11:33 -0500 Subject: How can I user @cast in the user-space's program or have other ways to aasign valus to the user-space pointer to a structure. In-Reply-To: References: Message-ID: <4F7202D5.40500@redhat.com> Liu, This is really a question for the systemtap list, not the utrace list. Forwarding there. Also see possible answer below. On 03/26/2012 10:06 PM, Liu Tianhao wrote: > I have a problem to cast a pointer to a structure in the user-space?s program. > It always report ?ERROR: kernel write fault at 0x0000000000400675 (addr) near > identifier '@cast' at test.stp:3:8?. > > Compile the source file and execute the stap command. > liuth at liuthivb:~/$ gcc -g -o test test.c > liuth at liuthivb:~/$ sudo stap -w -vg test.stp -c ./test > Pass 1: parsed user script and 81 library script(s) using > 49344virt/22060res/2024shr kb, in 130usr/0sys/125real ms. > Pass 2: analyzed script: 2 probe(s), 9 function(s), 0 embed(s), 0 global(s) > using 51992virt/23168res/2540shr kb, in 10usr/0sys/5real ms. > Pass 3: using > cached /home/liuth/.systemtap/cache/5c/stap_5c288dc4a44724d509924f222aedb626_90 > 50.c > Pass 4: using > cached /home/liuth/.systemtap/cache/5c/stap_5c288dc4a44724d509924f222aedb626_90 > 50.ko > Pass 5: starting run. > hello world > call------------------------------call > The value of a:[F] The value of b:[10] > call------------------------------call > ERROR: kernel write fault at 0x00000000004005b5 (addr) near identifier '@cast' > at test.stp:3:8 > Pass 5: run completed in 10usr/0sys/589real ms. > Pass 5: run failed. Try again with another '--vp 00001' option. > > I have modified the test.stp as follows. > probe process > ("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function > ("funcStruct").call > { > // compilation error > // @cast($pStruct, "struct TestStruct", "test.h ")->a = 31 > //@cast($pStruct, "struct TestStruct", "test.h ")->b = 32 > > // ERROR: kernel write fault at 0x00000000004005b5 (addr) near > identifier '@cast' at test.stp:3:8 > //@cast($pStruct, "struct TestStruct", " ")->a = 31 > //@cast($pStruct, "struct TestStruct", " ")->b = 32 > > // ERROR: kernel read fault at 0x000000200000001f (addr) near > identifier '$pStruct' at test.stp:5:60 > //@cast(&$pStruct, "struct TestStruct", " ")->a = 31 > //@cast(&$pStruct, "struct TestStruct", " ")->b = 32 > > @cast($pStruct, "struct TestStruct")->a = 31 > @cast($pStruct, "struct TestStruct")->b = 32 > printf("The value of a:[%X] The value of b:[%X]\n", $pStruct->a, > $pStruct->b) > } Hmm, what happens when you just use the pointer directly, like this: $pStruct->a = 31 $pStruct->b = 32 > The following are the program and the script. > ------------------------------------------------------------------------------- > ------------------------------------------------------------------------------- > ----- > Header file test.h: > #include > #include > typedef struct TestStruct > { > int a; > int b; > }ST_Test_Struct; > > //int func(int a, int b, int c) > int func(ST_Test_Struct tmpStruct); > int funcStruct(ST_Test_Struct* pStruct); > > source file test.c: > #include "test.h" > int func(ST_Test_Struct tmpStruct) > { > return tmpStruct.a + tmpStruct.b; > } > > int funcStruct(ST_Test_Struct* pStruct) > { > return pStruct->a + pStruct->b; > } > > int main(int argc, char** argv) > { > ST_Test_Struct tmpStruct = { 1,2 }; > func(tmpStruct); > funcStruct(&tmpStruct); > printf("hello world\n"); > return 0; > } > > script test.stp: > probe process > ("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function > ("funcStruct").call > { > @cast($pStruct, "struct TestStruct")->a = 31 > @cast($pStruct, "struct TestStruct")->b = 32 > printf("The value of a:[%X] The value of b:[%X]\n", $pStruct->a, > $pStruct->b) > } > probe process > ("/home/liuth/worksource/ddtv/tracedrv/java/DDTVConfig/test").function > ("func").call > { > printf("call------------------------------call\n") > $tmpStruct->a =15; > $tmpStruct->b =16; > printf("The value of a:[%X] The value of b:[%X]\n", $tmpStruct->a, > $tmpStruct->b) > printf("call------------------------------call\n") > } > > -- David Smith dsmith at redhat.com Red Hat http://www.redhat.com 256.217.0141 (direct) 256.837.0057 (fax)