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 0E095C4167B for ; Mon, 30 Oct 2023 11:49:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84FD86B01A3; Mon, 30 Oct 2023 07:49:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF9E6B01A4; Mon, 30 Oct 2023 07:49:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C7136B01A5; Mon, 30 Oct 2023 07:49:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 59D356B01A3 for ; Mon, 30 Oct 2023 07:49:06 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2B37440775 for ; Mon, 30 Oct 2023 11:49:06 +0000 (UTC) X-FDA: 81401956692.14.6384642 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 525A818000C for ; Mon, 30 Oct 2023 11:49:04 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bTinpibL; spf=pass (imf16.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.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=1698666544; 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=QNWJb3Kj/1cIYg/Vg3MgPzg6XViSheol3KsOD/+icSA=; b=wBYh5KnSGTAheba6/0xit0lZDzUqf8p9oPQWB21l4XhGgEin72K+j8+Q960ez8qdXo+aBD UvnoYq5aONqpn0vttF3YOHHjqAm9jJILhjviE6itUAnj8l4vs6XTt+FCE3dyKokNq8p3wO /zIVzX6FvYYRuTfxQe+gwIOnBo3Syk4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bTinpibL; spf=pass (imf16.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698666544; a=rsa-sha256; cv=none; b=vi0j4oPu/a1LNvn9RdzCQ8MteqO4cIRzIW7B/+knlZHWdhWBZmmxdLa4MEaRcMKMiRmOLU +KpiTR4heeFF8sqlvU3FqkbIdwDWPA70Abp6MaX5/SxuJ1OxrwqqGVd4Y3OPKI0sV+eFq0 p8R2afoPrjf8Qks9T5xm25tWd08dJh8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698666543; 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=QNWJb3Kj/1cIYg/Vg3MgPzg6XViSheol3KsOD/+icSA=; b=bTinpibLG1Xa4ieTRRO1leHCvF9lUqE+VDlau1BjHV8CfZr2DkjNjNDnhKYPrB5HMzPGKg WgHLuBCthv1bz35FzBxND0z8MAjfXw9LHcrXaI/iwKAEFWO2eLehziwshjKMJAsi1+qu5w 9K5x8zJu89FH/zkJrv+3mpapCOcWfcE= 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-577-imiWb702NZ2UiB9qt1FnAg-1; Mon, 30 Oct 2023 07:49:02 -0400 X-MC-Unique: imiWb702NZ2UiB9qt1FnAg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 7D2863C000A2; Mon, 30 Oct 2023 11:49:01 +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 6AFC2492BE0; Mon, 30 Oct 2023 11:49:01 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 5711B30C72AB; Mon, 30 Oct 2023 11:49:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 5467E3D99F; Mon, 30 Oct 2023 12:49:01 +0100 (CET) Date: Mon, 30 Oct 2023 12:49:01 +0100 (CET) From: Mikulas Patocka To: Jan Kara cc: Vlastimil Babka , =?ISO-8859-15?Q?Marek_Marczykowski-G=F3recki?= , 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: <20231030112844.g7b76cm2xxpovt6e@quack3> Message-ID: <7355fe90-5176-ea11-d6ed-a187c0146fdc@redhat.com> References: <89320668-67a2-2a41-e577-a2f561e3dfdd@suse.cz> <818a23f2-c242-1c51-232d-d479c3bcbb6@redhat.com> <18a38935-3031-1f35-bc36-40406e2e6fd2@suse.cz> <20231030112844.g7b76cm2xxpovt6e@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: 525A818000C X-Rspam-User: X-Stat-Signature: 86tx36p5313i58jg6guapezh3an1et9a X-Rspamd-Server: rspam01 X-HE-Tag: 1698666544-410699 X-HE-Meta: U2FsdGVkX1/YxTrrX6NxrZnVBb8ZIjBBkAKeCqOpEu7oKwrZgxY6i+Tw2WA/nPk5pMAI6NtaRfoRoSKik/bCr3Z3GHFTJX9zH3ssYUKHgpFwdI02FPp+wKQwIUNg7dxB+YX1NXsgvzVwvEVhQuv25St8m81i0j2O80iU1tX1RBfC/2t0Jlj2ED7K5/uN315pit2H9IBqtafGZ+sHe1OevbEnnI/yToyWq9DtEQKXXdutSpQb3jctH7q6Ho81rj4lVJZxBs8yTOjFFtUD1ldvr8Xn9K+5Ly37/p8LluAIkkQJFr+yUwlOxBX24DuL5PoXGZQDrmvgXQYlWWUn1KeO0D8hpDT2a59SFWzISz/JVhhPkNCCaIY83vtvlEcSigRJxs3sWX4sPjSO3U9DkELL3grCU51wwG8mIyVqj7/Mtq261Ncj7Rw/Z6SdYLYfQxAddUtbBbG2co3CM9VOv+3x9hZHWaGraqRORHJ2ZR4pkJAR8o/GGDpNIytqTGHs7qlSNI6lvwprBxlz4K9INz0geFgIm5ftzTpQh0NpU8Dpl16O+a6d6Pi6OXsxiV5ojrxXfg4xqKvzzP8d0Dn12YXuffGdDpwJnqP1qnNB/PKCthJqRYRG/r5IPh3WV6HYf3zEGOQYvzBVZEx5YBScMY0xIy5dbeTqVR/mnahnRSoDg7irO4N6KRaJnCBBHsMj59vTuCPjJeGrPk6jIMxGsJvEglc9AnmGBf3ehRnRXIZZXE23/b6aZuPKYOdYSTkittWCCFwXSq5y/0h8dKCZgWKnfQ9zYLNMYip3lvcozYADjZzVwv6hm9r3tSWqq0SHCMn5AYmFANfSsfzBNhur9cVHDP3c2b4bJDHPs442Hnlv7ba/rtUCwaT0D7/s5WGtGfj4C1Bjgqd1eJdSW+PJP0KoRT7s9i7pZjDyhmVaf5QMRa4nDzPwvbW21f03H4AS6FUaBFo6481KOjHq3CDB2YJ ocTOakWd ghWMO8lV4trqkewCMAPyCzjgov08Qce+21nu+Iyak/3Jbl8NPm5wU3o1I5bxdb3V7Vdg0JvdWnTD0PYDWZKqytodfSMOZ64odVeTvSDmXVwVgG+6OKLJDBokzqRje78szjLLf5oubJmwFfkQ3KCoLWgNkN9H08wS8P7EZvoPFkA5ZRRvEHN9FgIojklA+zJKIUc8BfFtzPHzeNLY= 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: On Mon, 30 Oct 2023, Jan Kara wrote: > > >> What if we end up in "goto retry" more than once? I don't see a matching > > > > > > It is impossible. Before we jump to the retry label, we set > > > __GFP_DIRECT_RECLAIM. mempool_alloc can't ever fail if > > > __GFP_DIRECT_RECLAIM is present (it will just wait until some other task > > > frees some objects into the mempool). > > > > Ah, missed that. And the traces don't show that we would be waiting for > > that. I'm starting to think the allocation itself is really not the issue > > here. Also I don't think it deprives something else of large order pages, as > > per the sysrq listing they still existed. > > > > What I rather suspect is what happens next to the allocated bio such that it > > works well with order-0 or up to costly_order pages, but there's some > > problem causing a deadlock if the bio contains larger pages than that? > > Hum, so in all the backtraces presented we see that we are waiting for page > writeback to complete but I don't see anything that would be preventing the > bios from completing. Page writeback can submit quite large bios so it kind > of makes sense that it trips up some odd behavior. Looking at the code > I can see one possible problem in crypt_alloc_buffer() but it doesn't > explain why reducing initial page order would help. Anyway: Are we > guaranteed mempool has enough pages for arbitrarily large bio that can > enter crypt_alloc_buffer()? I can see crypt_page_alloc() does limit the > number of pages in the mempool to dm_crypt_pages_per_client plus I assume > the percpu counter bias in cc->n_allocated_pages can limit the really > available number of pages even further. So if a single bio is large enough > to trip percpu_counter_read_positive(&cc->n_allocated_pages) >= > dm_crypt_pages_per_client condition in crypt_page_alloc(), we can loop > forever? But maybe this cannot happen for some reason... > > If this is not it, I think we need to find out why the writeback bios are > not completeting. Probably I'd start with checking what is kcryptd, > presumably responsible for processing these bios, doing. > > Honza cc->page_pool is initialized to hold BIO_MAX_VECS pages. crypt_map will restrict the bio size to BIO_MAX_VECS (see dm_accept_partial_bio being called from crypt_map). When we allocate a buffer in crypt_alloc_buffer, we try first allocation without waiting, then we grab the mutex and we try allocation with waiting. The mutex should prevent a deadlock when two processes allocate 128 pages concurrently and wait for each other to free some pages. The limit to dm_crypt_pages_per_client only applies to pages allocated from the kernel - when this limit is reached, we can still allocate from the mempool, so it shoudn't cause deadlocks. Mikulas