Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp822184pxb; Wed, 6 Apr 2022 00:46:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK48L1b9Eniq1Ol4QS6lwjpA084lip1DFSmzdr7rdxOQwsVwr+tc+BEwLBiLe0A4heJEmo X-Received: by 2002:a17:903:2348:b0:154:dd0:aba8 with SMTP id c8-20020a170903234800b001540dd0aba8mr7515172plh.51.1649231184838; Wed, 06 Apr 2022 00:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649231184; cv=none; d=google.com; s=arc-20160816; b=ABmLWOBfs8JGi+tOSnfDqEEiL6WfskFzyOE7VN1Dn0YF5Dc7FtEbyrACzxAjl4/tzw Y5rjnaVswrfn+FgHBWUalvW/1w+y9kFLnOZGAtbXvaZRT2D9uBOS2jnFwmh+x895GQA6 E7/u1ocWj8mIPZw/hZ7fUoewCyW7enkoqWmcXeY4LWZeWBfQpaDqpafOjK61JRMATyfz XTTC5J1/FQauP4on1o+1KRYA3fc+cEC9o8DNLxr1gn+sQymwTsGHuleJsX1ZOYExL5VY q+w2px0pW5nZEgKxiGKryCC17lAUDkDK8ZHWvbcJL/3j/EcM0hGBgevkcFgViyCWYxfn SBxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/P2XHjoRRxLtWDfBFTEKLwPK3NjNUTGLU+YC4EGF1Zs=; b=hlLgBCraT0Q4h6mktDWYbfkLS3CT6a/8iNu+g59tx8QjVg45pYShVk9bw/8OsCt5/x oAVF+8Y2KEar15O6uTQYv+wD/CfKG3IuF6icv1duz/skgHeex/CCZrgWhVMslnntQJzi plTFWnb7wnw60qcQInQ6PdJgWZ0r2JdRcbFwPflsApBm5EgFTU7QDfSSn2ZqSQiAxlOO oSKSamK+ix8kb2H4EWk6T3GZGS1DXyeTem/h/yBVBEi7i4b3ZUNgiOC3h6fCcQ+aAToU amNxF7pCHbIJnhbQmKbR8UOczL8XFst86hHnbI44t6mrOfZ2kLliUvIob0kmCcwgbeGN 8IJw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y29-20020a634b1d000000b003821d32f04csi14812995pga.116.2022.04.06.00.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 00:46:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C567050CB9C; Wed, 6 Apr 2022 00:14:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1841910AbiDFB0V (ORCPT + 99 others); Tue, 5 Apr 2022 21:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443698AbiDEPkK (ORCPT ); Tue, 5 Apr 2022 11:40:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B703184B58 for ; Tue, 5 Apr 2022 06:58:07 -0700 (PDT) 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 E29A461632 for ; Tue, 5 Apr 2022 13:58:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 686A6C385AA; Tue, 5 Apr 2022 13:58:04 +0000 (UTC) From: Catalin Marinas To: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/10] mm/slab: Decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN Date: Tue, 5 Apr 2022 14:57:49 +0100 Message-Id: <20220405135758.774016-2-catalin.marinas@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220405135758.774016-1-catalin.marinas@arm.com> References: <20220405135758.774016-1-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for supporting a dynamic kmalloc() minimum alignment, allow architectures to define ARCH_KMALLOC_MINALIGN independently of ARCH_DMA_MINALIGN. In addition, always define ARCH_DMA_MINALIGN even if an architecture does not override it. After this patch, ARCH_DMA_MINALIGN is expected to be used in static alignment annotations and defined by an architecture to be the maximum alignment for all supported configurations/SoCs in a single Image. ARCH_KMALLOC_MINALIGN, if different, is the minimum alignment guaranteed by kmalloc(). Signed-off-by: Catalin Marinas Cc: Andrew Morton --- include/linux/slab.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 373b3ef99f4e..d58211bdeceb 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -187,17 +187,30 @@ bool kmem_valid_obj(void *object); void kmem_dump_obj(void *object); #endif +/* + * slob does not support independent control of ARCH_KMALLOC_MINALIGN and + * ARCH_DMA_MINALIGN. + */ +#ifdef CONFIG_SLOB +#undef ARCH_KMALLOC_MINALIGN +#endif + /* * Some archs want to perform DMA into kmalloc caches and need a guaranteed * alignment larger than the alignment of a 64-bit integer. - * Setting ARCH_KMALLOC_MINALIGN in arch headers allows that. + * Setting ARCH_DMA_MINALIGN in arch headers allows that. */ -#if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8 +#ifndef ARCH_DMA_MINALIGN +#define ARCH_DMA_MINALIGN __alignof__(unsigned long long) +#elif ARCH_DMA_MINALIGN > 8 && !defined(ARCH_KMALLOC_MINALIGN) #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN -#define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN -#define KMALLOC_SHIFT_LOW ilog2(ARCH_DMA_MINALIGN) -#else +#endif + +#ifndef ARCH_KMALLOC_MINALIGN #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) +#else +#define KMALLOC_MIN_SIZE ARCH_KMALLOC_MINALIGN +#define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE) #endif /*