From: David Smith Date: Tue, 28 May 2013 21:42:03 +0000 (-0500) Subject: Fix PR15543 by fixing the 'servername' convenience variables in the rpc tapset. X-Git-Tag: release-2.3~232 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=725917a8c10e5dc0f9f030680b1cc3b9a35def69;p=systemtap.git Fix PR15543 by fixing the 'servername' convenience variables in the rpc tapset. * tapset/linux/rpc.stp: Handle kernel change that moves the 'cl_server' field of the 'rpc_clnt' structure into the 'rpc_xprt' structure. * tapset/linux/rcu.stp: New file. --- diff --git a/tapset/linux/rcu.stp b/tapset/linux/rcu.stp new file mode 100644 index 000000000..c99023487 --- /dev/null +++ b/tapset/linux/rcu.stp @@ -0,0 +1,41 @@ +// rcu tapset +// Copyright (C) 2013 Red Hat +// +// This file is part of systemtap, and is free software. You can +// redistribute it and/or modify it under the terms of the GNU General +// Public License (GPL); either version 2, or (at your option) any +// later version. + +%{ +#include +#ifndef rcu_dereference_check +#define STAP_ALWAYS_ACQUIRE_RCU_LOCK +#endif +%} + +function rcu_dereference:long (protected_pointer:long) %{ /* pure */ + void *protected_pointer = (void *)(long)STAP_ARG_protected_pointer; + long fetched_value; + +#ifndef STAP_ALWAYS_ACQUIRE_RCU_LOCK + int lock_acquired = 0; + + if (! rcu_read_lock_held()) { + rcu_read_lock(); + lock_acquired = 1; + } +#else + rcu_read_lock(); +#endif + + fetched_value = (long)rcu_dereference(protected_pointer); + +#ifndef STAP_ALWAYS_ACQUIRE_RCU_LOCK + if (lock_acquired) { + rcu_read_unlock(); + } +#else + rcu_read_unlock(); +#endif + STAP_RETVALUE = fetched_value; +%} diff --git a/tapset/linux/rpc.stp b/tapset/linux/rpc.stp index 1aff639d3..b3ba4dff7 100644 --- a/tapset/linux/rpc.stp +++ b/tapset/linux/rpc.stp @@ -276,7 +276,9 @@ probe _sunrpc.clnt.create_client.return.rpc_create_client = probe sunrpc.clnt.clone_client = kernel.function("rpc_clone_client") !, module("sunrpc").function("rpc_clone_client") { - servername = kernel_string($clnt->cl_server) + servername = kernel_string(@choose_defined($clnt->cl_server, + @cast(rcu_dereference($clnt->cl_xprt), + "struct rpc_xprt")->servername)) progname = kernel_string($clnt->cl_protname) prog = prog_from_clnt($clnt) vers = vers_from_clnt($clnt) @@ -322,7 +324,9 @@ probe sunrpc.clnt.clone_client.return = probe sunrpc.clnt.shutdown_client = kernel.function("rpc_shutdown_client") !, module("sunrpc").function("rpc_shutdown_client") { - servername = kernel_string($clnt->cl_server) + servername = kernel_string(@choose_defined($clnt->cl_server, + @cast(rcu_dereference($clnt->cl_xprt), + "struct rpc_xprt")->servername)) progname = kernel_string($clnt->cl_protname) prog = prog_from_clnt($clnt) vers = vers_from_clnt($clnt) @@ -392,7 +396,9 @@ probe sunrpc.clnt.bind_new_program = kernel.function("rpc_bind_new_program") !, module("sunrpc").function("rpc_bind_new_program") { - servername = kernel_string($old->cl_server) + servername = kernel_string(@choose_defined($old->cl_server, + @cast(rcu_dereference($old->cl_xprt), + "struct rpc_xprt")->servername)) old_progname = kernel_string($old->cl_protname) old_prog = prog_from_clnt($old) old_vers = vers_from_clnt($old) @@ -431,7 +437,9 @@ probe sunrpc.clnt.bind_new_program.return = probe sunrpc.clnt.call_sync = kernel.function("rpc_call_sync") !, module("sunrpc").function("rpc_call_sync") { - servername = kernel_string($clnt->cl_server) + servername = kernel_string(@choose_defined($clnt->cl_server, + @cast(rcu_dereference($clnt->cl_xprt), + "struct rpc_xprt")->servername)) progname = kernel_string($clnt->cl_protname) prog = prog_from_clnt($clnt) vers = vers_from_clnt($clnt) @@ -476,7 +484,9 @@ probe sunrpc.clnt.call_sync.return = kernel.function("rpc_call_sync").return !, probe sunrpc.clnt.call_async = kernel.function("rpc_call_async") !, module("sunrpc").function("rpc_call_async") { - servername = kernel_string($clnt->cl_server) + servername = kernel_string(@choose_defined($clnt->cl_server, + @cast(rcu_dereference($clnt->cl_xprt), + "struct rpc_xprt")->servername)) progname = kernel_string($clnt->cl_protname) prog = prog_from_clnt($clnt) vers = vers_from_clnt($clnt) @@ -518,7 +528,9 @@ probe sunrpc.clnt.call_async.return = probe sunrpc.clnt.restart_call = kernel.function("rpc_restart_call") !, module("sunrpc").function("rpc_restart_call") { - servername = kernel_string($task->tk_client->cl_server) + servername = kernel_string(@choose_defined($task->tk_client->cl_server, + @cast(rcu_dereference($task->tk_client->cl_xprt), + "struct rpc_xprt")->servername)) prog = prog_from_clnt($task->tk_client) xid = $task->tk_rqstp->rq_xid tk_pid = $task->tk_pid