From patchwork Wed Aug 17 10:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 12945686 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 0C300C25B08 for ; Wed, 17 Aug 2022 10:19:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 967BA6B007E; Wed, 17 Aug 2022 06:19:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 918296B0080; Wed, 17 Aug 2022 06:19:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 791558D0001; Wed, 17 Aug 2022 06:19:13 -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 6C1746B007E for ; Wed, 17 Aug 2022 06:19:13 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 39EFFA0871 for ; Wed, 17 Aug 2022 10:19:13 +0000 (UTC) X-FDA: 79808686986.14.02B84D6 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf06.hostedemail.com (Postfix) with ESMTP id D05EC1801AF for ; Wed, 17 Aug 2022 10:19:12 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 73so11601430pgb.9 for ; Wed, 17 Aug 2022 03:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=V13eBLL+I9iGduc+JnUgsCOIMqteurACvuOFaESMVck=; b=npKhTo3ktjcY8GrNZPcQJecpqhpmyjY86O+1b2c9YapnvSiuEYHiYe5hnCn/sUP0QT qNkoC7kX+tJi8lPw28MEQm733wFAvgSGKZHtoE1lhSMoCOdt3XXcAE+Mv7OAcQdFAvX+ HhH7RPa6voDdqpdjNP0u52d2Qik1vWrHYJBtcDSAmM+IC8xz9TstXJaxtT7fK2MNa8tY a+XUbmdJlWpmSC7QsgIfWYyubzXveHLy0AUl6kjCLyHahj3m/nD1qZPHeIe6fNarqGw7 QA4ZQNVBFjw1Ozp+l5pBhj89GteMBMwljxJ7dQawuvf0VZQXj9hzJhJRJy8QSr8Qix4u YK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=V13eBLL+I9iGduc+JnUgsCOIMqteurACvuOFaESMVck=; b=Zvl2ne0eAHvnWWGrRG3Ta3rPaF0W0OguCsiliH07FEzRmOhcOoZElCeQyyS5GcyD/t qIxMcI/OvrkTfBLEECrnPHUNKuHbSRJ7ceIrDRgOdDrDjME8vPO30LTjRVaUKrFsabsg Py7FrySLeoIgCbj2i1W7LNYdbT6DDGUeiQrdaOg7cntkwmgk6TtWd36hgVMuqrsSgbA0 7+Pe2PYyz0VNp+qbsmKv/uL/tpSXydlY5qTME+QIEU6V4whK6ItBPw0kaDCcRGz63cBo w8YYzRf605gE0XC9E1HTlxXfk/5/TGNGcjd2Ipq8qNsUlab+y5I7gnvH/X1nT7R64r4q X5EA== X-Gm-Message-State: ACgBeo05587Yjr405AnLy1b1lhMHCQ0J8WKwqGyHCGBSQ/hE7dQ368xM 8hvqadmBm6P9yoI2vji4MxE= X-Google-Smtp-Source: AA6agR5Ow2fAgG6PDOU6KesG5RJ+Tea/+u3A+H4XdF3ir3eqFdhtzZcFsxZkt3rDAsMg+9NGYF8LDg== X-Received: by 2002:a65:4605:0:b0:41c:3d73:9385 with SMTP id v5-20020a654605000000b0041c3d739385mr20546331pgq.168.1660731551918; Wed, 17 Aug 2022 03:19:11 -0700 (PDT) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id d8-20020a170903230800b00172633fc236sm1071318plh.174.2022.08.17.03.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 03:19:11 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/17] mm/slub: move kmalloc_large_node() to slab_common.c Date: Wed, 17 Aug 2022 19:18:16 +0900 Message-Id: <20220817101826.236819-8-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817101826.236819-1-42.hyeyoo@gmail.com> References: <20220817101826.236819-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660731552; 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:dkim-signature; bh=V13eBLL+I9iGduc+JnUgsCOIMqteurACvuOFaESMVck=; b=oUYn3c4Rv2T6bfERLCki9p+90va57lHK4yL4VsD4zHCU7DoAwh0ErQs+0kMd6S1nc98nzd BJza5yu+wRrJ6fRrViF4ZeNp2FUS/SRsiY28S+AUKUXpyBYBRlSkOiRtdmVeLKL4GvDoF+ kzt6+U/Cdu1jQX7fJhq1ptMHLbn0OKA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=npKhTo3k; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660731552; a=rsa-sha256; cv=none; b=4ls7c49wjls0/GQRtyoJuXDl0dvdTWx3gl4pCWasxkkl5RvOEsIpLu9Au4QtENdtI4zPIK hTBN6esuF0UXUGr2BOIiOuInQwcot/C1lwqAVsI2RNL30RAcFQ1g7XTngnh7c/BJaTJbMz wq4yz9+yWsIxYz/Md8foPViZEvVijsU= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D05EC1801AF X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=npKhTo3k; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: qdbg4yohhd57ci9iaecohich1gjxwgpi X-HE-Tag: 1660731552-305834 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: In later patch SLAB will also pass requests larger than order-1 page to page allocator. Move kmalloc_large_node() to slab_common.c. Fold kmalloc_large_node_hook() into kmalloc_large_node() as there is no other caller. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Vlastimil Babka --- include/linux/slab.h | 4 ++++ mm/slab_common.c | 22 ++++++++++++++++++++++ mm/slub.c | 25 ------------------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 15a4c59da59e..082499306098 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -491,6 +491,10 @@ static __always_inline void *kmem_cache_alloc_node_trace(struct kmem_cache *s, g void *kmalloc_large(size_t size, gfp_t flags) __assume_page_alignment __alloc_size(1); + +void *kmalloc_large_node(size_t size, gfp_t flags, int node) __assume_page_alignment + __alloc_size(1); + /** * kmalloc - allocate memory * @size: how many bytes of memory are required. diff --git a/mm/slab_common.c b/mm/slab_common.c index 8b1988544b89..1b9101f9cb21 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -928,6 +928,28 @@ void *kmalloc_large(size_t size, gfp_t flags) } EXPORT_SYMBOL(kmalloc_large); +void *kmalloc_large_node(size_t size, gfp_t flags, int node) +{ + struct page *page; + void *ptr = NULL; + unsigned int order = get_order(size); + + flags |= __GFP_COMP; + page = alloc_pages_node(node, flags, order); + if (page) { + ptr = page_address(page); + mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, + PAGE_SIZE << order); + } + + ptr = kasan_kmalloc_large(ptr, size, flags); + /* As ptr might get tagged, call kmemleak hook after KASAN. */ + kmemleak_alloc(ptr, size, 1, flags); + + return ptr; +} +EXPORT_SYMBOL(kmalloc_large_node); + #ifdef CONFIG_SLAB_FREELIST_RANDOM /* Randomize a generic freelist */ static void freelist_randomize(struct rnd_state *state, unsigned int *list, diff --git a/mm/slub.c b/mm/slub.c index f9929ba858ec..5e7819ade2c4 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1704,14 +1704,6 @@ static bool freelist_corrupted(struct kmem_cache *s, struct slab *slab, * Hooks for other subsystems that check memory allocations. In a typical * production configuration these hooks all should produce no code at all. */ -static inline void *kmalloc_large_node_hook(void *ptr, size_t size, gfp_t flags) -{ - ptr = kasan_kmalloc_large(ptr, size, flags); - /* As ptr might get tagged, call kmemleak hook after KASAN. */ - kmemleak_alloc(ptr, size, 1, flags); - return ptr; -} - static __always_inline void kfree_hook(void *x) { kmemleak_free(x); @@ -4402,23 +4394,6 @@ static int __init setup_slub_min_objects(char *str) __setup("slub_min_objects=", setup_slub_min_objects); -static void *kmalloc_large_node(size_t size, gfp_t flags, int node) -{ - struct page *page; - void *ptr = NULL; - unsigned int order = get_order(size); - - flags |= __GFP_COMP; - page = alloc_pages_node(node, flags, order); - if (page) { - ptr = page_address(page); - mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, - PAGE_SIZE << order); - } - - return kmalloc_large_node_hook(ptr, size, flags); -} - static __always_inline void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller) {