From patchwork Thu Apr 28 15:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12830981 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 B66B5C433EF for ; Thu, 28 Apr 2022 15:59:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94F3A6B00B6; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A4FE6B00B5; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 758736B00B7; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 59D996B00B2 for ; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 305BA622F7 for ; Thu, 28 Apr 2022 15:59:46 +0000 (UTC) X-FDA: 79406748372.07.6837276 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf23.hostedemail.com (Postfix) with ESMTP id 9828C140057 for ; Thu, 28 Apr 2022 15:59:38 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1651161583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+aMYyx9JbjctX7IKCAz71I7UvEWhb1H0O2/pEdg011c=; b=Jrko63r6s51mjDxZWE6hvaqb98Yrb2UoUcte3KUc/vRV6Md+Z/9eBqzdF/KYUvA5PaZCLb 0Td+pe5Ctd5RZKsYeFZtwSIfDiKv1HPtf+7irvWx1hK/ug3JaKyA1hDI3AEKdDirT4jGlQ 8KOM/oj8IRb5BjH2u2re/seuCQR/KWY= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Peter Collingbourne , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 1/2] mm: slab: fix comment for ARCH_KMALLOC_MINALIGN Date: Thu, 28 Apr 2022 17:59:39 +0200 Message-Id: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Stat-Signature: 3y3nfar5izye9md64j1gocoxrywgfw3x Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Jrko63r6; spf=pass (imf23.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9828C140057 X-HE-Tag: 1651161578-849332 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: From: Andrey Konovalov The comment next to the ARCH_KMALLOC_MINALIGN definition says that ARCH_KMALLOC_MINALIGN can be defined in arch headers. This is incorrect: it's actually ARCH_DMA_MINALIGN that can be defined there. Fix the comment. Signed-off-by: Andrey Konovalov Acked-by: David Rientjes --- include/linux/slab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 373b3ef99f4e..8cc1d54e56ad 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -190,7 +190,7 @@ void kmem_dump_obj(void *object); /* * 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 #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN From patchwork Thu Apr 28 15:59:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12830980 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 0F052C433F5 for ; Thu, 28 Apr 2022 15:59:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6541C6B00B4; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62F466B00B6; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D0BE6B00B5; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 3CE116B00B2 for ; Thu, 28 Apr 2022 11:59:46 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 1E4B3122347 for ; Thu, 28 Apr 2022 15:59:46 +0000 (UTC) X-FDA: 79406748372.13.1FDF883 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf08.hostedemail.com (Postfix) with ESMTP id 6941F160055 for ; Thu, 28 Apr 2022 15:59:38 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1651161583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zwt1Sx0pGDDP1QIiEEqqtc28lIMUpPSKVSQzvDDcrGM=; b=Mq2yqVxnX5D6a3Z+8iHVLmG47adlPN+nsa+tNRylOKiQ5DMBIoi9QNMIJ6U2jEe08yPZlk R2JK+OjIkZygJjuvdv3k/k5U0iH3M9dwvX618NHg9W6UBlVrFod9G9y7bBZR6lZPWi4VfA KSTFRMbkHn8kXFbU5TNGdZRobG8jaY8= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Peter Collingbourne , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 2/2] mm: slab: fix comment for __assume_kmalloc_alignment Date: Thu, 28 Apr 2022 17:59:40 +0200 Message-Id: <84d8142747230f2015eaf9705ee7c2e1a9f56596.1651161548.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6941F160055 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Mq2yqVxn; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-Stat-Signature: p49oeh4xf9ej5f1ndh1tb9ktmac6rm4m X-HE-Tag: 1651161578-396899 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: From: Andrey Konovalov The comment next to the __assume_kmalloc_alignment definition is not precise: kmalloc relies on kmem_cache_alloc, so kmalloc technically returns pointers aligned to both ARCH_KMALLOC_MINALIGN and ARCH_SLAB_MINALIGN, not only to ARCH_KMALLOC_MINALIGN. (See create_kmalloc_cache()->create_boot_cache()->calculate_alignment() for SLAB and SLUB and __do_kmalloc_node() for SLOB.) Clarify the comment. The assumption specified by __assume_kmalloc_alignment is still correct, although it can be made stronger. I'll leave this to a separate patch. Signed-off-by: Andrey Konovalov Acked-by: David Rientjes --- include/linux/slab.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 8cc1d54e56ad..06323a4beff0 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -210,9 +210,9 @@ void kmem_dump_obj(void *object); #endif /* - * kmalloc and friends return ARCH_KMALLOC_MINALIGN aligned - * pointers. kmem_cache_alloc and friends return ARCH_SLAB_MINALIGN - * aligned pointers. + * kmem_cache_alloc and friends return pointers aligned to ARCH_SLAB_MINALIGN. + * kmalloc and friends return pointers aligned to both ARCH_KMALLOC_MINALIGN + * and ARCH_SLAB_MINALIGN, but here we only assume the former alignment. */ #define __assume_kmalloc_alignment __assume_aligned(ARCH_KMALLOC_MINALIGN) #define __assume_slab_alignment __assume_aligned(ARCH_SLAB_MINALIGN)