Hide Forgot
procps and procps-ng in rhel7 apparently try to output a "prettier" output for the wchan data. The code basically does this: proc/ksym.c:read_wchan() and lookup_wchan() (but the later should not be used) [...] if(*ret=='.') ret++; switch(*ret){ case 's': if(!strncmp(ret, "sys_", 4)) ret += 4; break; case 'd': if(!strncmp(ret, "do_", 3)) ret += 3; break; case '_': while(*ret=='_') ret++; break; } [...] The problem is that there are common cases where stripping the "do_" or "sys_" may cause one to think that it is referring to a completely different code. The /proc/$pid/wchan contents are still correct. This is a RFC because if outputting the /proc/$pid/wchan contents, while "truly" correct, most likely would print mostly "do_" and "sys_" strings in a 6 characters field, unless using options to print in a larger column. Maybe there could be a flag to not remove the prefix if "-o wchan" is passed in the command line.
Hello Paulo, I don't understand "completely different code" in "...may cause one to think that it is referring to a completely different code." Can you please be more verbose what ambiguity this part of lookup_wchan() might cause? I listed all occurrences of "sys_" and "do_" in all wchan files in /proc and I didn't encounter anything suspicious. Tried on RHEL6 and RHEL7.
Hi Jan, The comment was due the reason the bug report was opened, where ps was showing "get_write_access", that is a generic function in the VFS layer, that locks an inode, while it actually was in "do_get_write_access", that is a jbd2 function. Part of the problem is that there is no real rules about function naming, that would say that "sys_" is a prefix for syscalls, or "do_" is an actual implementation of a syscall.
Thank you Paulo, this looks like a good proposal to discuss with upstream.
Created attachment 1223222 [details] wchan info stripping removed Introduced new better patch to fix the issue and stay aligned with upstream. Stripping prefixed from wchan data was removed, since it led to ambiguities and the purpose of the feature is untraceable.
Doc note: Since stripping of "do_" and "sys_" was removed completely, formerly proposed "wchanf" option was discarded (no longer needed). This is aligned with upstream.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2017-0769.html