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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41B97C433F5 for ; Wed, 6 Apr 2022 00:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EKOeF8gR5lWQPEZgKABoPKemZ0p65ogAz6Y1YpOKypg=; b=nO3YdqJOl95WMx C62KmuUieAIY0bbWXaAaUYOwSr1AD6GTr033/HYCSQKTs/cpCOSqHYANjPYayRKrgI+YHmnIfTMkg +AUqj+FjASOr4/DZYI4K10Fe0rQ1jsz6aR9CO34klRCIk66hFHjHPVPjqAcFDLvhH+M1eeWk3j1+W 4bvL18PyuokbC/osFJpQD75K1IWhwoYhDgGfX/giVRQsqGpzYvVPqSB1I0rEiG4Pf5blCd+mx1iCJ 8cwuOK8EiW4vJ5gdHqB+Drh7yCN+cJVZIaiWdn+52tmLv8wtNptrfArO0H7bS3wx2NU4C5MW0Biu3 4NGbRKfOWPNZrZlrl5rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbt5A-0033hM-S3; Tue, 05 Apr 2022 23:59:32 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbt57-0033gZ-Ue for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2022 23:59:31 +0000 Received: by mail-pf1-x42a.google.com with SMTP id x16so922285pfa.10 for ; Tue, 05 Apr 2022 16:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+pKWlLT8OBUODk8YNvFLSMhBfA/iojejnVtSVsASRAk=; b=YXBL1QT1SI7i+Bh2c/Dc8P9v+q9zH8NYCPf0bo/FnxGd06vvrjm+O0FsoJBk0fLEbN TaQbFXB8NNZ5nHIWMYME2kE1OjLFWBJxGzKfqq81r6V+XTnnibuYyxUjQDDC1SvWvxZh ZmGZTT02QcLWDCHdVr7gAerq/tjYtPmAx7wIvPAAVsLt56zt8AXu8yuNmg1JanvGP+x9 vpdZfL07mSEahEQOb/pPxEelhv2k4QH8DOCgTRmA8ssHD5rbeiGZ7EDjvLzqiSTf81Z9 c1S5njgI/BUvyLBAbpVZNDPhZH69GLSVdZ+WHHdLvA57R4MqqDkvpKVvRvDnzLutqjII 7cqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+pKWlLT8OBUODk8YNvFLSMhBfA/iojejnVtSVsASRAk=; b=Quu9yfP9qQ0CY2aDL0EWGMgIhrUONbIlDTFtXmS1WdvcHN6pOgENGgkY9ykEMjYA2T ISq65uzrFAMROz9nfTiOI4ylBFttgs7KyXJjjBDlQHbQLpQvJ2cOtArcrpeJKGogkmpE Lb+FF3xuM8Ag06L1x1K2nMfIBHHORMW7KGv/ENaaOmauhCZq/w6HiMFbELMWJhBWt70L x/rOUYq5+ZgPcvPcjtOmJIbsdTNHgiBtqlQ3v4U+S/FW2xTiA/F8/JIJN/pEXoDeLjWI +KL86pJmzgJri8vf6XLF16zQ6Havvz9Q/UHeOrctpYk0S4sO4I58scWed4ClHZAILI75 c2Vg== X-Gm-Message-State: AOAM531JB8jbm2TQXBH4YmZ7ImPDYnWfM/Pjv2CvCXOBiiC15Fwz5pY7 f+Szqo79EDT0/xzix8C1jKY= X-Google-Smtp-Source: ABdhPJwr8lCDx3qo0NcIt/6xVkEHW9WW1AsHFqpf8jte3twaF6gnt2JTp/x1cETmV5k6VXwhRd9jwQ== X-Received: by 2002:a05:6a00:130e:b0:4cc:3c7d:4dec with SMTP id j14-20020a056a00130e00b004cc3c7d4decmr6050466pfu.32.1649203168112; Tue, 05 Apr 2022 16:59:28 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id s135-20020a63778d000000b0038259e54389sm13949197pgc.19.2022.04.05.16.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:59:27 -0700 (PDT) Date: Wed, 6 Apr 2022 08:59:18 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Catalin Marinas Cc: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, cl@linux.com, vbabka@suse.cz, iamjoonsoo.kim@lge.com, rientjes@google.com, penberg@kernel.org, roman.gushchin@linux.dev Subject: Re: [PATCH 01/10] mm/slab: Decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN Message-ID: References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-2-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220405135758.774016-2-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220405_165930_042767_B524EAED X-CRM114-Status: GOOD ( 29.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Apr 05, 2022 at 02:57:49PM +0100, Catalin Marinas wrote: > 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. > [ +Cc slab maintainer/reviewers ] I get why you want to set minimum alignment of kmalloc() dynamically. That's because cache line size can be different and we cannot statically know that, right? But I don't get why you are trying to decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN. kmalloc'ed buffer is always supposed to be DMA-safe. I'm afraid this series may break some archs/drivers. in Documentation/dma-api-howto.rst: > 2) ARCH_DMA_MINALIGN > > Architectures must ensure that kmalloc'ed buffer is > DMA-safe. Drivers and subsystems depend on it. If an architecture > isn't fully DMA-coherent (i.e. hardware doesn't ensure that data in > the CPU cache is identical to data in main memory), > ARCH_DMA_MINALIGN must be set so that the memory allocator > makes sure that kmalloc'ed buffer doesn't share a cache line with > the others. See arch/arm/include/asm/cache.h as an example. > > Note that ARCH_DMA_MINALIGN is about DMA memory alignment > constraints. You don't need to worry about the architecture data > alignment constraints (e.g. the alignment constraints about 64-bit > objects). If I'm missing something, please let me know :) Thanks, Hyeonggon > 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 > > /* > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel