Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1106335rdb; Mon, 19 Feb 2024 04:40:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6rlRLGHodQ7oZg75Fb+AVaeEs2CJhz1pPfzd6geeNV0ldByH+3pSEsuY6tHQ1F85sPv0NT6ua9W2YqEW2d82ycWN8X51Nw9Ys+btIBA== X-Google-Smtp-Source: AGHT+IF/uYsWaO0nnHxujmzdGTV0ASp1qPX31A/FZW09jl3VAJ9Fei5mOSErXmZtdZd+lm5ahLpY X-Received: by 2002:a05:6a20:af13:b0:19e:a574:9b10 with SMTP id dr19-20020a056a20af1300b0019ea5749b10mr8523644pzb.33.1708346446258; Mon, 19 Feb 2024 04:40:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708346446; cv=pass; d=google.com; s=arc-20160816; b=SZiZqFFJikb4hvoLN1CR088f8NOC7PHWxcYDWH7vxktIFUx9Wzs7cXkduoyhiFhMA9 dlUQXXjJuFykGsf1xCkQkWNB5a/B+dH38jv0OB/HFsB5RSooc4prwF0PeeN02EqEbxA/ MJIbDG4KqznqB+IQ7lYM1Nbp0eF2dImwDiAuJoeTlSVYmnhRAysQnV/4hr2Bk3oc4WsJ OxtkaXWY1rsEQ1zMFjK2hHhDm8lnhdIC4xKJI0fhn5B9QVb4NL+rvR7ZIgkmkwnZv0zW kf5zTnsKwBHqAECfH6HNaazRqhe2e25OqEGARGhd57q7B1xv8n3yDwVmaUdOXmcBCfUA rY6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=UJdhwMnrMlsSDhckid4cXjQK+fmYFZjzMfDxB1XFsVA=; fh=z0eU98lebYSQbnFvsTaKywImC7RroAvZyIOM9L29+kE=; b=g1OpvwUk/QM4Fy6fDmKuwTuLx7l62MHQQ48YGTtIJMLghtLBHyExSLT5A//QPOWnu5 G8q7U4SRlbRpGkMtCJ5wyAPByWovBlOfb6cL6o4/IGrmRq/pgD2a1SkMK0SaE7P6Oepy 2wHEKCSWXZhF2iAW0iOHcLyqtj9aga7CSNYmtihIybbcV3bzauk1kPiaPtxkzb1RwyPe 9wirObKHpeRtzuyrhLbCJwWfW5c8Y66zFg7ESXOLvb6xMccrRvzHglrGq345UH+P+zaG xSYwiGL3ZHfkrYiw9x7mpHcdrHm7bLRjkayyCMiP4Xh2W98CW4d97tx0GmlQDwSgL11G vaPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=L1RXsQSu; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-71333-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71333-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g4-20020a056a0023c400b006e37410162bsi3431276pfc.56.2024.02.19.04.40.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 04:40:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71333-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=L1RXsQSu; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-71333-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71333-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E9325283EC6 for ; Mon, 19 Feb 2024 12:40:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E66C2E651; Mon, 19 Feb 2024 12:40:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b="L1RXsQSu" Received: from bee.tesarici.cz (bee.tesarici.cz [77.93.223.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90E6A2E85B for ; Mon, 19 Feb 2024 12:40:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=77.93.223.253 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708346423; cv=none; b=SprqZ7u/0e0xHxcjHr5klvpenmi/3pDLOCKxgwE/Vmg6wlDPTFhqaizYtoJGd63dqH063rO9VqUtDSHXfEi3rCKBRuF/xbvC5Z1u6/EIHqEIV0cFn0LG1Slube7AHVT1LL1u606YvHKfzjavKp0s9a0N+CRIjiZwc10FJePgLiY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708346423; c=relaxed/simple; bh=07ZMRt2iZQCVacurZog+A+8XvHvFt9qPaPQy0WtWnPU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gu4orMl4ajh7a3Ob5ChNOg+pFU/VSY/xxAUFKovohdI5LOqvLmzZd3T6J9jPS7TXIbov/j8quH0k85Yhq70+e71JoWojuFZ50qr2HtFQi1v6iIvuD1GIElupdLI7EBbMPmIHdSx5tfaOcbjS3s3B4vcKozUjMWT0c4lJl8fRMRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz; spf=pass smtp.mailfrom=tesarici.cz; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b=L1RXsQSu; arc=none smtp.client-ip=77.93.223.253 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tesarici.cz Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id 303E21AE418; Mon, 19 Feb 2024 13:40:12 +0100 (CET) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=quarantine dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesarici.cz; s=mail; t=1708346412; bh=UJdhwMnrMlsSDhckid4cXjQK+fmYFZjzMfDxB1XFsVA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=L1RXsQSu2wC5yK4CdFKgeAELFMe3COQ6IK3BT7m96aA1QABI9o25oWMQDZ8EOwuPp 71BkClN6GqBUHj46AWrCXqPpkzdlewKxTWxoL6dJKoj+T8ZB36ggCn1IJloYtrjcEB HH8dykVWpvPc1wIbEGqrXTm8kqL4WHkWdMm1pHz5WLDvHgE3FB1LwFrWgofWj1EBN/ w6kFYm03w0ShNPEwY1CuKiBJs80PazLdr/IRFHWFv+OJsx0qGvlJp2z5/wDYDrHzx8 qyE8afBe39MmIcJA35NZg+FY9TVAeEEDmcYbUqETrEM4rrojMa15xZPyruImJzfpRv UMl4mryngVDoA== Date: Mon, 19 Feb 2024 13:40:10 +0100 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Will Deacon Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, kernel-team@android.com, iommu@lists.linux.dev, Marek Szyprowski , Robin Murphy , Petr Tesarik , Dexuan Cui Subject: Re: [PATCH v3 0/3] Fix double allocation in swiotlb_alloc() Message-ID: <20240219134010.5b49b8f1@meshulam.tesarici.cz> In-Reply-To: <20240219092438.GB4105@willie-the-truck> References: <20240205190127.20685-1-will@kernel.org> <20240219063527.GA4580@lst.de> <20240219092438.GB4105@willie-the-truck> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-suse-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 19 Feb 2024 09:24:39 +0000 Will Deacon wrote: > Hey Christoph, > > On Mon, Feb 19, 2024 at 07:35:27AM +0100, Christoph Hellwig wrote: > > Robin and Petr, does this looks good to you now? It looks good to me for the boot-time swiotlb pool. Dynamic allocation of transient swiotlb pools does not take these additional alignment constraints into account, so when allocation may fail. OTOH the underlying allocator(s) do not provide a suitable API, so I don't think it's worth fixing. In the worst case, a DMA buffer will fail to map, which may already happen today. > FWIW, I'm likely to send a v4 addressing another issue reported by > Nicolin with NVME and 64k pages [1], so you may as well wait for that. I'm interested. The code look quite OK to me as it is, but I assume it again uncovers something when the difference between PAGE_SHIFT and IOTLB_SHIFT is more than one (which was motivation for my initial fix, which in the end broke more than it fixed). Petr T