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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 611A6C4332F for ; Tue, 31 Oct 2023 17:17:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2F808D001F; Tue, 31 Oct 2023 13:17:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB78A8D0012; Tue, 31 Oct 2023 13:17:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7F3C8D001F; Tue, 31 Oct 2023 13:17:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A217F8D0012 for ; Tue, 31 Oct 2023 13:17:41 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 54254A04D4 for ; Tue, 31 Oct 2023 17:17:41 +0000 (UTC) X-FDA: 81406413522.06.A485BB7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 2CFC9C0020 for ; Tue, 31 Oct 2023 17:17:38 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eBDCXOMU; spf=pass (imf28.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698772659; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KItUmro+eQMn3OtC7hcwqT1jD+OcEM3bVlAzhSK/rtQ=; b=8G/mZGDiEWw0YGTBiymSpbRoFaghNVw+RwKQbqxdWfIDTL7C8Z3XVqqTTJn+mJ3wZ9Lb/f inVDC3khY5URmbvtdgbYCqDfBMREsdJnXNOX8ffO681L4AT6RKS1WIwABZ8TrkS6pMQ99k RY97nWeSB7OfbCwY62Hu5Befbrg7sWM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698772659; a=rsa-sha256; cv=none; b=HRE79RHOlbNZW3gy07dLs9IznLFE6Nw+6yOcnfpVX8Kq80tDyzXVpRMsqh3DEDKsoWBcgm /EB6Ol9tmhp8GZOdWvZbt1rOGKkAuX8sbVQnGTn273+OKtlOlByez23f6PHj7yQf+iFcEz No6RFj8BYHUZpJt5JV1/HP4l38fQJvI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eBDCXOMU; spf=pass (imf28.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698772658; h=from:from:reply-to:subject:subject: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=KItUmro+eQMn3OtC7hcwqT1jD+OcEM3bVlAzhSK/rtQ=; b=eBDCXOMU/Jj+5ue0FY8lM/OhoCF8tB+wKAJREW5258phiHAFAuMKec+M1yUBX9S0qLbhax e78j56RQor14CmlTTwG2XUr9s1ngK5otmv5YGc2douSGC1Doy3h13z8iWJgZfSO7TAfiSi ZTla8OE8BtG2ATQhTQCPtZyLZ5fkgfc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-158-eScYHzCiPQ6pOZB5DxRIkw-1; Tue, 31 Oct 2023 13:17:27 -0400 X-MC-Unique: eScYHzCiPQ6pOZB5DxRIkw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6A8F29ABA2C; Tue, 31 Oct 2023 17:17:26 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D58F33D4; Tue, 31 Oct 2023 17:17:26 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id BE00830C2A86; Tue, 31 Oct 2023 17:17:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id B97CC3FB77; Tue, 31 Oct 2023 18:17:26 +0100 (CET) Date: Tue, 31 Oct 2023 18:17:26 +0100 (CET) From: Mikulas Patocka To: =?ISO-8859-15?Q?Marek_Marczykowski-G=F3recki?= cc: Jan Kara , Vlastimil Babka , Andrew Morton , Matthew Wilcox , Michal Hocko , stable@vger.kernel.org, regressions@lists.linux.dev, Alasdair Kergon , Mike Snitzer , dm-devel@lists.linux.dev, linux-mm@kvack.org Subject: Re: Intermittent storage (dm-crypt?) freeze - regression 6.4->6.5 In-Reply-To: Message-ID: <8a35cdea-3a1a-e859-1f7c-55d1c864a48@redhat.com> References: <3514c87f-c87f-f91f-ca90-1616428f6317@redhat.com> <1a47fa28-3968-51df-5b0b-a19c675cc289@suse.cz> <20231030122513.6gds75hxd65gu747@quack3> <20231030155603.k3kejytq2e4vnp7z@quack3> <98aefaa9-1ac-a0e4-fb9a-89ded456750@redhat.com> <20231031140136.25bio5wajc5pmdtl@quack3> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="185210117-713297632-1698772646=:87896" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspamd-Queue-Id: 2CFC9C0020 X-Rspam-User: X-Stat-Signature: moepfgig4ctg449hrt6xgweaitt47yi1 X-Rspamd-Server: rspam03 X-HE-Tag: 1698772658-535342 X-HE-Meta: U2FsdGVkX1/ZVcZfqkSqRo4ZqVob4ayddk0XPuC0SEtIDWGp3ex+dciE1IJ7xsAuKaPE6fYRleWDM5Z7pDHt9fuz81RrF0kk9Db6dX0TdMmavyqnMfzUP/lOtdFI8R+l+JWVUyfSycSBw/Z/wpSvPqAP1XMS3JdlmxNMqAg5NkePFVQ8uos9d7ZDhl1hJvA5jblcURkxNv44AxRpBifxDTuN8Mjb/ktzsxUbb82ta/4DF583KxHALetAS9a4y2TQJ8TkE87Bs1FPdTjmBsvk5al5UpxvvRJ6M4Rsrzc9WsGHXRXp8tmMk14D2bPh1eYQZPiFvbz4uSNyP6c4qllDP1jJPIVYN2kvcL95hBdaM9TPHP8sUtnbOQqI7cCrLhYI8TDUSFGChb/lZU3kQW8O1eiqPpsfPAD0jObyxdfF7MmRlcIbHaijKW1OieI1/3OxURQyBDbwGhH3hQBxkpIxItE7Qw3EkAHMvRBS+7/o4c1Q7BJX7NWhwXGEThvq8GPR6PPOvywNo/UYycVHuKoySxdo7/GKCO4oh3QJ2IhX53zb664q+h8jI0HxUDfON5YUasRlqriBxl4Xx/6xln5CKkw4Qd8vKzhD34gfrS9yaRycwhHeZZNH6ZSeYe4Ro1458X00QhgpVxyRrEp3DcLnzDCBvuWdb3PDGNrUadvlMVF2VHhgT0eS4N6VwbBepBJ7AB8mdva8e2xnLgpysQRpu+MkVGa5WDq6T+McSuiXswQ3tFZJ5/lqFZqm2w8jPqIlf7wtWgYAVgOGdh/KvjpV9tNcNqpStvYaMIR/eslrrtibcSmXvYVuBgzaq67i6D3JSQ25KqJkCwQwteF30lOYIQSB31UJiqgB0dwZK+EEQKpNUtO8MIvPg8N0ar7mTh/0fRxmnjrwnnf1DINW6rw/fTiuIWjcsrOOIGPSgxqljo9ccEne9g/p7JfZgjVDejhBMvL1IVFZJJR0GYiULHE 87hKTn0i DG3iGqFmEYruzBBeT3kccY6BqHWHt1MZeBzEKyGLXNSfybvvjyQt8S4c7Xrv9lLwT1i8vn9TBLBXVdzALVX8+RUWFBbVet3qdMnkv2Je6kXkk6wsRmLsW2CkweFzPZaA6CAGaU54DIne6/sW3x6gizLSwLj+3tduvvM+h62UuCFtxu3W5AHXxEnqjctyzMJdBLKRcQ+fd4o6FYpPul/Y3rjyBMHaKIVRB22d5g72wu6DRPvwT9jRsfHonmmWeR4+cZhUz9CS6rHHt/j/3vC2+1PzK0w== 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: List-Subscribe: List-Unsubscribe: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --185210117-713297632-1698772646=:87896 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Tue, 31 Oct 2023, Marek Marczykowski-Górecki wrote: > On Tue, Oct 31, 2023 at 03:01:36PM +0100, Jan Kara wrote: > > On Tue 31-10-23 04:48:44, Marek Marczykowski-Górecki wrote: > > > Then tried: > > > - PAGE_ALLOC_COSTLY_ORDER=4, order=4 - cannot reproduce, > > > - PAGE_ALLOC_COSTLY_ORDER=4, order=5 - cannot reproduce, > > > - PAGE_ALLOC_COSTLY_ORDER=4, order=6 - freeze rather quickly > > > > > > I've retried the PAGE_ALLOC_COSTLY_ORDER=4,order=5 case several times > > > and I can't reproduce the issue there. I'm confused... > > > > And this kind of confirms that allocations > PAGE_ALLOC_COSTLY_ORDER > > causing hangs is most likely just a coincidence. Rather something either in > > the block layer or in the storage driver has problems with handling bios > > with sufficiently high order pages attached. This is going to be a bit > > painful to debug I'm afraid. How long does it take for you trigger the > > hang? I'm asking to get rough estimate how heavy tracing we can afford so > > that we don't overwhelm the system... > > Sometimes it freezes just after logging in, but in worst case it takes > me about 10min of more or less `tar xz` + `dd`. Hi I would like to ask you to try this patch. Revert the changes to "order" and "PAGE_ALLOC_COSTLY_ORDER" back to normal and apply this patch on a clean upstream kernel. Does it deadlock? There is a bug in dm-crypt that it doesn't account large pages in cc->n_allocated_pages, this patch fixes the bug. Mikulas --- drivers/md/dm-crypt.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) Index: linux-stable/drivers/md/dm-crypt.c =================================================================== --- linux-stable.orig/drivers/md/dm-crypt.c 2023-10-31 16:25:09.000000000 +0100 +++ linux-stable/drivers/md/dm-crypt.c 2023-10-31 16:53:14.000000000 +0100 @@ -1700,11 +1700,16 @@ retry: order = min(order, remaining_order); while (order > 0) { + if (unlikely(percpu_counter_read_positive(&cc->n_allocated_pages) + (1 << order) > dm_crypt_pages_per_client)) + goto decrease_order; pages = alloc_pages(gfp_mask | __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | __GFP_COMP, order); - if (likely(pages != NULL)) + if (likely(pages != NULL)) { + percpu_counter_add(&cc->n_allocated_pages, 1 << order); goto have_pages; + } +decrease_order: order--; } @@ -1742,10 +1747,12 @@ static void crypt_free_buffer_pages(stru if (clone->bi_vcnt > 0) { /* bio_for_each_folio_all crashes with an empty bio */ bio_for_each_folio_all(fi, clone) { - if (folio_test_large(fi.folio)) + if (folio_test_large(fi.folio)) { + percpu_counter_sub(&cc->n_allocated_pages, 1 << folio_order(fi.folio)); folio_put(fi.folio); - else + } else { mempool_free(&fi.folio->page, &cc->page_pool); + } } } } --185210117-713297632-1698772646=:87896--