30 Aug, 2018

1 commit

  • Some architectures need to use stop_machine() to patch functions for
    ftrace, and the assumption is that the stopped CPUs do not make function
    calls to traceable functions when they are in the stopped state.

    Commit ce4f06dcbb5d ("stop_machine: Touch_nmi_watchdog() after
    MULTI_STOP_PREPARE") added calls to the watchdog touch functions from
    the stopped CPUs and those functions lack notrace annotations. This
    leads to crashes when enabling/disabling ftrace on ARM kernels built
    with the Thumb-2 instruction set.

    Fix it by adding the necessary notrace annotations.

    Fixes: ce4f06dcbb5d ("stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE")
    Signed-off-by: Vincent Whitchurch
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: oleg@redhat.com
    Cc: tj@kernel.org
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20180821152507.18313-1-vincent.whitchurch@axis.com

    Vincent Whitchurch
     

25 Aug, 2018

1 commit


22 Aug, 2018

2 commits

  • In flush_work(), we need to create a lockdep dependency so that
    the following scenario is appropriately tagged as a problem:

    work_function()
    {
    mutex_lock(&mutex);
    ...
    }

    other_function()
    {
    mutex_lock(&mutex);
    flush_work(&work); // or cancel_work_sync(&work);
    }

    This is a problem since the work might be running and be blocked
    on trying to acquire the mutex.

    Similarly, in flush_workqueue().

    These were removed after cross-release partially caught these
    problems, but now cross-release was reverted anyway. IMHO the
    removal was erroneous anyway though, since lockdep should be
    able to catch potential problems, not just actual ones, and
    cross-release would only have caught the problem when actually
    invoking wait_for_completion().

    Fixes: fd1a5b04dfb8 ("workqueue: Remove now redundant lock acquisitions wrt. workqueue flushes")
    Signed-off-by: Johannes Berg
    Signed-off-by: Tejun Heo

    Johannes Berg
     
  • In cancel_work_sync(), we can only have one of two cases, even
    with an ordered workqueue:
    * the work isn't running, just cancelled before it started
    * the work is running, but then nothing else can be on the
    workqueue before it

    Thus, we need to skip the lockdep workqueue dependency handling,
    otherwise we get false positive reports from lockdep saying that
    we have a potential deadlock when the workqueue also has other
    work items with locking, e.g.

    work1_function() { mutex_lock(&mutex); ... }
    work2_function() { /* nothing */ }

    other_function() {
    queue_work(ordered_wq, &work1);
    queue_work(ordered_wq, &work2);
    mutex_lock(&mutex);
    cancel_work_sync(&work2);
    }

    As described above, this isn't a problem, but lockdep will
    currently flag it as if cancel_work_sync() was flush_work(),
    which *is* a problem.

    Signed-off-by: Johannes Berg
    Signed-off-by: Tejun Heo

    Johannes Berg
     

13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

11 Jun, 2018

1 commit

  • Pull SCSI updates from James Bottomley:
    "This is mostly updates to the usual drivers: ufs, qedf, mpt3sas, lpfc,
    xfcp, hisi_sas, cxlflash, qla2xxx.

    In the absence of Nic, we're also taking target updates which are
    mostly minor except for the tcmu refactor.

    The only real core change to worry about is the removal of high page
    bouncing (in sas, storvsc and iscsi). This has been well tested and no
    problems have shown up so far"

    * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (268 commits)
    scsi: lpfc: update driver version to 12.0.0.4
    scsi: lpfc: Fix port initialization failure.
    scsi: lpfc: Fix 16gb hbas failing cq create.
    scsi: lpfc: Fix crash in blk_mq layer when executing modprobe -r lpfc
    scsi: lpfc: correct oversubscription of nvme io requests for an adapter
    scsi: lpfc: Fix MDS diagnostics failure (Rx < Tx)
    scsi: hisi_sas: Mark PHY as in reset for nexus reset
    scsi: hisi_sas: Fix return value when get_free_slot() failed
    scsi: hisi_sas: Terminate STP reject quickly for v2 hw
    scsi: hisi_sas: Add v2 hw force PHY function for internal ATA command
    scsi: hisi_sas: Include TMF elements in struct hisi_sas_slot
    scsi: hisi_sas: Try wait commands before before controller reset
    scsi: hisi_sas: Init disks after controller reset
    scsi: hisi_sas: Create a scsi_host_template per HW module
    scsi: hisi_sas: Reset disks when discovered
    scsi: hisi_sas: Add LED feature for v3 hw
    scsi: hisi_sas: Change common allocation mode of device id
    scsi: hisi_sas: change slot index allocation mode
    scsi: hisi_sas: Introduce hisi_sas_phy_set_linkrate()
    scsi: hisi_sas: fix a typo in hisi_sas_task_prep()
    ...

    Linus Torvalds
     

07 Jun, 2018

2 commits

  • Pull overflow updates from Kees Cook:
    "This adds the new overflow checking helpers and adds them to the
    2-factor argument allocators. And this adds the saturating size
    helpers and does a treewide replacement for the struct_size() usage.
    Additionally this adds the overflow testing modules to make sure
    everything works.

    I'm still working on the treewide replacements for allocators with
    "simple" multiplied arguments:

    *alloc(a * b, ...) -> *alloc_array(a, b, ...)

    and

    *zalloc(a * b, ...) -> *calloc(a, b, ...)

    as well as the more complex cases, but that's separable from this
    portion of the series. I expect to have the rest sent before -rc1
    closes; there are a lot of messy cases to clean up.

    Summary:

    - Introduce arithmetic overflow test helper functions (Rasmus)

    - Use overflow helpers in 2-factor allocators (Kees, Rasmus)

    - Introduce overflow test module (Rasmus, Kees)

    - Introduce saturating size helper functions (Matthew, Kees)

    - Treewide use of struct_size() for allocators (Kees)"

    * tag 'overflow-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
    treewide: Use struct_size() for devm_kmalloc() and friends
    treewide: Use struct_size() for vmalloc()-family
    treewide: Use struct_size() for kmalloc()-family
    device: Use overflow helpers for devm_kmalloc()
    mm: Use overflow helpers in kvmalloc()
    mm: Use overflow helpers in kmalloc_array*()
    test_overflow: Add memory allocation overflow tests
    overflow.h: Add allocation size calculation helpers
    test_overflow: Report test failures
    test_overflow: macrofy some more, do more tests for free
    lib: add runtime test of check_*_overflow functions
    compiler.h: enable builtin overflow checkers and add fallback code

    Linus Torvalds
     
  • One of the more common cases of allocation size calculations is finding
    the size of a structure that has a zero-sized array at the end, along
    with memory for some number of elements for that array. For example:

    struct foo {
    int stuff;
    void *entry[];
    };

    instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);

    Instead of leaving these open-coded and prone to type mistakes, we can
    now use the new struct_size() helper:

    instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);

    This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
    uses. It was done via automatic conversion with manual review for the
    "CHECKME" non-standard cases noted below, using the following Coccinelle
    script:

    // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
    // sizeof *pkey_cache->table, GFP_KERNEL);
    @@
    identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
    expression GFP;
    identifier VAR, ELEMENT;
    expression COUNT;
    @@

    - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
    + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)

    // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
    @@
    identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
    expression GFP;
    identifier VAR, ELEMENT;
    expression COUNT;
    @@

    - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
    + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)

    // Same pattern, but can't trivially locate the trailing element name,
    // or variable name.
    @@
    identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
    expression GFP;
    expression SOMETHING, COUNT, ELEMENT;
    @@

    - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
    + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)

    Signed-off-by: Kees Cook

    Kees Cook
     

