Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4083401rdb; Thu, 14 Sep 2023 11:11:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH423kBHcc8BV5dU6HtktuVVsUGQnk/lQTdVJ7iuo8Y2LAge6wEuroLgjh4PrahgzYo9lwN X-Received: by 2002:a17:903:2285:b0:1bb:2ccc:c321 with SMTP id b5-20020a170903228500b001bb2cccc321mr7719045plh.48.1694715091025; Thu, 14 Sep 2023 11:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694715091; cv=none; d=google.com; s=arc-20160816; b=UdXqw7B9ZPZN+at44P1aieeXSNiej0zxMJ/KnT9cpfmF2QHsdMMKD/lMB/ut0iN4Y2 wf8pyJnwqiugIyNUUc4xEaxHtW3rutgIED72KvRdzUlQO4/2l31Y/RUVtQ0CjvHuadlh AEQnsu7G1jzBqsywMn7jvxsPv3W+GAOHAXKQxoHwFoumLzYp8EHhbmP1vPmTJhD+P9Mm vAXNFFTTWfHnxltH+xfjwkmYabZhW/9ZF7tKB40Rg3I54pG9fSRxNOTslYHuUyNAzt/l hLLD00nFdQaWf1MLTTPYy32kUkCr9xU3iHaWbBFeKe2YEZ4paPYmzxGqXKg48OlGkXUw A5oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9dYbcygFs+B71xYNYqVHVDk/ZWOqRCfnzVK6KuhBKJI=; fh=ZApwyyFezqbyj2RE6nQ3qs4qhYWSDMrNZZlbDzmDUpY=; b=0acqy6YHTCxgzJPmM94K77/DGubebjjAdTSxllOHCqy57+j1ULASFprHRfR+TbJx9/ oMkm7atVY7aaKthFqRNDbTkze1SDJJTubTFnKCKc5RtMwkRyoJvjfz/VEBkX63+DGV6S MW3bCieDJEJO1Vep/64r4v/n9JZNtqLA804r109I7j9XpL4yfFB5feNU/A3dWOfceOeH QioJh5+i7+8pmhq7ybic4bKYPveBQDJZnYyZ4vsQu8BdRCweZfcoOzDtIk9hcI8E+VMU m2HPrd8/UkBAIf+xIawJ8apTTuurrJKOgPX6p5KTL8dXv7TDZJNnjvwIflEkNtVgQjU4 hhvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Rheo62hL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y22-20020a17090264d600b001bdca6456c3si1884010pli.46.2023.09.14.11.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:11:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Rheo62hL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D23D7832C35B; Thu, 14 Sep 2023 09:57:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbjINQ45 (ORCPT + 99 others); Thu, 14 Sep 2023 12:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjINQ45 (ORCPT ); Thu, 14 Sep 2023 12:56:57 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7321FDE for ; Thu, 14 Sep 2023 09:56:53 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BD4181F74C; Thu, 14 Sep 2023 16:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1694710611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9dYbcygFs+B71xYNYqVHVDk/ZWOqRCfnzVK6KuhBKJI=; b=Rheo62hLVc0dxeDLyvQ5sjmbAvZLXFpqZnskMAwq8m+e5BP+OY4EoCEVJQ3IQ5hGcOetul D0eG7FEfYFe0Wa2I6io9FWd3rsnfPJJoNzKXLRNFdTRj1+/QGWbH1pHxqrvxRCLxw7i1D/ 26Omj6jLkgHAsDtjC0MhGXWkYenKals= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9DFEF139DB; Thu, 14 Sep 2023 16:56:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eTH/IlM7A2XnPgAAMHmgww (envelope-from ); Thu, 14 Sep 2023 16:56:51 +0000 Date: Thu, 14 Sep 2023 18:56:50 +0200 From: Michal Hocko To: Johannes Weiner Cc: Andrew Morton , Shakeel Butt , Breno Leitao , Josef Bacik , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: memcontrol: fix GFP_NOFS recursion in memory.high enforcement Message-ID: References: <20230914152139.100822-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230914152139.100822-1-hannes@cmpxchg.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 09:57:10 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email On Thu 14-09-23 11:21:39, Johannes Weiner wrote: > Breno and Josef report a deadlock scenario from cgroup reclaim > re-entering the filesystem: > > [ 361.546690] ====================================================== > [ 361.559210] WARNING: possible circular locking dependency detected > [ 361.571703] 6.5.0-0_fbk700_debug_rc0_kbuilder_13159_gbf787a128001 #1 Tainted: G S E > [ 361.589704] ------------------------------------------------------ > [ 361.602277] find/9315 is trying to acquire lock: > [ 361.611625] ffff88837ba140c0 (&delayed_node->mutex){+.+.}-{4:4}, at: __btrfs_release_delayed_node+0x68/0x4f0 > [ 361.631437] > [ 361.631437] but task is already holding lock: > [ 361.643243] ffff8881765b8678 (btrfs-tree-01){++++}-{4:4}, at: btrfs_tree_read_lock+0x1e/0x40 > > [ 362.904457] mutex_lock_nested+0x1c/0x30 > [ 362.912414] __btrfs_release_delayed_node+0x68/0x4f0 > [ 362.922460] btrfs_evict_inode+0x301/0x770 > [ 362.982726] evict+0x17c/0x380 > [ 362.988944] prune_icache_sb+0x100/0x1d0 > [ 363.005559] super_cache_scan+0x1f8/0x260 > [ 363.013695] do_shrink_slab+0x2a2/0x540 > [ 363.021489] shrink_slab_memcg+0x237/0x3d0 > [ 363.050606] shrink_slab+0xa7/0x240 > [ 363.083382] shrink_node_memcgs+0x262/0x3b0 > [ 363.091870] shrink_node+0x1a4/0x720 > [ 363.099150] shrink_zones+0x1f6/0x5d0 > [ 363.148798] do_try_to_free_pages+0x19b/0x5e0 > [ 363.157633] try_to_free_mem_cgroup_pages+0x266/0x370 > [ 363.190575] reclaim_high+0x16f/0x1f0 > [ 363.208409] mem_cgroup_handle_over_high+0x10b/0x270 > [ 363.246678] try_charge_memcg+0xaf2/0xc70 > [ 363.304151] charge_memcg+0xf0/0x350 > [ 363.320070] __mem_cgroup_charge+0x28/0x40 > [ 363.328371] __filemap_add_folio+0x870/0xd50 > [ 363.371303] filemap_add_folio+0xdd/0x310 > [ 363.399696] __filemap_get_folio+0x2fc/0x7d0 > [ 363.419086] pagecache_get_page+0xe/0x30 > [ 363.427048] alloc_extent_buffer+0x1cd/0x6a0 > [ 363.435704] read_tree_block+0x43/0xc0 > [ 363.443316] read_block_for_search+0x361/0x510 > [ 363.466690] btrfs_search_slot+0xc8c/0x1520 > > This is caused by the mem_cgroup_handle_over_high() not respecting the > gfp_mask of the allocation context. We used to only call this function > on resume to userspace, where no locks were held. But c9afe31ec443 > ("memcg: synchronously enforce memory.high for large overcharges") > added a call from the allocation context without considering the gfp. > > Reported-by: Breno Leitao > Reported-by: Josef Bacik > Fixes: c9afe31ec443 ("memcg: synchronously enforce memory.high for large overcharges") > Cc: stable@vger.kernel.org # 5.17+ > Signed-off-by: Johannes Weiner Acked-by: Michal Hocko Thanks! -- Michal Hocko SUSE Labs