Re: [Cluster-devel] [PATCH v3] fs: record task name which froze superblock
On Mon, Mar 2, 2015 at 7:46 AM, Mateusz Guzik mgu...@redhat.com wrote: On Mon, Mar 02, 2015 at 05:38:29AM +0100, Mateusz Guzik wrote: On Sun, Mar 01, 2015 at 08:31:26AM +1100, Dave Chinner wrote: On Sat, Feb 28, 2015 at 05:25:57PM +0300, Alexey Dobriyan wrote: Freezing and thawing are separate system calls, task which is supposed to thaw filesystem/superblock can disappear due to crash or not thaw due to a bug. At least record task name (we can't take task_struct reference) to make support engineer's life easier. Hopefully 16 bytes per superblock isn't much. TASK_COMM_LEN definition (which is userspace ABI, see prctl(PR_SET_NAME)) is moved to userspace exported header to not drag sched.h into every fs.h inclusion. Signed-off-by: Alexey Dobriyan adobri...@gmail.com Freeze/thaw can be nested at the block level. That means the sb-s_writers.freeze_comm can point at the wrong process. i.e. Task A Task B freeze_bdev freeze_super freeze_comm = A freeze_bdev . thaw_bdev device still frozen crash At this point, the block device will never be unthawed, but the debug field is now pointing to the wrong task. i.e. The debug helper has not recorded the process that is actually causing the problem, and leads us all off on a wild goose chase down the wrong path. IMO, debug code is only useful if it's reliable. It can be trivially modified to be very useful to support people. Actually this patch clears saved task name on unfreeze, so in this particular scenario we would end up with no data. Freezer and unfreezer names don't even have to match, so there is not much we can do here (e.g. recording all names in a linked list or something is a non-starter because of this). I propose the following: - on freezing: 1. if 0-1 save the name 2. if 1-2 have a flag to note there is an additional freezer - on unfreezing 1. if 1-0 clear the flag 2. DO NOT clear the name in any case Now that I sent this e-mail I realized we could actually keep a linked list of freezer names. Unfreezing would delete all elements when going 1-0, but would not touch it otherwise. If you do linked list two processes constantly keeping superblock frozen will allocate all the memory: F F T F T ... After all valid objections and comments I think the way to proceed is a) record freeze_comm, never clear it (maybe record thaw_comm) b) record i am not the only one flag c) introduce debug_freeze which will record everything in dmesg for situations when crashdump is not used but serial console is. Alexey
Re: [Cluster-devel] [PATCH v3] fs: record task name which froze superblock
On Mon, Mar 2, 2015 at 7:38 AM, Mateusz Guzik mgu...@redhat.com wrote: As explained below, this one task name is already very useful and likely covers majority of real life use cases. While working in support we were getting a lot of vmcores where hung task detector panicked the kernel because a lot of tasks were blocked in UN state trying to write to frozen filesystems. I presume OP has similar story. Yes, the intended use case is 1 freezer which hopefully covers majority of bug reports. Some back on forth commuication almost always revealed one process e.g. freezing stuff and then blocking itself trying to access it. While we could see it blocked, we had no presumptive evidence to pin freezing on it. A matching name, while still not 100% conclusive, would be ok enough to push the case forward and avoid a rountrip of systemap scripts showing freezer process tree.
Re: [Cluster-devel] [PATCH v3] fs: record task name which froze superblock
On Mon, Mar 02, 2015 at 05:38:29AM +0100, Mateusz Guzik wrote: On Sun, Mar 01, 2015 at 08:31:26AM +1100, Dave Chinner wrote: On Sat, Feb 28, 2015 at 05:25:57PM +0300, Alexey Dobriyan wrote: Freezing and thawing are separate system calls, task which is supposed to thaw filesystem/superblock can disappear due to crash or not thaw due to a bug. At least record task name (we can't take task_struct reference) to make support engineer's life easier. Hopefully 16 bytes per superblock isn't much. TASK_COMM_LEN definition (which is userspace ABI, see prctl(PR_SET_NAME)) is moved to userspace exported header to not drag sched.h into every fs.h inclusion. Signed-off-by: Alexey Dobriyan adobri...@gmail.com Freeze/thaw can be nested at the block level. That means the sb-s_writers.freeze_comm can point at the wrong process. i.e. Task A Task B freeze_bdev freeze_super freeze_comm = A freeze_bdev . thaw_bdev device still frozen crash At this point, the block device will never be unthawed, but the debug field is now pointing to the wrong task. i.e. The debug helper has not recorded the process that is actually causing the problem, and leads us all off on a wild goose chase down the wrong path. IMO, debug code is only useful if it's reliable. It can be trivially modified to be very useful to support people. Actually this patch clears saved task name on unfreeze, so in this particular scenario we would end up with no data. It only clears it i thaw_super(), which is *not called* until the last nested thaw_bdev() call is made. When the system is hung what we actually need to know is who is responsible for *thawing* the filesystem and then we can work out why that hasn't run. What this code tries to do is identify who froze the filesystem and so indicate who *might* be responsible for thawing it. If we mis-identify the agent who holds the freeze status, then we fail to identify who needs to run the thaw and hence we're still stuck not knowing WTF happened I understand why you want to record this - I'm not arguing that we shouldn't do this. My point is that we should *make it reliable* and not in any way ambiguous, otherwise we failed to solve the problem it was intended for. Cheers, Dave. -- Dave Chinner da...@fromorbit.com
Re: [Cluster-devel] [PATCH v3] fs: record task name which froze superblock
On Sun, Mar 01, 2015 at 08:31:26AM +1100, Dave Chinner wrote: On Sat, Feb 28, 2015 at 05:25:57PM +0300, Alexey Dobriyan wrote: Freezing and thawing are separate system calls, task which is supposed to thaw filesystem/superblock can disappear due to crash or not thaw due to a bug. At least record task name (we can't take task_struct reference) to make support engineer's life easier. Hopefully 16 bytes per superblock isn't much. TASK_COMM_LEN definition (which is userspace ABI, see prctl(PR_SET_NAME)) is moved to userspace exported header to not drag sched.h into every fs.h inclusion. Signed-off-by: Alexey Dobriyan adobri...@gmail.com Freeze/thaw can be nested at the block level. That means the sb-s_writers.freeze_comm can point at the wrong process. i.e. Task ATask B freeze_bdev freeze_super freeze_comm = A freeze_bdev . thaw_bdev device still frozen crash At this point, the block device will never be unthawed, but the debug field is now pointing to the wrong task. i.e. The debug helper has not recorded the process that is actually causing the problem, and leads us all off on a wild goose chase down the wrong path. IMO, debug code is only useful if it's reliable. It can be trivially modified to be very useful to support people. Actually this patch clears saved task name on unfreeze, so in this particular scenario we would end up with no data. Freezer and unfreezer names don't even have to match, so there is not much we can do here (e.g. recording all names in a linked list or something is a non-starter because of this). I propose the following: - on freezing: 1. if 0-1 save the name 2. if 1-2 have a flag to note there is an additional freezer - on unfreezing 1. if 1-0 clear the flag 2. DO NOT clear the name in any case This way we keep the name for possible future reference and we know whether something with this name was the sole freezer in this cycle. As explained below, this one task name is already very useful and likely covers majority of real life use cases. While working in support we were getting a lot of vmcores where hung task detector panicked the kernel because a lot of tasks were blocked in UN state trying to write to frozen filesystems. I presume OP has similar story. Some back on forth commuication almost always revealed one process e.g. freezing stuff and then blocking itself trying to access it. While we could see it blocked, we had no presumptive evidence to pin freezing on it. A matching name, while still not 100% conclusive, would be ok enough to push the case forward and avoid a rountrip of systemap scripts showing freezer process tree. -- Mateusz Guzik
Re: [Cluster-devel] [PATCH v3] fs: record task name which froze superblock
On Mon, Mar 02, 2015 at 05:38:29AM +0100, Mateusz Guzik wrote: On Sun, Mar 01, 2015 at 08:31:26AM +1100, Dave Chinner wrote: On Sat, Feb 28, 2015 at 05:25:57PM +0300, Alexey Dobriyan wrote: Freezing and thawing are separate system calls, task which is supposed to thaw filesystem/superblock can disappear due to crash or not thaw due to a bug. At least record task name (we can't take task_struct reference) to make support engineer's life easier. Hopefully 16 bytes per superblock isn't much. TASK_COMM_LEN definition (which is userspace ABI, see prctl(PR_SET_NAME)) is moved to userspace exported header to not drag sched.h into every fs.h inclusion. Signed-off-by: Alexey Dobriyan adobri...@gmail.com Freeze/thaw can be nested at the block level. That means the sb-s_writers.freeze_comm can point at the wrong process. i.e. Task A Task B freeze_bdev freeze_super freeze_comm = A freeze_bdev . thaw_bdev device still frozen crash At this point, the block device will never be unthawed, but the debug field is now pointing to the wrong task. i.e. The debug helper has not recorded the process that is actually causing the problem, and leads us all off on a wild goose chase down the wrong path. IMO, debug code is only useful if it's reliable. It can be trivially modified to be very useful to support people. Actually this patch clears saved task name on unfreeze, so in this particular scenario we would end up with no data. Freezer and unfreezer names don't even have to match, so there is not much we can do here (e.g. recording all names in a linked list or something is a non-starter because of this). I propose the following: - on freezing: 1. if 0-1 save the name 2. if 1-2 have a flag to note there is an additional freezer - on unfreezing 1. if 1-0 clear the flag 2. DO NOT clear the name in any case Now that I sent this e-mail I realized we could actually keep a linked list of freezer names. Unfreezing would delete all elements when going 1-0, but would not touch it otherwise. This would cover a less likely use case though, so I would be fine either way FWIW. Just my $0,03. This way we keep the name for possible future reference and we know whether something with this name was the sole freezer in this cycle. As explained below, this one task name is already very useful and likely covers majority of real life use cases. While working in support we were getting a lot of vmcores where hung task detector panicked the kernel because a lot of tasks were blocked in UN state trying to write to frozen filesystems. I presume OP has similar story. Some back on forth commuication almost always revealed one process e.g. freezing stuff and then blocking itself trying to access it. While we could see it blocked, we had no presumptive evidence to pin freezing on it. A matching name, while still not 100% conclusive, would be ok enough to push the case forward and avoid a rountrip of systemap scripts showing freezer process tree. -- Mateusz Guzik
Re: [Cluster-devel] [PATCH v3] fs: record task name which froze superblock
On Sat, Feb 28, 2015 at 05:25:57PM +0300, Alexey Dobriyan wrote: Freezing and thawing are separate system calls, task which is supposed to thaw filesystem/superblock can disappear due to crash or not thaw due to a bug. At least record task name (we can't take task_struct reference) to make support engineer's life easier. Hopefully 16 bytes per superblock isn't much. TASK_COMM_LEN definition (which is userspace ABI, see prctl(PR_SET_NAME)) is moved to userspace exported header to not drag sched.h into every fs.h inclusion. Signed-off-by: Alexey Dobriyan adobri...@gmail.com Freeze/thaw can be nested at the block level. That means the sb-s_writers.freeze_comm can point at the wrong process. i.e. Task A Task B freeze_bdev freeze_super freeze_comm = A freeze_bdev . thaw_bdev device still frozen crash At this point, the block device will never be unthawed, but the debug field is now pointing to the wrong task. i.e. The debug helper has not recorded the process that is actually causing the problem, and leads us all off on a wild goose chase down the wrong path. IMO, debug code is only useful if it's reliable. --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -303,9 +303,6 @@ extern char ___assert_task_state[1 - 2*!!( #endif -/* Task command name length */ -#define TASK_COMM_LEN 16 - #include linux/spinlock.h /* --- a/include/uapi/linux/sched.h +++ b/include/uapi/linux/sched.h @@ -49,4 +49,7 @@ */ #define SCHED_FLAG_RESET_ON_FORK 0x01 +/* Task command name length */ +#define TASK_COMM_LEN 16 + #endif /* _UAPI_LINUX_SCHED_H */ That should be a separate patch, sent to the scheduler maintainers for review. AFAICT, it isn't part of the user API - it's not defined in the man page which just says can be up to 16 bytes. Cheers, Dave. -- Dave Chinner da...@fromorbit.com