From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7997AC433DF for ; Tue, 16 Jun 2020 08:16:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4898F2074D for ; Tue, 16 Jun 2020 08:16:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4898F2074D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C7A366B0073; Tue, 16 Jun 2020 04:16:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C29C56B0074; Tue, 16 Jun 2020 04:16:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B185A6B0075; Tue, 16 Jun 2020 04:16:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 978756B0073 for ; Tue, 16 Jun 2020 04:16:32 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 10BAA180AD80F for ; Tue, 16 Jun 2020 08:16:32 +0000 (UTC) X-FDA: 76934368224.12.sand04_2412a1f26dfd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id D021618006AFF for ; Tue, 16 Jun 2020 08:16:31 +0000 (UTC) X-HE-Tag: sand04_2412a1f26dfd X-Filterd-Recvd-Size: 5641 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 08:16:31 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id p18so13572500eds.7 for ; Tue, 16 Jun 2020 01:16:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3Q9s4Dr6CFfP0blUZrmq2KkSHz2WB3o+IFesWRBADsk=; b=VX8PA7NbKLli25ECcCwmOiPYSmhlKshzRgCA4g0UOfWYpat/75tk6PI4ILkB31Heqj 25frLnLqnGMjsoyoxPuDEdqZBYcvtbbC1s4IqHIuKcPCmAg0ta0PfLPJbWgIUBacVnhh SY7wlGLX4BUxbBJLQ/zniAhlONcnfNvBnM81cpBjmn7e8EWoEFCAYuSVyTzRnYPzW+vI s7ulQdtgRedqBJ6ncxYqpCwY1Kt+xXtQribg3zqfwnbfgsep005wswheHl0EFvMmNIAs KE3/1rM2EmxkbObrZo8Eki2FNwUBzRooH2hh+o5AtYvPmk5pned8CPcs0svjs6Ao+y6w 5lJg== X-Gm-Message-State: AOAM531S4m/lYL9gMJupUo2Ep43IG18vIUDTkrO/S350tE5tg/P/j1QD Kwe/29uBX6RTTEVz1bqZVnw= X-Google-Smtp-Source: ABdhPJwhX66Seu5A5vdpQC7uaqZ5/KLd99XixrVXgjp0XZbhtY+sfcr7lo914+VIaTJ/adaZhOqAiw== X-Received: by 2002:a50:bb29:: with SMTP id y38mr1475446ede.358.1592295390227; Tue, 16 Jun 2020 01:16:30 -0700 (PDT) Received: from localhost (ip-37-188-174-201.eurotel.cz. [37.188.174.201]) by smtp.gmail.com with ESMTPSA id ce25sm9655908edb.45.2020.06.16.01.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 01:16:29 -0700 (PDT) Date: Tue, 16 Jun 2020 10:16:28 +0200 From: Michal Hocko To: Yafang Shao Cc: hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com, akpm@linux-foundation.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3] xfs: avoid deadlock when trigger memory reclaim in ->writepages Message-ID: <20200616081628.GC9499@dhcp22.suse.cz> References: <1592222181-9832-1-git-send-email-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592222181-9832-1-git-send-email-laoar.shao@gmail.com> X-Rspamd-Queue-Id: D021618006AFF X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 15-06-20 07:56:21, Yafang Shao wrote: > Recently there is a XFS deadlock on our server with an old kernel. > This deadlock is caused by allocating memory in xfs_map_blocks() while > doing writeback on behalf of memroy reclaim. Although this deadlock happens > on an old kernel, I think it could happen on the upstream as well. This > issue only happens once and can't be reproduced, so I haven't tried to > reproduce it on upsteam kernel. > > Bellow is the call trace of this deadlock. > [480594.790087] INFO: task redis-server:16212 blocked for more than 120 seconds. > [480594.790087] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > [480594.790088] redis-server D ffffffff8168bd60 0 16212 14347 0x00000004 > [480594.790090] ffff880da128f070 0000000000000082 ffff880f94a2eeb0 ffff880da128ffd8 > [480594.790092] ffff880da128ffd8 ffff880da128ffd8 ffff880f94a2eeb0 ffff88103f9d6c40 > [480594.790094] 0000000000000000 7fffffffffffffff ffff88207ffc0ee8 ffffffff8168bd60 > [480594.790096] Call Trace: > [480594.790101] [] schedule+0x29/0x70 > [480594.790103] [] schedule_timeout+0x239/0x2c0 > [480594.790111] [] io_schedule_timeout+0xae/0x130 > [480594.790114] [] io_schedule+0x18/0x20 > [480594.790116] [] bit_wait_io+0x11/0x50 > [480594.790118] [] __wait_on_bit+0x65/0x90 > [480594.790121] [] wait_on_page_bit+0x81/0xa0 > [480594.790125] [] shrink_page_list+0x6d2/0xaf0 > [480594.790130] [] shrink_inactive_list+0x223/0x710 > [480594.790135] [] shrink_lruvec+0x3b5/0x810 > [480594.790139] [] shrink_zone+0xba/0x1e0 > [480594.790141] [] do_try_to_free_pages+0x100/0x510 > [480594.790143] [] try_to_free_mem_cgroup_pages+0xdd/0x170 > [480594.790145] [] mem_cgroup_reclaim+0x4e/0x120 > [480594.790147] [] __mem_cgroup_try_charge+0x41c/0x670 > [480594.790153] [] __memcg_kmem_newpage_charge+0xf6/0x180 > [480594.790157] [] __alloc_pages_nodemask+0x22d/0x420 > [480594.790162] [] alloc_pages_current+0xaa/0x170 > [480594.790165] [] new_slab+0x30c/0x320 > [480594.790168] [] ___slab_alloc+0x3ac/0x4f0 > [480594.790204] [] __slab_alloc+0x40/0x5c > [480594.790206] [] kmem_cache_alloc+0x193/0x1e0 > [480594.790233] [] kmem_zone_alloc+0x97/0x130 [xfs] > [480594.790247] [] _xfs_trans_alloc+0x3a/0xa0 [xfs] > [480594.790261] [] xfs_trans_alloc+0x3c/0x50 [xfs] Now with a more explanation from Dave I have got back to the original backtrace. Not sure which kernel version you are using but this path should have passed xfs_trans_reserve which sets PF_MEMALLOC_NOFS and this in turn should have made __alloc_pages_nodemask to use __GFP_NOFS and the memcg reclaim shouldn't ever wait_on_page_writeback (pressumably this is what the io_schedule is coming from). Does your kernel have ecf5fc6e9654c? -- Michal Hocko SUSE Labs