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 DD2A1C38A02 for ; Sun, 30 Oct 2022 08:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41B046B0074; Sun, 30 Oct 2022 04:46:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CB376B0075; Sun, 30 Oct 2022 04:46:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BB3A6B0078; Sun, 30 Oct 2022 04:46:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1B0876B0074 for ; Sun, 30 Oct 2022 04:46:08 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5FDF616094F for ; Sun, 30 Oct 2022 08:46:06 +0000 (UTC) X-FDA: 80076983532.03.5792BAC Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf22.hostedemail.com (Postfix) with ESMTP id CF7EFC001E for ; Sun, 30 Oct 2022 08:46:05 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 8D1D068AA6; Sun, 30 Oct 2022 09:46:02 +0100 (CET) Date: Sun, 30 Oct 2022 09:46:02 +0100 From: Christoph Hellwig To: Catalin Marinas Cc: Linus Torvalds , 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: <20221030084602.GB5278@lst.de> 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: User-Agent: Mutt/1.5.17 (2007-11-01) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667119566; 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=Uao/+VAE0sYb/QJBjOUPGUFTgbSd7KfCpNC2AdEMHqY=; b=a5ZksnjY+VRjvghkOxRZdMTB0+gOmZQw77Acb5NhliuHFblixvCE/oe0Ofys8klyVTDUQW koZNm5EpLTe2cYDc6MJNnnlPiy3sZzBOaStsNdN030vFPq+jwFYnJ/uX0m+hqdG208mEIW cNaRFTv9fbT4+2HwKYYlnfNBpP/PUdA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=none (imf22.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667119566; a=rsa-sha256; cv=none; b=ZYsL1IrxNxyTF5TymIJljbHg2pl1qItFkgrr+oZQxuz9zLSrxlEjHiqlNYW5ihztxadxcL fkVT4JruEIbQnWXXRP5U+L2Bn+7+ccbrdYjD49kcd+WNk5NQDfF6fAsaxjiWEXSTt3/RxC XnwtBd23wZajJFzLzPf79vp4kzKedtA= X-Stat-Signature: 8ib9mwxfgm4hun71gkgoobe4ytgb1ayf X-Rspamd-Queue-Id: CF7EFC001E X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; spf=none (imf22.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none X-Rspamd-Server: rspam04 X-HE-Tag: 1667119565-403834 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 Thu, Oct 27, 2022 at 11:29:48PM +0100, Catalin Marinas wrote: > 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). The other thing would be to check the dma mask so that we don't end up bounce buffering again.