From patchwork Mon Oct 24 08:14:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13016816 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 E5587C38A2D for ; Mon, 24 Oct 2022 08:15:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84EE48E0005; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF198E0002; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C73F8E0005; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5D5058E0002 for ; Mon, 24 Oct 2022 04:15:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2A8BF1401C9 for ; Mon, 24 Oct 2022 08:15:32 +0000 (UTC) X-FDA: 80055133704.03.7A30314 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id DC870C000D for ; Mon, 24 Oct 2022 08:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666599330; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oB5FHCqdQzRcpJOgYsd1zcN5d+GwusZuRHj9Ye7P85Q=; b=MVVPlPV/zqchGBRP0L9jJ4IXX1nNCVDaaVg/AR6d6GrM6k8ReNJrJzgu59nRLD4umPcNJg Sdvk4qEZNx2AdpLs5tmLwSiaIbzCScmh/rz+B9XVM5E3adN44QTZfqoZlDkcNm6ZKgug86 L5kBwgxIK7jeeB1ZdKOPMYcpWaEpSVY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-md_8dzoMOzCwdktsUExyUg-1; Mon, 24 Oct 2022 04:15:20 -0400 X-MC-Unique: md_8dzoMOzCwdktsUExyUg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 70B7E887400; Mon, 24 Oct 2022 08:15:19 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D63C40C6F9F; Mon, 24 Oct 2022 08:15:12 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Baoquan He , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH 8/8] mm/slub, percpu: correct the calculation of early percpu allocation size Date: Mon, 24 Oct 2022 16:14:35 +0800 Message-Id: <20221024081435.204970-9-bhe@redhat.com> In-Reply-To: <20221024081435.204970-1-bhe@redhat.com> References: <20221024081435.204970-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666599330; a=rsa-sha256; cv=none; b=m88Im1XmciRv9SX8l8lmYdo2g/VLJ6+CBsOm489Nlnk9Wsv24BacCIo1eltop3/jL15MRl C0wmTgHr4CpkgH71I+hgaqE/2VxrskS+7jpAptNVPdKrNFY8DMSdd6GBfb5xMbEY2JJZq2 n2NS+El76+VYEnf2xdV+3T1KcR3Lbxc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="MVVPlPV/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666599330; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oB5FHCqdQzRcpJOgYsd1zcN5d+GwusZuRHj9Ye7P85Q=; b=j3vsgF7WKlrITmvmp5xyFoacKDAkT0JgLnU3G8x44Ee4NoOUMlwrmnFaUUkDKaYo7qYPQm h/JMmTgyCVLdwSo3E5tUJiyAMJ5mMLrWa8YMAcC89z6gvWOaK0tp9eF3QFITFMqnaAYuF/ y8Ta8ax8pCxt5eal/kegnpwh8nOTtJo= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="MVVPlPV/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com X-Rspamd-Server: rspam04 X-Rspam-User: X-Stat-Signature: 8iiu9wsfx3mxnke96cic71xxzhhyq4a8 X-Rspamd-Queue-Id: DC870C000D X-HE-Tag: 1666599330-54839 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: SLUB allocator relies on percpu allocator to initialize its ->cpu_slab during early boot. For that, the dynamic chunk of percpu which serves the early allocation need be large enough to satisfy the kmalloc creation. However, the current BUILD_BUG_ON() in alloc_kmem_cache_cpus() doesn't consider the kmalloc array with NR_KMALLOC_TYPES length. Fix that with correct calculation. Signed-off-by: Baoquan He Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Vlastimil Babka Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Dennis Zhou --- mm/slub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 157527d7101b..8ac3bb9a122a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4017,7 +4017,8 @@ init_kmem_cache_node(struct kmem_cache_node *n) static inline int alloc_kmem_cache_cpus(struct kmem_cache *s) { BUILD_BUG_ON(PERCPU_DYNAMIC_EARLY_SIZE < - KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)); + NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * + sizeof(struct kmem_cache_cpu)); /* * Must align to double word boundary for the double cmpxchg