Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1086506ybl; Wed, 14 Aug 2019 10:28:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqw82v2QO8Pw036TKGI/uegWIRiXV5pGua1ZHVfHjm+9wJHX+StAC40lT4/GWflyqR6c+Y+1 X-Received: by 2002:a65:4b89:: with SMTP id t9mr240350pgq.55.1565803724510; Wed, 14 Aug 2019 10:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803724; cv=none; d=google.com; s=arc-20160816; b=qEKfO+WRMR9+rmYysAfBcXTI0f+Mo7l/iKyiJ8DZuP81yGc9NFc/VYyxM0kgMEnnt/ KGTcd4eC2sFu0Th2A6LQLtWrJpOMPpsrkemRZaGYNm/5QzXFOSD1EpFcnQlX+62jVwrQ HquM4QEZaR+spc+v3a0Zbs8uTD1UKBod/K9BKjFlVtNsNL/786Vr4/b5eNDWFttKtNvg cMELKjLQeCq2CphPfY2hRNQ0zDLcymWs0mFcYF1RS3rTJXFzQr7lu7woPhlwLAYn5wd2 LkzyNiMwGypKie3uzU51VsGJiATDC3K6m++42EBpre+MehpJ21Blhdnl3jvn36wZoeDO o/3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1YwKmFD5EgdsGOQ95ZFmB3yPDYfeAFaorCcjcNqQ0g0=; b=W+yc/p/TPjjjIcQVF+g7zibaeGIHppfXH7Uh5Ep96dKdVBcb03vdu8QHM3Mie9bktv ru3qGyUMK7gNVC8yG3n2I9MXn1clNEnXVx3N228h+/gct1yHmMbFHCHa0coCVUMp3hgJ HZnqEiNQCtfDUVpp06Kc5ntNqr36fvH31HcZ9BQQKt7CB3isWfc4bZK6ngxLX08kLR8S YutyZ9OKmWlLkGUxcDqrYYZ2y3Qk0uVvNqdRRcQFXGjp27P4gzIE0c7LNT4ZCKeFmZnA 7cF+hznNrR5U+8qsATF3QRyWSaIgP2cFvyr9MfR6Xaxl9Ibx5M67X+GNVKIOELLeVNoj /5nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EliFGyo6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s59si268270plb.294.2019.08.14.10.28.28; Wed, 14 Aug 2019 10:28:44 -0700 (PDT) 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=@kernel.org header.s=default header.b=EliFGyo6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728806AbfHNRDA (ORCPT + 99 others); Wed, 14 Aug 2019 13:03:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:51418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728753AbfHNRCy (ORCPT ); Wed, 14 Aug 2019 13:02:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED59F208C2; Wed, 14 Aug 2019 17:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802173; bh=+CXq6oZbI60+8LECdsaJ4zvtYQhisedmjNoIKEe5MS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EliFGyo6yAZbdFV8gvTWb5WrDjHh2Me4DHRLmVmp3vHXEIniT+mSkFmECp9YPBoug oYfNdjL6qsHo51jKwPhLEXHZJ/dKGLuo8trt3S0+shtqroHQBbX9zLRe2AYYVIkLfp R9mX9T6Zo5WlyRuXZEblekFXJonZr1bXjRsQ+jCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Jens Axboe Subject: [PATCH 5.2 022/144] loop: set PF_MEMALLOC_NOIO for the worker thread Date: Wed, 14 Aug 2019 18:59:38 +0200 Message-Id: <20190814165800.780401930@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka commit d0a255e795ab976481565f6ac178314b34fbf891 upstream. A deadlock with this stacktrace was observed. The loop thread does a GFP_KERNEL allocation, it calls into dm-bufio shrinker and the shrinker depends on I/O completion in the dm-bufio subsystem. In order to fix the deadlock (and other similar ones), we set the flag PF_MEMALLOC_NOIO at loop thread entry. PID: 474 TASK: ffff8813e11f4600 CPU: 10 COMMAND: "kswapd0" #0 [ffff8813dedfb938] __schedule at ffffffff8173f405 #1 [ffff8813dedfb990] schedule at ffffffff8173fa27 #2 [ffff8813dedfb9b0] schedule_timeout at ffffffff81742fec #3 [ffff8813dedfba60] io_schedule_timeout at ffffffff8173f186 #4 [ffff8813dedfbaa0] bit_wait_io at ffffffff8174034f #5 [ffff8813dedfbac0] __wait_on_bit at ffffffff8173fec8 #6 [ffff8813dedfbb10] out_of_line_wait_on_bit at ffffffff8173ff81 #7 [ffff8813dedfbb90] __make_buffer_clean at ffffffffa038736f [dm_bufio] #8 [ffff8813dedfbbb0] __try_evict_buffer at ffffffffa0387bb8 [dm_bufio] #9 [ffff8813dedfbbd0] dm_bufio_shrink_scan at ffffffffa0387cc3 [dm_bufio] #10 [ffff8813dedfbc40] shrink_slab at ffffffff811a87ce #11 [ffff8813dedfbd30] shrink_zone at ffffffff811ad778 #12 [ffff8813dedfbdc0] kswapd at ffffffff811ae92f #13 [ffff8813dedfbec0] kthread at ffffffff810a8428 #14 [ffff8813dedfbf50] ret_from_fork at ffffffff81745242 PID: 14127 TASK: ffff881455749c00 CPU: 11 COMMAND: "loop1" #0 [ffff88272f5af228] __schedule at ffffffff8173f405 #1 [ffff88272f5af280] schedule at ffffffff8173fa27 #2 [ffff88272f5af2a0] schedule_preempt_disabled at ffffffff8173fd5e #3 [ffff88272f5af2b0] __mutex_lock_slowpath at ffffffff81741fb5 #4 [ffff88272f5af330] mutex_lock at ffffffff81742133 #5 [ffff88272f5af350] dm_bufio_shrink_count at ffffffffa03865f9 [dm_bufio] #6 [ffff88272f5af380] shrink_slab at ffffffff811a86bd #7 [ffff88272f5af470] shrink_zone at ffffffff811ad778 #8 [ffff88272f5af500] do_try_to_free_pages at ffffffff811adb34 #9 [ffff88272f5af590] try_to_free_pages at ffffffff811adef8 #10 [ffff88272f5af610] __alloc_pages_nodemask at ffffffff811a09c3 #11 [ffff88272f5af710] alloc_pages_current at ffffffff811e8b71 #12 [ffff88272f5af760] new_slab at ffffffff811f4523 #13 [ffff88272f5af7b0] __slab_alloc at ffffffff8173a1b5 #14 [ffff88272f5af880] kmem_cache_alloc at ffffffff811f484b #15 [ffff88272f5af8d0] do_blockdev_direct_IO at ffffffff812535b3 #16 [ffff88272f5afb00] __blockdev_direct_IO at ffffffff81255dc3 #17 [ffff88272f5afb30] xfs_vm_direct_IO at ffffffffa01fe3fc [xfs] #18 [ffff88272f5afb90] generic_file_read_iter at ffffffff81198994 #19 [ffff88272f5afc50] __dta_xfs_file_read_iter_2398 at ffffffffa020c970 [xfs] #20 [ffff88272f5afcc0] lo_rw_aio at ffffffffa0377042 [loop] #21 [ffff88272f5afd70] loop_queue_work at ffffffffa0377c3b [loop] #22 [ffff88272f5afe60] kthread_worker_fn at ffffffff810a8a0c #23 [ffff88272f5afec0] kthread at ffffffff810a8428 #24 [ffff88272f5aff50] ret_from_fork at ffffffff81745242 Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -893,7 +893,7 @@ static void loop_unprepare_queue(struct static int loop_kthread_worker_fn(void *worker_ptr) { - current->flags |= PF_LESS_THROTTLE; + current->flags |= PF_LESS_THROTTLE | PF_MEMALLOC_NOIO; return kthread_worker_fn(worker_ptr); }