[PATCH 0/1] SUNRPC: convert RPC_TASK_* constants to enum

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

For context on this change, I work on the drgn debugger [1] and also
maintain a growing set of helpers [2] that can examine live systems & core
dumps and give detailed information about the state of different
subsystems. One such helper (not written by me) shows all RPC tasks and
their states. For example:

=============================== RPC_TASK =================================
---- <rpc_task: 0xffff8dc383548a00>  tk_op: nfs4_delegreturn_ops  tk_action: call_status
     tk_client: 0xffff8dc385c0fe00  tk_client.cl_xprt: 0xffff8dc4f79f9000
     tk_xprt: 0xffff8dc4f79f9000
     tk_status: 0 (OK) tk_rpc_status[0] (OK)
     tk_runstate: 0x16  (RPC_TASK_QUEUED|RPC_TASK_ACTIVE|RPC_TASK_MSG_RECV_WAIT)
     tk_priority: 1  tk_timeout(ticks): 6095245983  tk_timeouts(major): 0
     <tk_rqstp: 0xffff8dc47025d000>  rq_xid: 0x96143ed3  rq_retries: 0

---- <rpc_task: 0xffff8dc383548400>  tk_op: nfs4_close_ops  tk_action: call_status
     tk_client: 0xffff8dc385c0fe00  tk_client.cl_xprt: 0xffff8dc4f79f9000
     tk_xprt: 0xffff8dc4f79f9000
     tk_status: 0 (OK) tk_rpc_status[0] (OK)
     tk_runstate: 0x16  (RPC_TASK_QUEUED|RPC_TASK_ACTIVE|RPC_TASK_MSG_RECV_WAIT)
     tk_priority: 1  tk_timeout(ticks): 6095245983  tk_timeouts(major): 0
     <tk_rqstp: 0xffff8dc47025ca00>  rq_xid: 0x96143ed4  rq_retries: 0

To do that it needs to be able to interpret the RPC_TASK_* constants back
to their human readable names. Of course these can be hard-coded and this
has been done, but in this particular case, the RPC state codes have been
updated and changed several times:

729749bb8da1 ("SUNRPC: Don't hold the transport lock across socket copy operations")
7ebbbc6e7bd0 ("SUNRPC: Simplify identification of when the message send/receive is complete")
cf9946cd6144 ("SUNRPC: Refactor the transport request pinning")
ae67bd3821bb ("SUNRPC: Fix up task signalling")

Most of these simply add to the end of the list, but at least one (7ebbbc6e7bd0)
shuffles around existing codes. Creating maintainable debugging scripts that can
be used over a range of kernel versions is difficult when you need to detect
these sorts of shuffles. We *can* do this by detecting the presence or existence
of other code changes that occurred in the same commit, but this tends to get
tedious, and it's not very reliable. It certainly won't help in case a similar
change happens in the future.

Converting constants from macros to enums is a great way to avoid this for the
future. While macros aren't typically encoded in debuginfo, enum definitions
are. Of course macros aren't always suitable for 64-bit constants. But in this
case, the RPC_TASK_* constants are bit numbers, so they aren't impacted by this
limitation. So this change shouldn't have any impact except making the code
easier to debug.

Thanks,
Stephen

[1]: https://drgn.readthedocs.io/en/latest/
[2]: https://github.com/oracle-samples/drgn-tools

Stephen Brennan (1):
  SUNRPC: convert RPC_TASK_* constants to enum

 include/linux/sunrpc/sched.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

-- 
2.43.5





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux