Re: odd TRACE_DEFINE_ENUM behavior

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

 



> On Jan 4, 2018, at 2:39 PM, Chuck Lever <chuck.lever@xxxxxxxxxx> wrote:
> 
>> 
>> On Jan 4, 2018, at 2:36 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>> 
>> On Thu, 4 Jan 2018 14:10:21 -0500
>> Chuck Lever <chuck.lever@xxxxxxxxxx> wrote:
>> 
>>>>> #define nfs_show_stable(stable) \
>>>>> 	__print_symbolic(stable, \
>>>>> 			{ NFS_UNSTABLE, " (UNSTABLE)" }, \
>>>>> 			{ NFS_DATA_SYNC, " (DATA_SYNC)" }, \
>>>>> 			{ NFS_FILE_SYNC, " (FILE_SYNC)" })
>>>>> 
>>>>> When the field contains 0 it displays "(UNSTABLE)", and when the field
>>>>> contains a non-zero value the displayed symbol is blank.  
>>>> nfs_initiate_write,
>>>> Can you show my what is in
>> 
>> Are you sure that it isn't another number there?
> 
> Yes.
> 
> 
>>>> /sys/kernel/debug/tracing/events/nfs/nfs_initiate_write/format  
>>> 
>>> This is with current v4.15-rc6 code base:
>>> 
>>> name: nfs_initiate_write
>>> ID: 1818
>>> format:
>>> 	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
>>> 	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
>>> 	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
>>> 	field:int common_pid;	offset:4;	size:4;	signed:1;
>>> 
>>> 	field:loff_t offset;	offset:8;	size:8;	signed:1;
>>> 	field:unsigned long count;	offset:16;	size:8;	signed:0;
>>> 	field:enum nfs3_stable_how stable;	offset:24;	size:4;	signed:1;
>>> 	field:dev_t dev;	offset:28;	size:4;	signed:0;
>>> 	field:u32 fhandle;	offset:32;	size:4;	signed:0;
>>> 	field:u64 fileid;	offset:40;	size:8;	signed:0;
>>> 
>>> print fmt: "fileid=%02x:%02x:%llu fhandle=0x%08x offset=%lld count=%lu stable=%d%s", ((unsigned int) ((REC->dev) >> 20)), ((unsigned int) ((REC->dev) & ((1U << 20) - 1))), (unsigned long long)REC->fileid, REC->fhandle, REC->offset, REC->count, REC->stable, __print_symbolic(REC->stable, { 0, " (UNSTABLE)" }, { 1, " (DATA_SYNC)" }, { 2, " (FILE_SYNC)" })
>> 
>> This looks like it should work fine.
> 
> This does work fine. The source code avoids using TRACE_DEFINE_ENUM.
> Do you want me to wire up the "proper" way to implement nfs_show_stable
> and we can experiment on that?

include/linux/nfs.h has:

 47 enum nfs3_stable_how {
 48         NFS_UNSTABLE = 0,
 49         NFS_DATA_SYNC = 1,
 50         NFS_FILE_SYNC = 2,
 51 
 52         /* used by direct.c to mark verf as invalid */
 53         NFS_INVALID_STABLE_HOW = -1
 54 };

I applied this patch to v4.15-rc6:

diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 093290c..94d4f2e 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -796,15 +796,15 @@
                )
 );
 
-/*
- * XXX: I tried using NFS_UNSTABLE and friends in this table, but they
- * all evaluate to 0 for some reason, even if I include linux/nfs.h.
- */
+TRACE_DEFINE_ENUM(NFS_UNSTABLE);
+TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
+TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
+
 #define nfs_show_stable(stable) \
        __print_symbolic(stable, \
-                       { 0, " (UNSTABLE)" }, \
-                       { 1, " (DATA_SYNC)" }, \
-                       { 2, " (FILE_SYNC)" })
+                       { NFS_UNSTABLE, " (UNSTABLE)" }, \
+                       { NFS_DATA_SYNC, " (DATA_SYNC)" }, \
+                       { NFS_FILE_SYNC, " (FILE_SYNC)" })
 
 TRACE_EVENT(nfs_initiate_write,
                TP_PROTO(


eval_map now has this:

NFS_FILE_SYNC 2 (nfs)
NFS_DATA_SYNC 1 (nfs)
NFS_UNSTABLE 0 (nfs)

but nfs_initiate_write/format has this:

name: nfs_initiate_write
ID: 1818
format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:loff_t offset;	offset:8;	size:8;	signed:1;
	field:unsigned long count;	offset:16;	size:8;	signed:0;
	field:enum nfs3_stable_how stable;	offset:24;	size:4;	signed:1;
	field:dev_t dev;	offset:28;	size:4;	signed:0;
	field:u32 fhandle;	offset:32;	size:4;	signed:0;
	field:u64 fileid;	offset:40;	size:8;	signed:0;

print fmt: "fileid=%02x:%02x:%llu fhandle=0x%08x offset=%lld count=%lu stable=%d%s", ((unsigned int) ((REC->dev) >> 20)), ((unsigned int) ((REC->dev) & ((1U << 20) - 1))), (unsigned long long)REC->fileid, REC->fhandle, REC->offset, REC->count, REC->stable, __print_symbolic(REC->stable, { 0, " (UNSTABLE)" }, { 1, " (DATA_SYNC)" }, { NFS_FILE_SYNC, " (FILE_SYNC)" })

Which is a little screwy.


>> Can you try this:
>> 
>> 	trace-cmd record -e nfs_initiate_write
>> 
>> do stuff to trigger the event, then hit Ctrl^C
>> 
>> See if "trace-cmd report" shows it. If not do:
>> 
>> 	trace-cmd report -R
>> 
>> Which will suppress the translation of the output and show you the raw
>> values. That way, you will see what is in the stable field.
> 
> 
> --
> Chuck Lever
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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