From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (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 9FC8722A817 for ; Thu, 16 Jan 2025 14:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737036818; cv=none; b=eO2g8BzCIh5JQF3GKt+8dH0Iw7SsFS8qxmB3Bqltwxb5bBBecimSxtE4R7YwtaYGTLH16/+3ad6vCs4W/T7dXh9EKkXU2R/3MC+BMYa4YKZ/Rdhs5BlEgNZgq9foWArLIZXEkO43IPIbWfrJBL+Dvi+dtl3eTzQh9i4jV8L0yRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737036818; c=relaxed/simple; bh=jklf77cQvAqZJ/Tl2hKIbP4y9cxOBSQcS1UsSlX3Nfs=; h=From:To:Cc:In-Reply-To:References:Subject:Message-Id:Date: MIME-Version:Content-Type; b=TFHH5NG7nC3D+pL1TT0nQnS8F8TBBO7DvNfRlFdwPJIpTq1O1mBtPWeP2RB1pF13jqeccz9oJNpdmmCMJ3hpCvaKwbSvOPtfEhfVFbzNzr8ZnQDjYDuElTvu/IExs/h+8cZpnMTwFi9gf+YiB81lImpVKzBqHnV+x9v9nePH15o= 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=TV5QrHkQ; arc=none smtp.client-ip=209.85.166.43 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="TV5QrHkQ" Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-844cd85f5ebso76945839f.3 for ; Thu, 16 Jan 2025 06:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1737036815; x=1737641615; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:date:message-id:subject :references:in-reply-to:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bL/GyekQBgTf+5p3mdaN9UaIM6BQ+hf2PyMsVTBo5MA=; b=TV5QrHkQRnJXgeBPdsFrVf7c8PHiOa7XiU+cvdKc0AVbWILSqtYm9L+WxB3roZJ27M VDkhlZEnVQF0ICcPdjfxwuAN65mkPBm0oLUM99HW7QRyQKFfnamPNVJHKJKQBRkIGvKz shBJ3slK+8EOPcW8YbluyXAajSxZQQvhcB3UhkHEKdf9nU/GjmYWl/JLXByct2Bub0qC pZR3pFKq/8b7/6YmiHe4AwGs1259IC8lWKFyMLVBU3edrJbT6aYrGap3tO7hIWc4yay/ SqoDGdMaFRexyGLV2k0Pc1incpeQ46aSRtAHbgVYiicxs4BAElUs8EjCZNZA7S13kkaW rHhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737036815; x=1737641615; h=content-transfer-encoding:mime-version:date:message-id:subject :references:in-reply-to:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bL/GyekQBgTf+5p3mdaN9UaIM6BQ+hf2PyMsVTBo5MA=; b=rHTr2OG5YAyxf47n1lVB4hgfNJShASzUBRFHjaTVTsGykBcfclEZ0sMYDcPNe0cFwK PO+QmdkwNGSXfEgrBL34ASkcjrsgdC40uWrS+WG33E/k3spsr656yWCVEjoaYO6hk6c+ lewYgS0C5he0mghBtjkIjVcU21nO0VTdQRc6Y7hnPFyguR40EB0fxchveRU/XaGF6YKb ptURADeEjY+Z8gI4yvYWKj5qu4wDP6jY4V0LJ4Ak7v7XRLvZVs434FDbrAAQxXPA6+ef 1bPGGCwr6VEmWwZxJOAKciBUMOoBIj75cKokDyTC4ScBg9g2gO0KlJT/nHsf/uueHi3L CMlw== X-Forwarded-Encrypted: i=1; AJvYcCXxa9Mlmm3KoypLYEmtj5qOCNYhpMgmXxYA/5szp34Z7Fjr51jQAhVDumcWFLah7Ct4ifGkwZZuhkt0RS4=@vger.kernel.org X-Gm-Message-State: AOJu0YzvAn1qJWBjJyhRAGuGOHe8k0D5SY1cKzgjgO1Q7/1F6s8sEC1j VcPsyjOhnhY5g20UKWyQcZFgP6P/WqExcZD853ZxNyvucxnAwGzWaFBRVH2pKp16Kfecn1T1KvH Q X-Gm-Gg: ASbGncsy0t/jDZdduUoUlNZiRhoIRIPjM5hjcWdIY7spfEb1bYOOMQIB/9vLqO/K+uf GaM+RBJayYP5a8Ftwi6QiNeoPIN268ZkGhugOMDH01D+ChzNASZxNE4x/v8Pg6e+NFgzSI/NM5Y cMLX7MTcpP51lEe3vwMlm/WtrvKGKp2AaIKiadmBk6FbJBdL7fiXIsjCUhgo9BFQoR3DDWC52wG 6Yb2Li3VysyOABDhRsAnZnEjP/lH8TM4KasjbuYSVEwm4o= X-Google-Smtp-Source: AGHT+IHTn49Ss1T1Jwr6CpOINfiGp/sUX6BBjtUgCBEI/nGq12Ta78Qu4Rt/JBsWOVPXYBhsmlOXAA== X-Received: by 2002:a05:6602:7512:b0:84a:5133:a257 with SMTP id ca18e2360f4ac-84ce0036d8amr3335085539f.1.1737036815443; Thu, 16 Jan 2025 06:13:35 -0800 (PST) Received: from [127.0.0.1] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ea756bae75sm36808173.132.2025.01.16.06.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 06:13:34 -0800 (PST) From: Jens Axboe To: Pavel Begunkov , Jann Horn Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250115-uring-clone-refactor-v2-1-7289ba50776d@google.com> References: <20250115-uring-clone-refactor-v2-1-7289ba50776d@google.com> Subject: Re: [PATCH v2] io_uring/rsrc: Simplify buffer cloning by locking both rings Message-Id: <173703681418.10865.3728594442935840848.b4-ty@kernel.dk> Date: Thu, 16 Jan 2025 07:13:34 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: b4 0.14.3-dev-14bd6 On Wed, 15 Jan 2025 21:26:03 +0100, Jann Horn wrote: > The locking in the buffer cloning code is somewhat complex because it goes > back and forth between locking the source ring and the destination ring. > > Make it easier to reason about by locking both rings at the same time. > To avoid ABBA deadlocks, lock the rings in ascending kernel address order, > just like in lock_two_nondirectories(). > > [...] Applied, thanks! [1/1] io_uring/rsrc: Simplify buffer cloning by locking both rings commit: 8865af703c087b8bcc2fdd04b6a93d3cc0fb0e9f Best regards, -- Jens Axboe