Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4382066imw; Tue, 12 Jul 2022 07:05:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vWZ/c+4g1QbhUl9kYnFHBlXrEhoEPaMuhour+/xiCoUgM5WAOHvnkd0TceOsebrNx5DFD/ X-Received: by 2002:a05:6402:b9b:b0:43a:5aac:ed6 with SMTP id cf27-20020a0564020b9b00b0043a5aac0ed6mr31874987edb.131.1657634709060; Tue, 12 Jul 2022 07:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657634709; cv=none; d=google.com; s=arc-20160816; b=cvdgNDi8tBNIZjdQlUaF5jhoZDJabikBiIuYbqNmpKFOHvOGxrN1YARH/eSascHxUX jv4qbMkf72G4NTwf8MUO6TnH7FTt42m42Eo/98vAVBVMbqx5psjZGj7wu2j5JJeo5Fi8 v5uSjHXT6Es9vLLnladIOVtxEo4G3/7XT9FHFq4FtOJOwm+2do8fiOnSdRi/4ig91ypy sCvinBu1rQ5jlfa4unZRkLhDDevTOTUjVb46Ps82vwe+6FRl5YyhmoTSD/cTncKP9qD9 8RZacWfhrm8355Fsw6XxSa8gb8icnAv/5jhH9TdserBN9kmb5EFcz+e61yYTWHGFxtjC 88wQ== 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 :dkim-signature; bh=hkTIlokXdXZHx70dj4cBcCaT2BPOKJtfpJSDSwc0fHU=; b=Ex2roVLCwdRwg0/MWmxDNXLz24NmH80Vd5e3Y5pieWanKsxRiWLD+aUT0okOLcHm8W sfFLdYMvqhMig+yU3PYGdZqMV6n3naAWKW/hCbyjP6L6EjtLQDiaJxINTrdfSxYKDf37 XjXii5iMV14BXMi34tG9MKE2feHHNZwiuYFVVRIciPU4sqIyOr6l1PjWR0tP4hVq8/mG sKiyig4yiLdvOlfYaybCYUezz1mili6CKW2ZywSrE6LtWPDUIeGv5WhTb+Qi5lzXW+M6 JsFlp6jOk9cPkgkunz/5XEYc56Jf3rgcaPEtCTlX6ppcqHKrPubzsO8si1Y9rR8PZaGo EL7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gXwpav1c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf37-20020a1709077f2500b007262ce19578si18378010ejc.549.2022.07.12.07.04.30; Tue, 12 Jul 2022 07:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gXwpav1c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233320AbiGLNlI (ORCPT + 99 others); Tue, 12 Jul 2022 09:41:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbiGLNkZ (ORCPT ); Tue, 12 Jul 2022 09:40:25 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6160B850F for ; Tue, 12 Jul 2022 06:40:23 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id l12so7258562plk.13 for ; Tue, 12 Jul 2022 06:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hkTIlokXdXZHx70dj4cBcCaT2BPOKJtfpJSDSwc0fHU=; b=gXwpav1cs46JY9auUHpcAwYHPt6lSXcC2SSzBTo4UXju5/zqc9fbvLJYuVlpXdlK+x ILUw3UDcuQM6XR0DYIOaLLq7PiFw1DelSfNhpH8fwrMOMcUZKBsnicw8LHwhwYTZZy9f V9yVjlGvi0UjRoM7uKFypklMHjTy5TGtAM389Mbcd/lY4jpm/sC7Nn4xgO2TvpAzLFDO kGQ2/qx9+4o3tsfwPKUPPFOueOag7i1feT+gRgghI/bdCfLwnHTCpw9HeHb2t//988sg c6NWB4HtEj7qA4n2UDfd8bO5eiuCpQHi/pkHoGQi6pX0nDw24mta8uLyX/kz+rzZnmC+ QGQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hkTIlokXdXZHx70dj4cBcCaT2BPOKJtfpJSDSwc0fHU=; b=eZofZ5bz7h4DdZmxjkAGPrreTFfJ3yNxMK9U3IkRO/dqqpjg4KAasw96bEPj9PCtEJ v9o9CTBzWX/Te99kdb6TwdOAJnDs3B2r1htwrvj1HixgtqP8rky16a83ugKfodLrOeqi 3npO0f72JIleWayHaVqy3dOhjyTdnGc/dr9jLCxGze7InbX8+F6m7PhMFNLm0nut6m4k fjoAEwoYGYKsO4Qe/k10q1D5pRuEgLdPROT8DNERkn9v4BjXg3kHwsEgZDOWPiyXzGDX CaCNSJTpBkYGQdSfABMlrXT3qW4hiKaGkTL+hRB2rhrS+WOvwTTvRJ9ivcbP+w68489Q 6OuA== X-Gm-Message-State: AJIora+Gy+ZbD373nqV6jD5hiwEPh0W1RGKWbUxkPnan4zdhIX4vrzMr qH8/0YUWaRw+vd4ieYPt2Co= X-Received: by 2002:a17:90b:3807:b0:1f0:a86:6875 with SMTP id mq7-20020a17090b380700b001f00a866875mr4428239pjb.103.1657633223420; Tue, 12 Jul 2022 06:40:23 -0700 (PDT) Received: from ip-172-31-24-42.ap-northeast-1.compute.internal (ec2-35-75-15-180.ap-northeast-1.compute.amazonaws.com. [35.75.15.180]) by smtp.gmail.com with ESMTPSA id r6-20020aa79886000000b0052ae3bcb807sm1947178pfl.188.2022.07.12.06.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 06:40:22 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Joe Perches , Vasily Averin , Matthew WilCox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 09/15] mm/slab_common: cleanup kmalloc_large() Date: Tue, 12 Jul 2022 13:39:39 +0000 Message-Id: <20220712133946.307181-10-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220712133946.307181-1-42.hyeyoo@gmail.com> References: <20220712133946.307181-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, 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 Now that kmalloc_large() and kmalloc_large_node() do mostly same job, make kmalloc_large() wrapper of __kmalloc_large_node_notrace(). In the meantime, add missing flag fix code in __kmalloc_large_node_notrace(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slab_common.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index dc872e0ef0fc..9c46e2f9589f 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -932,29 +932,6 @@ gfp_t kmalloc_fix_flags(gfp_t flags) * directly to the page allocator. We use __GFP_COMP, because we will need to * know the allocation order to free the pages properly in kfree. */ -void *kmalloc_large(size_t size, gfp_t flags) -{ - void *ret = NULL; - struct page *page; - unsigned int order = get_order(size); - - if (unlikely(flags & GFP_SLAB_BUG_MASK)) - flags = kmalloc_fix_flags(flags); - - flags |= __GFP_COMP; - page = alloc_pages(flags, order); - if (likely(page)) { - ret = page_address(page); - mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, - PAGE_SIZE << order); - } - ret = kasan_kmalloc_large(ret, size, flags); - /* As ret might get tagged, call kmemleak hook after KASAN. */ - kmemleak_alloc(ret, size, 1, flags); - trace_kmalloc(_RET_IP_, ret, NULL, size, PAGE_SIZE << order, flags); - return ret; -} -EXPORT_SYMBOL(kmalloc_large); static __always_inline void *__kmalloc_large_node_notrace(size_t size, gfp_t flags, int node) @@ -963,6 +940,9 @@ void *__kmalloc_large_node_notrace(size_t size, gfp_t flags, int node) void *ptr = NULL; unsigned int order = get_order(size); + if (unlikely(flags & GFP_SLAB_BUG_MASK)) + flags = kmalloc_fix_flags(flags); + flags |= __GFP_COMP; page = alloc_pages_node(node, flags, order); if (page) { @@ -978,6 +958,16 @@ void *__kmalloc_large_node_notrace(size_t size, gfp_t flags, int node) return ptr; } +void *kmalloc_large(size_t size, gfp_t flags) +{ + void *ret = __kmalloc_large_node_notrace(size, flags, NUMA_NO_NODE); + + trace_kmalloc(_RET_IP_, ret, NULL, size, + PAGE_SIZE << get_order(size), flags); + return ret; +} +EXPORT_SYMBOL(kmalloc_large); + void *kmalloc_large_node_notrace(size_t size, gfp_t flags, int node) { return __kmalloc_large_node_notrace(size, flags, node); -- 2.34.1