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 89B30C38A02 for ; Fri, 28 Oct 2022 09:37:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8DFA6B0072; Fri, 28 Oct 2022 05:37:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3DF36B0073; Fri, 28 Oct 2022 05:37:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B05016B0074; Fri, 28 Oct 2022 05:37:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9D6E46B0072 for ; Fri, 28 Oct 2022 05:37:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5AE47AB1AC for ; Fri, 28 Oct 2022 09:37:23 +0000 (UTC) X-FDA: 80069855166.17.B014E80 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id E692120008 for ; Fri, 28 Oct 2022 09:37:22 +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 dfw.source.kernel.org (Postfix) with ESMTPS id E16396271D; Fri, 28 Oct 2022 09:37:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA9E8C433D6; Fri, 28 Oct 2022 09:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666949841; bh=QGO8DftAisCJD9dq7Tl91Z+LoDywYwRn52bKdNeVUbg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HUqZ3XPqfU2fx0CEKqLIs9jQwIB+Uk0BSvH/XompUZ0jOCZAq4tYDCd+ViJU1CQld 9F5ww0I2CnMunemaNChh0XSnVJm3OpMP+nsSJLmTNeSj6IJ/+r4zRbrBZq2t9NA3Ey t0oRedSeUgm4cddcbeRlQppSs9OS0hdyTe6a8bRM= Date: Fri, 28 Oct 2022 11:37:18 +0200 From: Greg Kroah-Hartman To: Catalin Marinas Cc: Linus Torvalds , 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-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=HUqZ3XPq; spf=pass (imf03.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666949843; a=rsa-sha256; cv=none; b=izhI9wOizh65MzAlrMTimdt1UnM+1TXtF75NamTv7+ODirAzwMKm8JC5qxuAs6nbvazaVc Gq7IznfJf1ml5ZJ5UNbmBQB0IXN7rLGQ7ygUn/lbzb5xJ9KLEVrKWzlaN8n0m0F+X+YsWD hpF174nlzqNkyn7q5xXeOEFHNyBHP5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666949843; 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:dkim-signature; bh=Bvsdw6B6ErYcYBtqdrICy8XN45FcmuEevy8zqETyzFg=; b=PKluHRXQusDJK+x7QGd8Yxwkc7ckDE7UyD/pGtq61G4JT9MGTcWp0fIBlAM+VvPj6T4ggp RTOpb1WOXYqCpauxJC9xzKKLPzIO2qnb4Wa56TSyPOZyvFFjDmYcsuDZ9qu+A7VC9xqbUo TpD1Dnxs+w7mHUR3dssVvRwMHtifyZU= X-Rspam-User: X-Rspamd-Queue-Id: E692120008 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=HUqZ3XPq; spf=pass (imf03.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-Stat-Signature: eakibrqzjyth7ftiede5yuqtg7rdjotp X-Rspamd-Server: rspam10 X-HE-Tag: 1666949842-596498 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: > 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. bouncing? sparse is your friend here, here's a tiny patch that if you apply and then build the kernel with sparse will show up all the USB driver changes that are needed. (note, sample code only, does not fully work yet as there are no .c changes made). I suggest we add something like this now, work on fixing up all of the drivers for 6.2-rc1, and then you can add the backend allocator changes after that. A few rounds of 'make allmodconfig' will show us the places needing to be fixed up and 0-day will help out with that as well. Yes it's a lot, but it gives us a fighting chance to do the right thing going forward with regards to knowing what "type" of memory needs to be allocated. thanks, greg k-h