Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1156976rdb; Fri, 1 Dec 2023 08:22:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHY9y4qVYaLo8QncSGTrDyeJFZuGhDxN+L1DVCp7RsUA4ttVBTSDDfxUOw8K/MY3MxpYeU5 X-Received: by 2002:a17:903:54d:b0:1cf:b413:8baa with SMTP id jo13-20020a170903054d00b001cfb4138baamr27944717plb.25.1701447722672; Fri, 01 Dec 2023 08:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701447722; cv=none; d=google.com; s=arc-20160816; b=jp6ZxhpKMdoNbLKhcQgQZ+Zd/pfXz2yWuUFkU19fCFhho7ncUpJgODbhuJ0W6h6J7z U46j+BmboE+V30H4n1SYFO2XkEOPuM41YVp52VNKn0A+j9VPXtig2AJ03aYbNsTS1fP4 x6w3eEbHxL6hZK6wsCH0dSeLpM97jm0nqGHlSCW8VHSfXgEIonkgmZHEPYEmwc/XGla6 wLtNz0NJQ+DQyxmw1IGje9fR7qSsiy7AaX99pmVvVeb3h3YnGndaeCJkMIE7hk3qLHQG DcYvOBmc94SzrqlSdRpamNHN9JZuUuc6QaalkPs/AuQ8/kmnfYjFMTJMprfjYknR5snm 0fOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PG94C7GQvWecavScRE1BBi0ICXxFKKszVsYl5r4vfvY=; fh=AM70mB4ta12lishvoPoXqLDE3onEIIVSZwD2KzKnE4o=; b=ItI1KlnrLmr52uXGBvNi3eUad5FepwIRJYwafWUM6R/maKM4zZNygPX8qrbGhKrmlW fk8aZMDpQVVkdSUbwL5jOdXbb0MW7/PDIHo2HG2DGztqepDLJ59noNEyHqcJwd4921Ar z/eKNUvhb6yIQuCUIFiGtOEc5RGUovcrC88KhoNKGVabfKxR3ID57JiV7paWKEgLKe8P gPoRc2XMjd9E1f8w0lRHGxK7eRF5/IzH4Qyp4lj8HYE1/nc2xmLmF9r6jPssZVam89kX YfTJX/4izF01PMfEnhy9+9BhLTQzBx9NxY5AjDVCJOMNC6qSGluNoQ3Y6TBfQGukE1eL QWvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v8-20020a1709029a0800b001cc2ef72ab2si3390366plp.68.2023.12.01.08.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:22:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id F084C826ECAF; Fri, 1 Dec 2023 08:21:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229977AbjLAQVh (ORCPT + 99 others); Fri, 1 Dec 2023 11:21:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbjLAQVf (ORCPT ); Fri, 1 Dec 2023 11:21:35 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id DA08CFE for ; Fri, 1 Dec 2023 08:21:41 -0800 (PST) Received: (qmail 291592 invoked by uid 1000); 1 Dec 2023 11:21:40 -0500 Date: Fri, 1 Dec 2023 11:21:40 -0500 From: Alan Stern To: Ferry Toth Cc: Catalin Marinas , Ferry Toth , Christoph Hellwig , Hamza Mahfooz , Dan Williams , Marek Szyprowski , Andrew , Andy Shevchenko , Thorsten Leemhuis , iommu@lists.linux.dev, Kernel development list , USB mailing list , Robin Murphy , Will Deacon Subject: Re: Bug in add_dma_entry()'s debugging code Message-ID: <5093ce37-047e-4aa8-a9e8-2978da9d734a@rowland.harvard.edu> References: <736e584f-7d5f-41aa-a382-2f4881ba747f@rowland.harvard.edu> <20231127160759.GA1668@lst.de> <637d6dff-de56-4815-a15a-1afccde073f0@rowland.harvard.edu> <20231128133702.GA9917@lst.de> <76e8def2-ff45-47d3-91ab-96876ea84079@gmail.com> <5425cf42-0f49-41b5-b26d-1e099d5bdcc2@elsinga.info> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5425cf42-0f49-41b5-b26d-1e099d5bdcc2@elsinga.info> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 01 Dec 2023 08:21:52 -0800 (PST) On Fri, Dec 01, 2023 at 01:17:43PM +0100, Ferry Toth wrote: > > A non-cache coherent platform would either have the kmalloc() > > allocations aligned or it would bounce those small, unaligned buffers. > It would? Or it always has? > > So it doesn't seem right to issue a warning on x86 where kmalloc() > > minimum alignment is 8 and not getting the warning on a non-coherent > > platform which forces the kmalloc() alignment. > > If *all*non-coherent platforms implement either correct alignment or bounce > buffer, and on (coherent) x86 we get an WARN, then it is a false alarm > right? > > That is exactly my question (because I have no idea which platforms have > non-coherent caches). Don't forget, not all DMA buffers are allocated by kmalloc(). A buffer allocated by some other means might not be aligned properly and might share a cache line with another buffer. Or you might have a single data structure that was allocated by kmalloc() and then create separate DMA mappings for two members of that structure. If the two members are in the same cache line, that would be an error. Alan Stern > > If we consider the kmalloc() aspect already covered by bouncing or force > > alignment, the DMA API debug code can still detect other cache line > > sharing situations. > > Consider? Or know? > > If we know, and we can not easily prevent false WARN's on x86 it could be > sufficient to change the message to "possible cacheline sharing detected" > and add a line that "DMA_API_DEBUG" should be disabled on production > systems. > > And while at it, we might be able to fix the missed real cacheline sharing > mentioned by Alan: > > ?"As a separate issue, active_cacheline_insert() fails to detect > overlap in situations where a mapping occupies more than one cache line. > For example, if mapping A uses lines N and N+1 and mapping B uses line > N+1, no overlap will be detected because the radix-tree keys for A and B > will be different (N vs. N+1)." >