24 May, 2018

1 commit

  • In commit 7ee681b25284 ("workqueue: Convert to state machine callbacks"),
    three new function definitions were added: ‘workqueue_prepare_cpu’,
    ‘workqueue_online_cpu’ and ‘workqueue_offline_cpu’.

    Move these function definitions within a CONFIG_SMP block since they are
    not used outside of it. This will match function declarations in header
    , and silence the following gcc warning (W=1):

    kernel/workqueue.c:4743:5: warning: no previous prototype for ‘workqueue_prepare_cpu’ [-Wmissing-prototypes]
    kernel/workqueue.c:4756:5: warning: no previous prototype for ‘workqueue_online_cpu’ [-Wmissing-prototypes]
    kernel/workqueue.c:4783:5: warning: no previous prototype for ‘workqueue_offline_cpu’ [-Wmissing-prototypes]

    Signed-off-by: Mathieu Malaterre
    Signed-off-by: Tejun Heo

    Mathieu Malaterre
     

21 May, 2018

1 commit

  • The worker struct could already be freed when wq_worker_comm() tries
    to access it for reporting. This patch protects PF_WQ_WORKER
    modifications with wq_pool_attach_mutex and makes wq_worker_comm()
    test the flag before dereferencing worker from kthread_data(), which
    ensures that it only dereferences when the worker struct is valid.

    Signed-off-by: Tejun Heo
    Reported-by: Lai Jiangshan
    Fixes: 6b59808bfe48 ("workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status}")

    Tejun Heo
     

