Received: by 10.223.176.46 with SMTP id f43csp847081wra; Fri, 19 Jan 2018 02:59:52 -0800 (PST) X-Google-Smtp-Source: ACJfBovQw+9tRzcByp3HkbwvI8kyoqHKwNJ3e4IGHdiAeb8Qy5SScbInEPRNrHrGMa7LI2Ke35WJ X-Received: by 10.101.100.144 with SMTP id e16mr39214930pgv.26.1516359592032; Fri, 19 Jan 2018 02:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516359591; cv=none; d=google.com; s=arc-20160816; b=U5p/N/ishbI8zAfYLwBgBn0kn1/QU93bFqo9rR1FSIU9CXFuE7HbJ6jc8iRDC/2pZy 5YwHzhCW7j2nCop8a+y0i79PAcoxgVbc9/5iPg7g0iiSKXxGQIpDsI8TcZ85ugFQfRSL gYddcaT0CXmSn6OpdMYY4JNe7qSEKPxixED1GlG7HBcftoyZt6N9CAzcICeUYMVoEsE3 oXb4ahWw0aCtWUwKR1r1lGynijbOMTjk6ukw9JBMEbMWPw+sJ6HTp2xBy//N2alqB2p8 CL3JIEm3AztGQKuFcR00lZBvWfRktCvY5UjW68wCYjYWqwL/Vt/uVwW2H+P3CK97uN/C FYRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=O4+aN/9rbnpr0jRgCrJIIEbgelWLUMkBW93c7nFL79s=; b=uDxg4gepHmCGazEa6xxgnSc4dskwlnxbVbszgEYwQ/J5HRNvjbwAcNKVvjjN2NiuQc rF8NeMxzHcuwy8EKk2uTyiW0tdW9aBPS9C864UBByWQzZJCkEN/8X/cwEFaZLQeYehBM QBz8RIxoh3YPL55mlp7j+IxLEoqtyyR/cl0EwuHV3TAnRHDZCRnCNtkhaGm+RUfAOlZR dS70fKcXpSxOUrfEhVuaEoB2xB0SntYf+p/noI0XnUfNqi3kvWmOuUZPuNB/NFErplxq 2ANzPrPLijs/SbvR5APmcTiuUpnAy+5CXs1QrOu55o4avbXMe0so8fDC+3PGkTN0U34I Zzfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bYJrpc5q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6-v6si735346pll.258.2018.01.19.02.59.37; Fri, 19 Jan 2018 02:59:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bYJrpc5q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755149AbeASK5i (ORCPT + 99 others); Fri, 19 Jan 2018 05:57:38 -0500 Received: from mail-qt0-f178.google.com ([209.85.216.178]:45108 "EHLO mail-qt0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbeASK5d (ORCPT ); Fri, 19 Jan 2018 05:57:33 -0500 Received: by mail-qt0-f178.google.com with SMTP id x27so2773881qtm.12 for ; Fri, 19 Jan 2018 02:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=O4+aN/9rbnpr0jRgCrJIIEbgelWLUMkBW93c7nFL79s=; b=bYJrpc5q0Y52pVwjuKs8Jr3I6eJ/qj+VITIiEWgCLXZuXXVyfFnY5ghncycDp5Zogf SYwnN1Q21cpPmUCghhAPLwzmFL7oMvER+YtphpGEf7eJOu/8/l8tmsy71kn5Afi7S3XD 4zazMY+eju/RjH4ME5pisHJ94SFI6CiA9OcsceIgO1ZGMkWwdCCYiWJIGLEmsAiQ/nDk dLm1hXBfMKo00khIFlxTOnqwV5ea+r361WAQ8cO3s8UWJAETt7vj7AgHPMgV/58JqNop MeIp3VZ54vgXgYMvYleBTBPKUuoK4v4fkTBzXfV3lAx1lls9hgio1hvv9gYIe68Ky+sI V9ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=O4+aN/9rbnpr0jRgCrJIIEbgelWLUMkBW93c7nFL79s=; b=QMYaelwIOGga8bpR1c2saYjDrlNCIaGeOGUSlahTpGb/vT04fqKLoJiw1lAf6YezTn DkBDBKwCCzmpVZ8eqJZ1/QGAm4/34QS2aQpO5q5C5C3FneEYoBHJZlt21xriLw0dfCN3 ZmtdhP5EqiDK2j9MaPR7UpS9Qyz9Y5d0sbygZgeRCEcXrkkOh8KZPQzmdEO9DBeRHUDc aluA2P5AFlZTP3QiREdX2gUai/Q5OwxvPgcmGn7lGTxyD1aYWSbOIOdNPvESH09x43Qs ciO5MizHSc0dwMhQru33F6gZtg+ljBPa0zNA9T5NDYs95uY+FfX3Tyo/I0bc5Gdx8wft pomQ== X-Gm-Message-State: AKGB3mKT9+D/4X4A7ZfGMP2dXu1LY6ZEIHNa7FGciZJbDwJekRnVi64t mYNi85dziYwsL8FX0xKkNIPhe76lvDDYUhQVdkLQb9Ws X-Received: by 10.55.33.162 with SMTP id f34mr68706361qki.210.1516359452731; Fri, 19 Jan 2018 02:57:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.26.27 with HTTP; Fri, 19 Jan 2018 02:57:32 -0800 (PST) In-Reply-To: <20180117224852.3cr33lhot3rpahg7@shells.gnugeneration.com> References: <20171129183919.GQ692@shells.gnugeneration.com> <20171201213322.GW692@shells.gnugeneration.com> <20180117224852.3cr33lhot3rpahg7@shells.gnugeneration.com> From: Enric Balletbo Serra Date: Fri, 19 Jan 2018 11:57:32 +0100 Message-ID: Subject: Re: [REGRESSION] (>= v4.12) IO w/dmcrypt causing audio underruns To: vcaputo@pengaru.com Cc: linux-kernel , Tim Murray , tj@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vito, 2018-01-17 23:48 GMT+01:00 : > On Mon, Dec 18, 2017 at 10:25:33AM +0100, Enric Balletbo Serra wrote: >> Hi Vito, >> >> 2017-12-01 22:33 GMT+01:00 : >> > On Wed, Nov 29, 2017 at 10:39:19AM -0800, vcaputo@pengaru.com wrote: >> >> Hello, >> >> >> >> Recently I noticed substantial audio dropouts when listening to MP3s in >> >> `cmus` while doing big and churny `git checkout` commands in my linux git >> >> tree. >> >> >> >> It's not something I've done much of over the last couple months so I >> >> hadn't noticed until yesterday, but didn't remember this being a problem in >> >> recent history. >> >> >> >> As there's quite an accumulation of similarly configured and built kernels >> >> in my grub menu, it was trivial to determine approximately when this began: >> >> >> >> 4.11.0: no dropouts >> >> 4.12.0-rc7: dropouts >> >> 4.14.0-rc6: dropouts (seem more substantial as well, didn't investigate) >> >> >> >> Watching top while this is going on in the various kernel versions, it's >> >> apparent that the kworker behavior changed. Both the priority and quantity >> >> of running kworker threads is elevated in kernels experiencing dropouts. >> >> >> >> Searching through the commit history for v4.11..v4.12 uncovered: >> >> >> >> commit a1b89132dc4f61071bdeaab92ea958e0953380a1 >> >> Author: Tim Murray >> >> Date: Fri Apr 21 11:11:36 2017 +0200 >> >> >> >> dm crypt: use WQ_HIGHPRI for the IO and crypt workqueues >> >> >> >> Running dm-crypt with workqueues at the standard priority results in IO >> >> competing for CPU time with standard user apps, which can lead to >> >> pipeline bubbles and seriously degraded performance. Move to using >> >> WQ_HIGHPRI workqueues to protect against that. >> >> >> >> Signed-off-by: Tim Murray >> >> Signed-off-by: Enric Balletbo i Serra >> >> Signed-off-by: Mike Snitzer >> >> >> >> --- >> >> >> >> Reverting a1b8913 from 4.14.0-rc6, my current kernel, eliminates the >> >> problem completely. >> >> >> >> Looking at the diff in that commit, it looks like the commit message isn't >> >> even accurate; not only is the priority of the dmcrypt workqueues being >> >> changed - they're also being made "CPU intensive" workqueues as well. >> >> >> >> This combination appears to result in both elevated scheduling priority and >> >> greater quantity of participant worker threads effectively starving any >> >> normal priority user task under periods of heavy IO on dmcrypt volumes. >> >> >> >> I don't know what the right solution is here. It seems to me we're lacking >> >> the appropriate mechanism for charging CPU resources consumed on behalf of >> >> user processes in kworker threads to the work-causing process. >> >> >> >> What effectively happens is my normal `git` user process is able to >> >> greatly amplify what share of CPU it takes from the system by generating IO >> >> on what happens to be a high-priority CPU-intensive storage volume. >> >> >> >> It looks potentially complicated to fix properly, but I suspect at its core >> >> this may be a fairly longstanding shortcoming of the page cache and its >> >> asynchronous design. Something that has been exacerbated substantially by >> >> the introduction of CPU-intensive storage subsystems like dmcrypt. >> >> >> >> If we imagine the whole stack simplified, where all the IO was being done >> >> synchronously in-band, and the dmcrypt kernel code simply ran in the >> >> IO-causing process context, it would be getting charged to the calling >> >> process and scheduled accordingly. The resource accounting and scheduling >> >> problems all emerge with the page cache, buffered IO, and async background >> >> writeback in a pool of unrelated worker threads, etc. That's how it >> >> appears to me anyways... >> >> >> >> The system used is a X61s Thinkpad 1.8Ghz with 840 EVO SSD, lvm on dmcrypt. >> >> The kernel .config is attached in case it's of interest. >> >> >> >> Thanks, >> >> Vito Caputo >> > >> > >> > >> > Ping... >> > >> > Could somebody please at least ACK receiving this so I'm not left wondering >> > if my mails to lkml are somehow winding up flagged as spam, thanks! >> >> Sorry I did not notice your email before you ping me directly. It's >> interesting that issue, though we didn't notice this problem. It's a >> bit far since I tested this patch but I'll setup the environment again >> and do more tests to understand better what is happening. >> > > Any update on this? > I did not reproduce the issue for now. Can you try what happens if you remove the WQ_CPU_INTENSIVE in the kcryptd_io workqueue? - cc->io_queue = alloc_workqueue("kcryptd_io", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1); cc->io_queue = alloc_workqueue("kcryptd_io", WQ_HIGHPRI | WQ_MEM_RECLAIM, 1); > I still experience it on 4.15-rc7 when doing sustained heavyweight git > checkouts without a1b8913 reverted. > > Thanks, > Vito Caputo