From patchwork Mon Jun 12 15:32:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13276872 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 189EAC7EE2F for ; Mon, 12 Jun 2023 15:33:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B28F18E000B; Mon, 12 Jun 2023 11:33:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD94F8E0005; Mon, 12 Jun 2023 11:33:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C84F8E000B; Mon, 12 Jun 2023 11:33:22 -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 8F3758E0005 for ; Mon, 12 Jun 2023 11:33:22 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2A5E1C0280 for ; Mon, 12 Jun 2023 15:33:22 +0000 (UTC) X-FDA: 80894489844.17.DBBA25F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 545E510000C for ; Mon, 12 Jun 2023 15:33:19 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf05.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686584000; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+tCZdLyULJntPoisjA5Kvnhf6MMZALveOM8+g4gPdAo=; b=8DJrJiZr1tyfL2l0JU0uw2NrBI09oM4oIQSbsbx5vYJIGCXIBD2lEsWE9iuuKowA0OddAT aNuKw0B0ri5t13+r3ywMB8G8/FDOiF6iaal3rPglb3kWQgQKJVGN6SrHgZEiPuZWRo4ikc kTcmzNBqdIWLp4G1AgNSieWClU04kys= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf05.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686584000; a=rsa-sha256; cv=none; b=Lm+pHzoJ2/cTOS5Rlm1FFS/PO4bMNfr+NZ37FfJYIqV86lN3zduO/CbMRsjet2v+TpV89Y AQjwpZegHdDrN75cGsdNZ4vfpNX2q7oPUAMGpaNKukmEbq0of5zc4ApqK66NVbSEybO/p8 zjrxqh1n6YRuVVF46VYsW5nhMW/QqXI= 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 4DE23618D8; Mon, 12 Jun 2023 15:33:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD3B6C433A1; Mon, 12 Jun 2023 15:33:14 +0000 (UTC) From: Catalin Marinas To: Andrew Morton , Linus Torvalds Cc: Christoph Hellwig , Robin Murphy , Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Jonathan Cameron , Vlastimil Babka , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 16/17] mm: slab: Reduce the kmalloc() minimum alignment if DMA bouncing possible Date: Mon, 12 Jun 2023 16:32:00 +0100 Message-Id: <20230612153201.554742-17-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612153201.554742-1-catalin.marinas@arm.com> References: <20230612153201.554742-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 545hp5zr848f5cgwd6pxtoh8ihbj5idk X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 545E510000C X-HE-Tag: 1686583999-111584 X-HE-Meta: U2FsdGVkX1+gl8udmUKj5siwnIpdy8pVmRX228xWYue1oDRsmIKMwY8JRBxRShNFZXwtK/y/AlbsgncspKyIGqAG/L4/5OEfdoQmI3cIjRW/VeS3fEm6FcjUfK91sION0qyCx4S30I9/duf8Rv8jWAd/yoTCdUSQx7FAxHe7xGE7+umDDMIqeI0c+kGhpKtKG5h5tG3HyDLnDPoW6Ih/B0hBEHtypB4vrr3or1E7K7y7fS5no5xABMZI4R6jEiNK90mJXuXyzxT12200Yh6SwAFlqXqyq5vbZTEES6ONtwzV73QsJiJ94rwAbhuaNsWrnm8alGkZ7yfOpt3kbFmdGbgzQWIOLTri/FNZWJAGYIpUphmIUqXR6xKf+3fk0wFGbMhoQCmUOjoVD3KOIeISNDID7cf4MWgQ/NRG9u3/m6BiqY09Qg/EL+H6HpC5BOKa+Fu7Fc8v5Ypi9qYp41Ql/RBMZB3s4eXgwf+iqA5Hq90g9hpE+EgmkCARvN13OaeFe9l9/vBg28ST01P5Od41Fa3AffPTqlRDJEDRlgbdcS8xIoRfcRyqDUs3HCxl7QeDu/oB2eQUpqfHmPP2BGMIssIUAyLVRMwCIntF17q9rTlv1qoFohkJDH1PJsC0XNzNXTwwKD76kNNKJkR0V9HSqUzDPRPn5rc4kZtYSpLeO77q0tVgfx0eeGJ95gvry5OYmx2qZ3y+CA2OqwBqhuk5fR5y3+TtAz3tcp9bn0PtPYIIzBGkbe/GA+ABoX+UsPF1xP9tR1riuAo+7Ds7pKIKOHiMnXgbqnfyv86woK5/J0kjBlAh9wRl0rSBUIMSXAbx4GF2gKKlUKkEnHC2OTwXRt8kM6ak8cWUBjyFvNJWKT9GgBADG58o6d1OX9XlYBI7eGWAKMMwhamZsYB+9O7Hn37boAnKsAfDHEiRMCNqFNwtgIFxW/nH0U4tY7SRWMy3yrBbfYow7zAh7ro+Sfy vpkGArct usU9XLxR31iiidQDBrVDxxFJGB3qXY476Ttr4ZQu0U+NpoHh7jcCceck73Abk/1KFWq/rT9I9HLVl4j/HnX8TfeEtFuNP2EXMO/dyCp5Zh1GxpMj3mVq8dMpVIsjq3Tl/PukroRz+TEcyj408NeSnj2N2ERLGeq4TGy57J4eQ/LHUe9VAp2AQ0JFiSVq8p22dg6J+pxmc1g6pzFdv4Vfwy8s5sKID18vJGdLS2yEvsRLv4SSi3+ymIE8OcW5IljUoMyW9I7G8GU/WKDFGRWyOgC/N+zOFyMahdIYrmt7Af+7pog6VE4VOxXB/g1JlnIZABDwp1hHbe8kPcchbLJYjFaF/4PndNxY8OL8tSUDoqCuBr+thf2xWXG8USSJ+8KoRye9PD/E6JrXKv2iv/4PBbDBeNvlH7ZJjL7IRwMTQdAS4ykJxC2ZModAMbN+tOLOYIeqlO4omT+cdp7iT+fRbiBF0J0XZ1YT+NXf/4D1+ecBZngBK9Dfn2F++iJBQYR+vv7EcOLez4Mt5mi/E8bmC3MlocheC+Y2tT7J4X2URIw6dPH8= 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: If an architecture opted in to DMA bouncing of unaligned kmalloc() buffers (ARCH_WANT_KMALLOC_DMA_BOUNCE), reduce the minimum kmalloc() cache alignment below cache-line size to ARCH_KMALLOC_MINALIGN. Signed-off-by: Catalin Marinas Reviewed-by: Vlastimil Babka Cc: Andrew Morton Cc: Christoph Hellwig Cc: Robin Murphy Tested-by: Isaac J. Manjarres --- mm/slab_common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/slab_common.c b/mm/slab_common.c index 7c6475847fdf..43c008165f56 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -865,6 +866,10 @@ void __init setup_kmalloc_cache_index_table(void) static unsigned int __kmalloc_minalign(void) { +#ifdef CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC + if (io_tlb_default_mem.nslabs) + return ARCH_KMALLOC_MINALIGN; +#endif return dma_get_cache_alignment(); }