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 CDA19ECAAA1 for ; Thu, 27 Oct 2022 22:29:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D7D36B0072; Thu, 27 Oct 2022 18:29:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 188136B0073; Thu, 27 Oct 2022 18:29:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 077FA6B0074; Thu, 27 Oct 2022 18:29:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EF7E66B0072 for ; Thu, 27 Oct 2022 18:29:57 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BDC851C5E95 for ; Thu, 27 Oct 2022 22:29:57 +0000 (UTC) X-FDA: 80068173234.06.3749DCF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf23.hostedemail.com (Postfix) with ESMTP id 4F382140006 for ; Thu, 27 Oct 2022 22:29:57 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4F8CBB8282A; Thu, 27 Oct 2022 22:29:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E958C433D6; Thu, 27 Oct 2022 22:29:51 +0000 (UTC) Date: Thu, 27 Oct 2022 23:29:48 +0100 From: Catalin Marinas To: Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Christoph Hellwig , Isaac Manjarres , Saravana Kannan , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 2/2] treewide: Add the __GFP_PACKED flag to several non-DMA kmalloc() allocations Message-ID: References: <20221025205247.3264568-1-catalin.marinas@arm.com> <20221025205247.3264568-3-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666909797; a=rsa-sha256; cv=none; b=herPRFIKaE7v2wgX8F0J+Fk1mr1a7bwiuoSa8yCu1RKrdAhjzwOLUz9t9POELHPmEMXidn ZwhztKRDBTpEQUIELntQ/cp7DK7XHHsaGLR5XyUFYG36H6+Ly4da83UiyUQOvXocZppzcp HHfRk8a7YaCjxQvxGsKkPNABDIVYOH4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666909797; 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; bh=DX2BS7nRd0BfTBoeOR92zv1RY+FjhOMca4SzDNAHpeU=; b=YHfDZ6fR7hCIhkttmyyMDdXWkjTRdzcHkS/eW9+H0eUjwe2/WvUpETFB8rkGmo5EBiYxUU 6E66sJo8aGhzSJHCzdW2giwfrehFsqqLr0fXfkfUbu81Xr1mEVSiaSWDetMI4sY1cdAd9R W43XM8gLkY/MfGbVYxbpaJ+1YMzuuRY= Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4F382140006 X-Stat-Signature: ksex9jjbpkrjdi3yr4r376r9g8gpkrfa X-Rspam-User: X-HE-Tag: 1666909797-433114 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: On Wed, Oct 26, 2022 at 10:46:46AM -0700, Linus Torvalds wrote: > I think we should just stop bending over backwards over this, and say > "if your DMA isn't coherent, it's on your driver to mark its > allocations". [...] > That hardware may then be one of the one-off strange cases, but those > people with their masochistic tendencies can take the pain of "oh, now > I need to mark my broken driver with dma_alloc()". The driver is not necessarily broken. The same small kmalloc() in a USB driver can work fine on a fully coherent platform but if that chip ends up on a SoC that doesn't support coherent DMA, it needs bigger kmalloc() alignment. The driver could check if it's coherent but that's more of an arch detail that the driver shouldn't care about. If we define a new API like dma_alloc() and drivers don't use it, that's when we can claim they are broken. A further optimisation would be for dma_alloc() to take a struct device pointer and check dev_is_dma_coherent() before deciding to align the size, though this doesn't work when the allocation place cannot tell the destination device (e.g. alloc_skb(), though these buffers are cacheline-aligned already). Reading up on coccinelle to see if I can make this transition easier. If not, I'll probably go back to bouncing. -- Catalin