https://github.com/torvalds/linux
Revision 7b2b55da1db10a5525460633ae4b6fb0be060c41 authored by Jason Xing on 25 August 2019, 00:54:53 UTC, committed by Linus Torvalds on 25 August 2019, 02:48:42 UTC
Only when calling the poll syscall the first time can user receive POLLPRI correctly. After that, user always fails to acquire the event signal. Reproduce case: 1. Get the monitor code in Documentation/accounting/psi.txt 2. Run it, and wait for the event triggered. 3. Kill and restart the process. The question is why we can end up with poll_scheduled = 1 but the work not running (which would reset it to 0). And the answer is because the scheduling side sees group->poll_kworker under RCU protection and then schedules it, but here we cancel the work and destroy the worker. The cancel needs to pair with resetting the poll_scheduled flag. Link: http://lkml.kernel.org/r/1566357985-97781-1-git-send-email-joseph.qi@linux.alibaba.com Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com> Reviewed-by: Caspar Zhang <caspar@linux.alibaba.com> Reviewed-by: Suren Baghdasaryan <surenb@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bb65f89
Tip revision: 7b2b55da1db10a5525460633ae4b6fb0be060c41 authored by Jason Xing on 25 August 2019, 00:54:53 UTC
psi: get poll_work to run when calling poll syscall next time
psi: get poll_work to run when calling poll syscall next time
Tip revision: 7b2b55d
fs_types.c
// SPDX-License-Identifier: GPL-2.0
#include <linux/fs.h>
#include <linux/export.h>
/*
* fs on-disk file type to dirent file type conversion
*/
static const unsigned char fs_dtype_by_ftype[FT_MAX] = {
[FT_UNKNOWN] = DT_UNKNOWN,
[FT_REG_FILE] = DT_REG,
[FT_DIR] = DT_DIR,
[FT_CHRDEV] = DT_CHR,
[FT_BLKDEV] = DT_BLK,
[FT_FIFO] = DT_FIFO,
[FT_SOCK] = DT_SOCK,
[FT_SYMLINK] = DT_LNK
};
/**
* fs_ftype_to_dtype() - fs on-disk file type to dirent type.
* @filetype: The on-disk file type to convert.
*
* This function converts the on-disk file type value (FT_*) to the directory
* entry type (DT_*).
*
* Context: Any context.
* Return:
* * DT_UNKNOWN - Unknown type
* * DT_FIFO - FIFO
* * DT_CHR - Character device
* * DT_DIR - Directory
* * DT_BLK - Block device
* * DT_REG - Regular file
* * DT_LNK - Symbolic link
* * DT_SOCK - Local-domain socket
*/
unsigned char fs_ftype_to_dtype(unsigned int filetype)
{
if (filetype >= FT_MAX)
return DT_UNKNOWN;
return fs_dtype_by_ftype[filetype];
}
EXPORT_SYMBOL_GPL(fs_ftype_to_dtype);
/*
* dirent file type to fs on-disk file type conversion
* Values not initialized explicitly are FT_UNKNOWN (0).
*/
static const unsigned char fs_ftype_by_dtype[DT_MAX] = {
[DT_REG] = FT_REG_FILE,
[DT_DIR] = FT_DIR,
[DT_LNK] = FT_SYMLINK,
[DT_CHR] = FT_CHRDEV,
[DT_BLK] = FT_BLKDEV,
[DT_FIFO] = FT_FIFO,
[DT_SOCK] = FT_SOCK,
};
/**
* fs_umode_to_ftype() - file mode to on-disk file type.
* @mode: The file mode to convert.
*
* This function converts the file mode value to the on-disk file type (FT_*).
*
* Context: Any context.
* Return:
* * FT_UNKNOWN - Unknown type
* * FT_REG_FILE - Regular file
* * FT_DIR - Directory
* * FT_CHRDEV - Character device
* * FT_BLKDEV - Block device
* * FT_FIFO - FIFO
* * FT_SOCK - Local-domain socket
* * FT_SYMLINK - Symbolic link
*/
unsigned char fs_umode_to_ftype(umode_t mode)
{
return fs_ftype_by_dtype[S_DT(mode)];
}
EXPORT_SYMBOL_GPL(fs_umode_to_ftype);
/**
* fs_umode_to_dtype() - file mode to dirent file type.
* @mode: The file mode to convert.
*
* This function converts the file mode value to the directory
* entry type (DT_*).
*
* Context: Any context.
* Return:
* * DT_UNKNOWN - Unknown type
* * DT_FIFO - FIFO
* * DT_CHR - Character device
* * DT_DIR - Directory
* * DT_BLK - Block device
* * DT_REG - Regular file
* * DT_LNK - Symbolic link
* * DT_SOCK - Local-domain socket
*/
unsigned char fs_umode_to_dtype(umode_t mode)
{
return fs_ftype_to_dtype(fs_umode_to_ftype(mode));
}
EXPORT_SYMBOL_GPL(fs_umode_to_dtype);
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...