From patchwork Mon Nov 4 02:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13860800 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56D1C2F5A for ; Mon, 4 Nov 2024 02:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730687917; cv=none; b=bLyVKqF5eJ3NSrzSO/wO9G7ePFnDsblrwPwrfXKs/7/UHZUFzec2Rk306ln8BaVko8htPC7IerN+Ou8bgVHddKL8JGbZfw4x2s4ocf81IypZWC6htH952TzO4r3uNE4sb2doBrx0mmw+Bce/O5vGERYKB9aaz3uXErTVdp+Afvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730687917; c=relaxed/simple; bh=XhCyYYk0mEstaNDV/2XhxEt14BcFP29muk01JM58Mg0=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:From:To:Cc: References:In-Reply-To; b=jOZDNdhLdroxgaHDGtTJFkpFruhqcpvWxKf7WCIqBT+HWSxtHAHn3/yad3rFxpU0PW0vc1iNGAJ16gOgda6OAhlGhbzK5GNW40za7PxPIzmTaDIzQoOPhV4ZFGPOfYx3x3YHD9RxZIY2TDL75fNmAl+nBz66tLoTKrlP0c5qKg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=GIp9u7UL; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="GIp9u7UL" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20c9978a221so36965095ad.1 for ; Sun, 03 Nov 2024 18:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1730687913; x=1731292713; darn=vger.kernel.org; h=in-reply-to:content-language:references:cc:to:from:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=eC3eBFWwdOLE/lj3duyiFnbRAXC5pXb5r7bt7MjFNVc=; b=GIp9u7ULHgWBPkcjslrBVautXIdTTmj7HVxNi/WYUTXH0jDAPcySfBFb2uDz9xR6PB zoaMJiczxr9xFLQTiD/OWPoMI4dGFiYeWWDCUx13nhP/+0Ul4KWPDpdUcWuAj43OZE7e tnkPEmJrfh3b3VTN3tvuZRn12AqPtMVHpSehrSuMaCeKGUOZjw/MmHBhhfkfxie1ucyu xoDtHlLzaIbgNppYdAOS9iQDyXkwWZXSjQpAqEvC3H16Pa6bGvU28bm9OlyZLo7Yn41b B7+Eoq6WL39V7vzWwhe9mUpXhtT3T3hdd2sQWQU14B9WSrXsImfpPKQQPSRivrrpNCKy vtwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730687913; x=1731292713; h=in-reply-to:content-language:references:cc:to:from:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=eC3eBFWwdOLE/lj3duyiFnbRAXC5pXb5r7bt7MjFNVc=; b=pQ7UFpR8RLnhgngBfJLkkmaqW5ZYo2RvDYoV/0g7vW+aLIs4dNZmbz34CQ8Qk7vdrt j3TTLCqfCJQh+pMdhYel9zAhN9IBaRZvbbN2T2IYfPS6BqQuAoanvOYlF+K26PSkdbCW e5K9IcMfgPlFt0fsMNf8aw9giLGeLDT3GZTs3XR58+ZDxoQngMv4gaB9VXXDpRbYdtRY TsW2W7JxRLf6WYPVuyDYeHblZUA9/ZlZd7xFBwWn8DiY2MPmxqsCycC5Is9aZx0eEIvd 0BgZVdVvkCRq3VTm/R/I0uYSg7pfrgQ0nVm4iCX57u9yZZkkmkuV7OBfKzft0rf/OWQQ JeYA== X-Forwarded-Encrypted: i=1; AJvYcCW3uUp2aeTno7aGtB0h8oaCBElhc50Fq1n9vqLHnZ5MXmc4y1f3lr1LhI3cvZ9jqd03bTw3WXSKmg==@vger.kernel.org X-Gm-Message-State: AOJu0YyFQD7OkFA1l9HFI7PtwF7yTSU2YLV1ouqFraVcFSx22XyHcxMM HDKgLh7XkJJmcKTfj7QtbII13BlMVK9BuODB7VPOHq6Sp0fPxMNiaeJz0LfK4TY= X-Google-Smtp-Source: AGHT+IHirDQUIVeuwX+mE5dRWw3aGeXGQssoMqggzHIIOwB3ls3PYAgmLZwJ1Gf7RQMWv52Y0OAvbg== X-Received: by 2002:a17:902:f693:b0:20b:9535:922d with SMTP id d9443c01a7336-210c6d27f7fmr350982525ad.60.1730687912581; Sun, 03 Nov 2024 18:38:32 -0800 (PST) Received: from [192.168.1.150] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2110570865fsm51955925ad.107.2024.11.03.18.38.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Nov 2024 18:38:31 -0800 (PST) Message-ID: Date: Sun, 3 Nov 2024 19:38:30 -0700 Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Stable backport (was "Re: PROBLEM: io_uring hang causing uninterruptible sleep state on 6.6.59") From: Jens Axboe To: Keith Busch Cc: Andrew Marshall , io-uring@vger.kernel.org, Greg Kroah-Hartman , stable References: <3d913aef-8c44-4f50-9bdf-7d9051b08941@app.fastmail.com> <25c4c665-1a33-456c-93c7-8b7b56c0e6db@kernel.dk> Content-Language: en-US In-Reply-To: <25c4c665-1a33-456c-93c7-8b7b56c0e6db@kernel.dk> On 11/3/24 5:06 PM, Jens Axboe wrote: > On 11/3/24 5:01 PM, Keith Busch wrote: >> On Sun, Nov 03, 2024 at 04:53:27PM -0700, Jens Axboe wrote: >>> On 11/3/24 4:47 PM, Andrew Marshall wrote: >>>> I identified f4ce3b5d26ce149e77e6b8e8f2058aa80e5b034e as the likely >>>> problematic commit simply by browsing git log. As indicated above; >>>> reverting that atop 6.6.59 results in success. Since it is passing on >>>> 6.11.6, I suspect there is some missing backport to 6.6.x, or some >>>> other semantic merge conflict. Unfortunately I do not have a compact, >>>> minimal reproducer, but can provide my large one (it is testing a >>>> larger build process in a VM) if needed?there are some additional >>>> details in the above-linked downstream bug report, though. I hope that >>>> having identified the problematic commit is enough for someone with >>>> more context to go off of. Happy to provide more information if >>>> needed. >>> >>> Don't worry about not having a reproducer, having the backport commit >>> pin pointed will do just fine. I'll take a look at this. >> >> I think stable is missing: >> >> 6b231248e97fc3 ("io_uring: consolidate overflow flushing") > > I think you need to go back further than that, this one already > unconditionally holds ->uring_lock around overflow flushing... Took a look, it's this one: commit 8d09a88ef9d3cb7d21d45c39b7b7c31298d23998 Author: Pavel Begunkov Date: Wed Apr 10 02:26:54 2024 +0100 io_uring: always lock __io_cqring_overflow_flush Greg/stable, can you pick this one for 6.6-stable? It picks cleanly. For 6.1, which is the other stable of that age that has the backport, the attached patch will do the trick. With that, I believe it should be sorted. Hopefully that can make 6.6.60 and 6.1.116. From 3f1c33f03386c481caf2044a836f3ca611094098 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Wed, 10 Apr 2024 02:26:54 +0100 Subject: [PATCH] io_uring: always lock __io_cqring_overflow_flush Commit 8d09a88ef9d3cb7d21d45c39b7b7c31298d23998 upstream. Conditional locking is never great, in case of __io_cqring_overflow_flush(), which is a slow path, it's not justified. Don't handle IOPOLL separately, always grab uring_lock for overflow flushing. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/162947df299aa12693ac4b305dacedab32ec7976.1712708261.git.asml.silence@gmail.com Signed-off-by: Jens Axboe --- io_uring/io_uring.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index f902b161f02c..92c1aa8f3501 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -593,6 +593,8 @@ static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force) bool all_flushed; size_t cqe_size = sizeof(struct io_uring_cqe); + lockdep_assert_held(&ctx->uring_lock); + if (!force && __io_cqring_events(ctx) == ctx->cq_entries) return false; @@ -647,12 +649,9 @@ static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx) bool ret = true; if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) { - /* iopoll syncs against uring_lock, not completion_lock */ - if (ctx->flags & IORING_SETUP_IOPOLL) - mutex_lock(&ctx->uring_lock); + mutex_lock(&ctx->uring_lock); ret = __io_cqring_overflow_flush(ctx, false); - if (ctx->flags & IORING_SETUP_IOPOLL) - mutex_unlock(&ctx->uring_lock); + mutex_unlock(&ctx->uring_lock); } return ret; @@ -1405,6 +1404,8 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min) int ret = 0; unsigned long check_cq; + lockdep_assert_held(&ctx->uring_lock); + if (!io_allowed_run_tw(ctx)) return -EEXIST; -- 2.45.2