18 May, 2018

5 commits

  • There can be a lot of workqueue workers and they all show up with the
    cryptic kworker/* names making it difficult to understand which is
    doing what and how they came to be.

    # ps -ef | grep kworker
    root 4 2 0 Feb25 ? 00:00:00 [kworker/0:0H]
    root 6 2 0 Feb25 ? 00:00:00 [kworker/u112:0]
    root 19 2 0 Feb25 ? 00:00:00 [kworker/1:0H]
    root 25 2 0 Feb25 ? 00:00:00 [kworker/2:0H]
    root 31 2 0 Feb25 ? 00:00:00 [kworker/3:0H]
    ...

    This patch makes workqueue workers report the latest workqueue it was
    executing for through /proc/PID/{comm,stat,status}. The extra
    information is appended to the kthread name with intervening '+' if
    currently executing, otherwise '-'.

    # cat /proc/25/comm
    kworker/2:0-events_power_efficient
    # cat /proc/25/stat
    25 (kworker/2:0-events_power_efficient) I 2 0 0 0 -1 69238880 0 0...
    # grep Name /proc/25/status
    Name: kworker/2:0-events_power_efficient

    Unfortunately, ps(1) truncates comm to 15 characters,

    # ps 25
    PID TTY STAT TIME COMMAND
    25 ? I 0:00 [kworker/2:0-eve]

    making it a lot less useful; however, this should be an easy fix from
    ps(1) side.

    Signed-off-by: Tejun Heo
    Suggested-by: Linus Torvalds
    Cc: Craig Small

    Tejun Heo
     
  • Work functions can use set_worker_desc() to improve the visibility of
    what the worker task is doing. Currently, the desc field is unset at
    the beginning of each execution and there is a separate field to track
    the field is set during the current execution.

    Instead of leaving empty till desc is set, worker->desc can be used to
    remember the last workqueue the worker worked on by default and users
    that use set_worker_desc() can override it to something more
    informative as necessary.

    This simplifies desc handling and helps tracking the last workqueue
    that the worker exected on to improve visibility.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • For historical reasons, the worker attach/detach functions don't
    currently manage worker->pool and the callers are manually and
    inconsistently updating it.

    This patch moves worker->pool updates into the worker attach/detach
    functions. This makes worker->pool consistent and clearly defines how
    worker->pool updates are synchronized.

    This will help later workqueue visibility improvements by allowing
    safe access to workqueue information from worker->task.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • To improve workqueue visibility, we want to be able to access
    workqueue information from worker tasks. The per-pool attach mutex
    makes that difficult because there's no way of stabilizing task ->
    worker pool association without knowing the pool first.

    Worker attach/detach is a slow path and there's no need for different
    pools to be able to perform them concurrently. This patch replaces
    the per-pool attach_mutex with global wq_pool_attach_mutex to prepare
    for visibility improvement changes.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • As a prerequisite, complement commit 3d1cb2059d93 ("workqueue: include
    workqueue info when printing debug dump of a worker task") to be usable with
    kernel modules by exporting the symbol set_worker_desc(). Current built-in
    user was introduced with commit ef3b101925f2 ("writeback: set worker desc to
    identify writeback workers in task dumps").

    Can help distinguishing work items which do not have adapter scope.
    Description is printed out with task dump for debugging on WARN, BUG, panic,
    or magic-sysrq [show-task-states(t)].

    Example:
    $ echo 0 >| /sys/bus/ccw/drivers/zfcp/0.0.1880/0x50050763031bd327/failed &
    $ echo 't' >| /proc/sysrq-trigger
    $ dmesg
    sysrq: SysRq : Show State
    task PC stack pid father
    ...
    zfcp_q_0.0.1880 S14640 2165 2 0x02000000
    Call Trace:
    ([] __schedule+0xbf4/0xc78)
    [] schedule+0x94/0xc0
    [] rescuer_thread+0x33c/0x3a0
    [] kthread+0x166/0x178
    [] kernel_thread_starter+0x6/0xc
    [] kernel_thread_starter+0x0/0xc
    no locks held by zfcp_q_0.0.1880/2165.
    ...
    kworker/u512:2 D11280 2193 2 0x02000000
    Workqueue: zfcp_q_0.0.1880 zfcp_scsi_rport_work [zfcp] (zrpd-50050763031bd327)
    ^^^^^^^^^^^^^^^^^^^^^
    Call Trace:
    ([] __schedule+0xbf4/0xc78)
    [] schedule+0x94/0xc0
    [] schedule_timeout+0x488/0x4d0
    [] msleep+0x5c/0x78 >>test code only<<
    [] zfcp_scsi_rport_work+0xbe/0x100 [zfcp]
    [] process_one_work+0x3b4/0x718
    [] worker_thread+0x264/0x408
    [] kthread+0x166/0x178
    [] kernel_thread_starter+0x6/0xc
    [] kernel_thread_starter+0x0/0xc
    2 locks held by kworker/u512:2/2193:
    #0: (name){++++.+}, at: [] process_one_work+0x1ae/0x718
    #1: ((&(&port->rport_work)->work)){+.+.+.}, at: [] process_one_work+0x1ae/0x718
    ...

    =============================================
    Showing busy workqueues and worker pools:
    workqueue zfcp_q_0.0.1880: flags=0x2000a
    pwq 512: cpus=0-255 flags=0x4 nice=0 active=1/1
    in-flight: 2193:zfcp_scsi_rport_work [zfcp]
    pool 512: cpus=0-255 flags=0x4 nice=0 hung=0s workers=4 idle: 5 2354 2311

    Work items with adapter scope are already identified by the workqueue name
    "zfcp_q_" and the work item function name.

    Signed-off-by: Steffen Maier
    Cc: Tejun Heo
    Cc: Lai Jiangshan
    Reviewed-by: Benjamin Block
    Acked-by: Tejun Heo
    Signed-off-by: Martin K. Petersen

    Steffen Maier
     

04 Apr, 2018

1 commit

  • Pull workqueue updates from Tejun Heo:
    "rcu_work addition and a couple trivial changes"

    * 'for-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
    workqueue: remove the comment about the old manager_arb mutex
    workqueue: fix the comments of nr_idle
    fs/aio: Use rcu_work instead of explicit rcu and work item
    cgroup: Use rcu_work instead of explicit rcu and work item
    RCU, workqueue: Implement rcu_work

    Linus Torvalds
     

21 Mar, 2018

2 commits


20 Mar, 2018

2 commits

  • Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • There are cases where RCU callback needs to be bounced to a sleepable
    context. This is currently done by the RCU callback queueing a work
    item, which can be cumbersome to write and confusing to read.

    This patch introduces rcu_work, a workqueue work variant which gets
    executed after a RCU grace period, and converts the open coded
    bouncing in fs/aio and kernel/cgroup.

    v3: Dropped queue_rcu_work_on(). Documented rcu grace period behavior
    after queue_rcu_work().

    v2: Use rcu_barrier() instead of synchronize_rcu() to wait for
    completion of previously queued rcu callback as per Paul.

    Signed-off-by: Tejun Heo
    Acked-by: "Paul E. McKenney"
    Cc: Linus Torvalds

    Tejun Heo
     

14 Mar, 2018

2 commits


09 Mar, 2018

1 commit


22 Feb, 2018

1 commit

  • Fixes for 4.16. I contains fixes for deadlock on runtime suspend on few
    drivers, a memory leak on non-blocking commits, a crash on color-eviction.
    The is also meson and edid fixes, plus a fix for a doc warning.

    * tag 'drm-misc-fixes-2018-02-21' of git://anongit.freedesktop.org/drm/drm-misc:
    drm/tve200: fix kernel-doc documentation comment include
    drm/meson: fix vsync buffer update
    drm: Handle unexpected holes in color-eviction
    drm/edid: Add 6 bpc quirk for CPT panel in Asus UX303LA
    drm/amdgpu: Fix deadlock on runtime suspend
    drm/radeon: Fix deadlock on runtime suspend
    drm/nouveau: Fix deadlock on runtime suspend
    drm: Allow determining if current task is output poll worker
    workqueue: Allow retrieval of current task's work struct
    drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits

    Dave Airlie
     

21 Feb, 2018

1 commit

  • As we prepare for offloading the residual 1hz scheduler ticks to
    workqueue, let's affine those to housekeepers so that they don't
    interrupt the CPUs that don't want to be disturbed.

    Signed-off-by: Frederic Weisbecker
    Reviewed-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Cc: Chris Metcalf
    Cc: Christoph Lameter
    Cc: Linus Torvalds
    Cc: Luiz Capitulino
    Cc: Mike Galbraith
    Cc: Paul E. McKenney
    Cc: Rik van Riel
    Cc: Wanpeng Li
    Link: http://lkml.kernel.org/r/1519186649-3242-5-git-send-email-frederic@kernel.org
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

17 Feb, 2018

1 commit

  • Introduce a helper to retrieve the current task's work struct if it is
    a workqueue worker.

    This allows us to fix a long-standing deadlock in several DRM drivers
    wherein the ->runtime_suspend callback waits for a specific worker to
    finish and that worker in turn calls a function which waits for runtime
    suspend to finish. That function is invoked from multiple call sites
    and waiting for runtime suspend to finish is the correct thing to do
    except if it's executing in the context of the worker.

    Cc: Lai Jiangshan
    Cc: Dave Airlie
    Cc: Ben Skeggs
    Cc: Alex Deucher
    Acked-by: Tejun Heo
    Reviewed-by: Lyude Paul
    Signed-off-by: Lukas Wunner
    Link: https://patchwork.freedesktop.org/patch/msgid/2d8f603074131eb87e588d2b803a71765bd3a2fd.1518338788.git.lukas@wunner.de

    Lukas Wunner
     

02 Feb, 2018

1 commit

  • Pull staging/IIO updates from Greg KH:
    "Here is the big Staging and IIO driver patches for 4.16-rc1.

    There is the normal amount of new IIO drivers added, like all
    releases.

    The networking IPX and the ncpfs filesystem are moved into the staging
    tree, as they are on their way out of the kernel due to lack of use
    anymore.

    The visorbus subsystem finall has started moving out of the staging
    tree to the "real" part of the kernel, and the most and fsl-mc
    codebases are almost ready to move out, that will probably happen for
    4.17-rc1 if all goes well.

    Other than that, there is a bunch of license header cleanups in the
    tree, along with the normal amount of coding style churn that we all
    know and love for this codebase. I also got frustrated at the
    Meltdown/Spectre mess and took it out on the dgnc tty driver, deleting
    huge chunks of it that were never even being used.

    Full details of everything is in the shortlog.

    All of these patches have been in linux-next for a while with no
    reported issues"

    * tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (627 commits)
    staging: rtlwifi: remove redundant initialization of 'cfg_cmd'
    staging: rtl8723bs: remove a couple of redundant initializations
    staging: comedi: reformat lines to 80 chars or less
    staging: lustre: separate a connection destroy from free struct kib_conn
    Staging: rtl8723bs: Use !x instead of NULL comparison
    Staging: rtl8723bs: Remove dead code
    Staging: rtl8723bs: Change names to conform to the kernel code
    staging: ccree: Fix missing blank line after declaration
    staging: rtl8188eu: remove redundant initialization of 'pwrcfgcmd'
    staging: rtlwifi: remove unused RTLHALMAC_ST and RTLPHYDM_ST
    staging: fbtft: remove unused FB_TFT_SSD1325 kconfig
    staging: comedi: dt2811: remove redundant initialization of 'ns'
    staging: wilc1000: fix alignments to match open parenthesis
    staging: wilc1000: removed unnecessary defined enums typedef
    staging: wilc1000: remove unnecessary use of parentheses
    staging: rtl8192u: remove redundant initialization of 'timeout'
    staging: sm750fb: fix CamelCase for dispSet var
    staging: lustre: lnet/selftest: fix compile error on UP build
    staging: rtl8723bs: hal_com_phycfg: Remove unneeded semicolons
    staging: rts5208: Fix "seg_no" calculation in reset_ms_card()
    ...

    Linus Torvalds
     

31 Jan, 2018

2 commits

  • Pull workqueue updates from Tejun Heo:
    "Workqueue has an early init trick where workqueues can be created and
    work items queued on them before the workqueue subsystem is online.
    This helps simplifying early init and operation of low level
    subsystems which use workqueues for managerial things which aren't
    depended upon early during boot.

    Out of laziness, the early init didn't cover workqueues with
    WQ_MEM_RECLAIM, which is inconsistent and confusing because adding the
    flag simply makes the system fail to boot. Cover WQ_MEM_RECLAIM too.

    This was originally brought up for RCU but RCU didn't actually need
    this. I still think it's a good idea to cover it"

    * 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
    workqueue: allow WQ_MEM_RECLAIM on early init workqueues
    workqueue: separate out init_rescuer()

    Linus Torvalds
     
  • Pull RCU updates from Ingo Molnar:
    "The main RCU changes in this cycle were:

    - Updates to use cond_resched() instead of cond_resched_rcu_qs()
    where feasible (currently everywhere except in kernel/rcu and in
    kernel/torture.c). Also a couple of fixes to avoid sending IPIs to
    offline CPUs.

    - Updates to simplify RCU's dyntick-idle handling.

    - Updates to remove almost all uses of smp_read_barrier_depends() and
    read_barrier_depends().

    - Torture-test updates.

    - Miscellaneous fixes"

    * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (72 commits)
    torture: Save a line in stutter_wait(): while -> for
    torture: Eliminate torture_runnable and perf_runnable
    torture: Make stutter less vulnerable to compilers and races
    locking/locktorture: Fix num reader/writer corner cases
    locking/locktorture: Fix rwsem reader_delay
    torture: Place all torture-test modules in one MAINTAINERS group
    rcutorture/kvm-build.sh: Skip build directory check
    rcutorture: Simplify functions.sh include path
    rcutorture: Simplify logging
    rcutorture/kvm-recheck-*: Improve result directory readability check
    rcutorture/kvm.sh: Support execution from any directory
    rcutorture/kvm.sh: Use consistent help text for --qemu-args
    rcutorture/kvm.sh: Remove unused variable, `alldone`
    rcutorture: Remove unused script, config2frag.sh
    rcutorture/configinit: Fix build directory error message
    rcutorture: Preempt RCU-preempt readers more vigorously
    torture: Reduce #ifdefs for preempt_schedule()
    rcu: Remove have_rcu_nocb_mask from tree_plugin.h
    rcu: Add comment giving debug strategy for double call_rcu()
    tracing, rcu: Hide trace event rcu_nocb_wake when not used
    ...

    Linus Torvalds
     

15 Jan, 2018

1 commit

  • Instead of the cfs workitem library, use workqueues.

    As lnet wants to provide a cpu mask of allowed cpus, it
    needs to be a WQ_UNBOUND work queue so that tasks can
    run on cpus other than where they were submitted.

    This patch also exported apply_workqueue_attrs() which is
    a documented part of the workqueue API, that isn't currently
    exported. lustre needs it to allow workqueue thread to be limited
    to a subset of CPUs.

    Acked-by: Tejun Heo (for export of apply_workqueue_attrs)
    Signed-off-by: NeilBrown
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     

13 Jan, 2018

1 commit


08 Jan, 2018

2 commits

  • Workqueues can be created early during boot before workqueue subsystem
    in fully online - work items are queued waiting for later full
    initialization. However, early init wasn't supported for
    WQ_MEM_RECLAIM workqueues causing unnecessary annoyances for a subset
    of users. Expand early init support to include WQ_MEM_RECLAIM
    workqueues.

    Signed-off-by: Tejun Heo
    Cc: Paul McKenney

    Tejun Heo
     
  • Separate out init_rescuer() from __alloc_workqueue_key() to prepare
    for early init support for WQ_MEM_RECLAIM. This patch doesn't
    introduce any functional changes.

    Signed-off-by: Tejun Heo
    Cc: Paul McKenney

    Tejun Heo
     

03 Jan, 2018

1 commit

  • …k/linux-rcu into core/rcu

    Pull RCU updates from Paul E. McKenney:

    - Updates to use cond_resched() instead of cond_resched_rcu_qs()
    where feasible (currently everywhere except in kernel/rcu and
    in kernel/torture.c). Also a couple of fixes to avoid sending
    IPIs to offline CPUs.

    - Updates to simplify RCU's dyntick-idle handling.

    - Updates to remove almost all uses of smp_read_barrier_depends()
    and read_barrier_depends().

    - Miscellaneous fixes.

    - Torture-test updates.

    Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Ingo Molnar
     

11 Dec, 2017

1 commit


05 Dec, 2017

3 commits


28 Nov, 2017

1 commit


22 Nov, 2017

1 commit

  • With all callbacks converted, and the timer callback prototype
    switched over, the TIMER_FUNC_TYPE cast is no longer needed,
    so remove it. Conversion was done with the following scripts:

    perl -pi -e 's|\(TIMER_FUNC_TYPE\)||g' \
    $(git grep TIMER_FUNC_TYPE | cut -d: -f1 | sort -u)

    perl -pi -e 's|\(TIMER_DATA_TYPE\)||g' \
    $(git grep TIMER_DATA_TYPE | cut -d: -f1 | sort -u)

    The now unused macros are also dropped from include/linux/timer.h.

    Signed-off-by: Kees Cook

    Kees Cook