* [PATCH 1/3] SUNRPC: Ensure that task->tk_pid is unique... @ 2013-09-05 2:58 Trond Myklebust 2013-09-05 2:58 ` [PATCH 2/3] SUNRPC: Add an identifier for struct rpc_clnt Trond Myklebust 0 siblings, 1 reply; 3+ messages in thread From: Trond Myklebust @ 2013-09-05 2:58 UTC (permalink / raw) To: linux-nfs Replace the task->tk_pid with a guaranteed unique parameter. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> --- include/linux/sunrpc/sched.h | 3 ++- net/sunrpc/sched.c | 57 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 8ebb7c0..6e8657c 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -80,7 +80,7 @@ struct rpc_task { unsigned short tk_timeouts; /* maj timeouts */ #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS) - unsigned short tk_pid; /* debugging aid */ + unsigned int tk_pid; /* debugging aid */ #endif unsigned char tk_priority : 2,/* Task priority */ tk_garb_retry : 2, @@ -133,6 +133,7 @@ struct rpc_task_setup { #define RPC_TASK_RUNNING 0 #define RPC_TASK_QUEUED 1 #define RPC_TASK_ACTIVE 2 +#define RPC_TASK_PID 3 #define RPC_IS_RUNNING(t) test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) #define rpc_set_running(t) set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index ff3cc4b..fd15110 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -259,24 +259,55 @@ static int rpc_wait_bit_killable(void *word) } #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS) -static void rpc_task_set_debuginfo(struct rpc_task *task) +static DEFINE_IDA(rpc_pids); + +static int rpc_task_alloc_pid(struct rpc_task *task) { - static atomic_t rpc_pid; + int pid; + + pid = ida_simple_get(&rpc_pids, 0, 0, GFP_NOFS); + if (pid < 0) + return pid; + task->tk_pid = pid; + set_bit(RPC_TASK_PID, &task->tk_runstate); + return 0; +} - task->tk_pid = atomic_inc_return(&rpc_pid); +static bool rpc_task_need_free_pid(struct rpc_task *task) +{ + return test_and_clear_bit(RPC_TASK_PID, &task->tk_runstate) != 0; +} + +static void rpc_task_free_pid(int pid) +{ + ida_simple_remove(&rpc_pids, pid); } #else -static inline void rpc_task_set_debuginfo(struct rpc_task *task) +static int rpc_task_alloc_pid(struct rpc_task *task) +{ + return 0; +} + +static bool rpc_task_need_free_pid(struct rpc_task *task) +{ + return false; +} + +static void rpc_task_free_pid(int pid) { } #endif -static void rpc_set_active(struct rpc_task *task) +static int rpc_set_active(struct rpc_task *task) { - trace_rpc_task_begin(task->tk_client, task, NULL); + int ret; - rpc_task_set_debuginfo(task); + ret = rpc_task_alloc_pid(task); + if (ret < 0) + return ret; + trace_rpc_task_begin(task->tk_client, task, NULL); set_bit(RPC_TASK_ACTIVE, &task->tk_runstate); + return 0; } /* @@ -811,8 +842,14 @@ static void __rpc_execute(struct rpc_task *task) void rpc_execute(struct rpc_task *task) { bool is_async = RPC_IS_ASYNC(task); + int ret; - rpc_set_active(task); + ret = rpc_set_active(task); + if (ret < 0) { + task->tk_status = ret; + rpc_release_task(task); + return; + } rpc_make_runnable(task); if (!is_async) __rpc_execute(task); @@ -970,6 +1007,8 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data) static void rpc_free_task(struct rpc_task *task) { unsigned short tk_flags = task->tk_flags; + bool free_pid = rpc_task_need_free_pid(task); + int pid = task->tk_pid; rpc_release_calldata(task->tk_ops, task->tk_calldata); @@ -977,6 +1016,8 @@ static void rpc_free_task(struct rpc_task *task) dprintk("RPC: %5u freeing task\n", task->tk_pid); mempool_free(task, rpc_task_mempool); } + if (free_pid) + rpc_task_free_pid(pid); } static void rpc_async_release(struct work_struct *work) -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] SUNRPC: Add an identifier for struct rpc_clnt 2013-09-05 2:58 [PATCH 1/3] SUNRPC: Ensure that task->tk_pid is unique Trond Myklebust @ 2013-09-05 2:58 ` Trond Myklebust 2013-09-05 2:58 ` [PATCH 3/3] SUNRPC: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid Trond Myklebust 0 siblings, 1 reply; 3+ messages in thread From: Trond Myklebust @ 2013-09-05 2:58 UTC (permalink / raw) To: linux-nfs Add an identifier in order to aid debugging. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> --- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 76c0bf6..6740801 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -33,6 +33,7 @@ struct rpc_inode; */ struct rpc_clnt { atomic_t cl_count; /* Number of references */ + unsigned int cl_clid; /* client id */ struct list_head cl_clients; /* Global list of clients */ struct list_head cl_tasks; /* List of tasks */ spinlock_t cl_lock; /* spinlock */ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 0cd5b6d5..0a79069 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -313,6 +313,24 @@ out: return err; } +static DEFINE_IDA(rpc_clids); + +static int rpc_alloc_clid(struct rpc_clnt *clnt) +{ + int clid; + + clid = ida_simple_get(&rpc_clids, 0, 0, GFP_KERNEL); + if (clid < 0) + return clid; + clnt->cl_clid = clid; + return 0; +} + +static void rpc_free_clid(struct rpc_clnt *clnt) +{ + ida_simple_remove(&rpc_clids, clnt->cl_clid); +} + static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt, struct rpc_clnt *parent) @@ -343,6 +361,10 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, goto out_err; clnt->cl_parent = parent ? : clnt; + err = rpc_alloc_clid(clnt); + if (err) + goto out_no_clid; + rcu_assign_pointer(clnt->cl_xprt, xprt); clnt->cl_procinfo = version->procs; clnt->cl_maxproc = version->nrprocs; @@ -386,6 +408,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, out_no_path: rpc_free_iostats(clnt->cl_metrics); out_no_stats: + rpc_free_clid(clnt); +out_no_clid: kfree(clnt); out_err: rpciod_down(); @@ -646,6 +670,7 @@ rpc_free_client(struct rpc_clnt *clnt) clnt->cl_metrics = NULL; xprt_put(rcu_dereference_raw(clnt->cl_xprt)); rpciod_down(); + rpc_free_clid(clnt); kfree(clnt); } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] SUNRPC: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid 2013-09-05 2:58 ` [PATCH 2/3] SUNRPC: Add an identifier for struct rpc_clnt Trond Myklebust @ 2013-09-05 2:58 ` Trond Myklebust 0 siblings, 0 replies; 3+ messages in thread From: Trond Myklebust @ 2013-09-05 2:58 UTC (permalink / raw) To: linux-nfs Instead of the pointer values, use the task and client identifier values for tracing purposes. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> --- include/trace/events/sunrpc.h | 50 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index b74a8ac..d51d16c 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -17,18 +17,20 @@ DECLARE_EVENT_CLASS(rpc_task_status, TP_ARGS(task), TP_STRUCT__entry( - __field(const struct rpc_task *, task) - __field(const struct rpc_clnt *, clnt) + __field(unsigned int, task_id) + __field(unsigned int, client_id) __field(int, status) ), TP_fast_assign( - __entry->task = task; - __entry->clnt = task->tk_client; + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; __entry->status = task->tk_status; ), - TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status) + TP_printk("task:%u@%u, status %d", + __entry->task_id, __entry->client_id, + __entry->status) ); DEFINE_EVENT(rpc_task_status, rpc_call_status, @@ -49,18 +51,20 @@ TRACE_EVENT(rpc_connect_status, TP_ARGS(task, status), TP_STRUCT__entry( - __field(const struct rpc_task *, task) - __field(const struct rpc_clnt *, clnt) + __field(unsigned int, task_id) + __field(unsigned int, client_id) __field(int, status) ), TP_fast_assign( - __entry->task = task; - __entry->clnt = task->tk_client; + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; __entry->status = status; ), - TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status) + TP_printk("task:%u@%u, status %d", + __entry->task_id, __entry->client_id, + __entry->status) ); DECLARE_EVENT_CLASS(rpc_task_running, @@ -70,8 +74,8 @@ DECLARE_EVENT_CLASS(rpc_task_running, TP_ARGS(clnt, task, action), TP_STRUCT__entry( - __field(const struct rpc_clnt *, clnt) - __field(const struct rpc_task *, task) + __field(unsigned int, task_id) + __field(unsigned int, client_id) __field(const void *, action) __field(unsigned long, runstate) __field(int, status) @@ -79,17 +83,16 @@ DECLARE_EVENT_CLASS(rpc_task_running, ), TP_fast_assign( - __entry->clnt = clnt; - __entry->task = task; + __entry->client_id = clnt->cl_clid; + __entry->task_id = task->tk_pid; __entry->action = action; __entry->runstate = task->tk_runstate; __entry->status = task->tk_status; __entry->flags = task->tk_flags; ), - TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d action=%pf", - __entry->task, - __entry->clnt, + TP_printk("task:%u@%u flags=%4.4x state=%4.4lx status=%d action=%pf", + __entry->task_id, __entry->client_id, __entry->flags, __entry->runstate, __entry->status, @@ -128,8 +131,8 @@ DECLARE_EVENT_CLASS(rpc_task_queued, TP_ARGS(clnt, task, q), TP_STRUCT__entry( - __field(const struct rpc_clnt *, clnt) - __field(const struct rpc_task *, task) + __field(unsigned int, task_id) + __field(unsigned int, client_id) __field(unsigned long, timeout) __field(unsigned long, runstate) __field(int, status) @@ -138,8 +141,8 @@ DECLARE_EVENT_CLASS(rpc_task_queued, ), TP_fast_assign( - __entry->clnt = clnt; - __entry->task = task; + __entry->client_id = clnt->cl_clid; + __entry->task_id = task->tk_pid; __entry->timeout = task->tk_timeout; __entry->runstate = task->tk_runstate; __entry->status = task->tk_status; @@ -147,9 +150,8 @@ DECLARE_EVENT_CLASS(rpc_task_queued, __assign_str(q_name, rpc_qname(q)); ), - TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s", - __entry->task, - __entry->clnt, + TP_printk("task:%u@%u flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s", + __entry->task_id, __entry->client_id, __entry->flags, __entry->runstate, __entry->status, -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-05 2:59 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-09-05 2:58 [PATCH 1/3] SUNRPC: Ensure that task->tk_pid is unique Trond Myklebust 2013-09-05 2:58 ` [PATCH 2/3] SUNRPC: Add an identifier for struct rpc_clnt Trond Myklebust 2013-09-05 2:58 ` [PATCH 3/3] SUNRPC: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid Trond Myklebust
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).