Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp583547imn; Thu, 28 Jul 2022 09:34:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7724IHEyTPaabILTaqkVxH8G0aM/vIpPV7GXhQs46b3GhGLjR9qFsCvSna81IdJPAXPDLh X-Received: by 2002:a17:90a:fb4b:b0:1f3:1cbb:8912 with SMTP id iq11-20020a17090afb4b00b001f31cbb8912mr193504pjb.239.1659026078095; Thu, 28 Jul 2022 09:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659026078; cv=none; d=google.com; s=arc-20160816; b=s5omKFUxs44+yBUqgEBqddScfyZPpMnRXBtrRlm330NCTOpoRygVXeJSDFDND67NGi fBdarK1dLsFC8Pl+9k9eHs7UimHXZ2zwrUCH2tR8pKSWHE+7LVHBW0alnMS0QbBeL0Xh VtDOdPT/3+3VsSjBRAwdf0DB8pxJsHMyZ3MI8t2sc6kG6GcbPYtl/SqNUQbwQl5Pv8Zx MUjfestupkAke8SxlMl3Mlv7rRmHV1OBWdNsu8GVg0Er9T3Ym53PwVWVxg+OvpSZgyMv IE0RO33Y0L63BghvEzgVgmqueQqTGMz5Rlt7dlUyw5pbCfa/x4RA41rjEifGRgrhvt3h 2LKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=uFNLMsmaiX/KJpwTe1Kl7r0olPyBVX9u4w3byywnZaQ=; b=OYe6SG92F4dEIawcZzI9JNbbIwyr2We8PDDK8pxrF0F6GOTkcE7/goQ7NfKgEavkgk O9EP0PL5pv5Rk1h2FLQZWMgDtl7UPgbC806JIh7KrY9eBnFDxUUSvyc9ECu5sZOucHrn NYDsN+CaGgCX2I0L9BD1d2AFldfANJxufCC5lmkH2A5D+K4mGy9ZsCiPZ9tN113F1Qt0 X2VaTI+sbC9XlsqtpFhEcWwUzJFvYOstFKDt8ZZwkL56aAp4PJhUUeW1phHGYSkfcN8A 7FqQT5x4HP+c/X87Dfb/cBmgPF10o323w7msUitfeC/5Zc6saDQWkETSHY49ZQwaFf6p 4FPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=usHCPZMY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a170902cec100b0016d86335ae6si1629655plg.164.2022.07.28.09.34.21; Thu, 28 Jul 2022 09:34:38 -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=@suse.cz header.s=susede2_rsa header.b=usHCPZMY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231410AbiG1QNp (ORCPT + 99 others); Thu, 28 Jul 2022 12:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232492AbiG1QNX (ORCPT ); Thu, 28 Jul 2022 12:13:23 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AAB26F7E3 for ; Thu, 28 Jul 2022 09:13:11 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D697B1FBAD; Thu, 28 Jul 2022 16:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1659024789; h=from:from:reply-to: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=uFNLMsmaiX/KJpwTe1Kl7r0olPyBVX9u4w3byywnZaQ=; b=usHCPZMY4s4WbBkvRuD2vTWO1umj/trRQm5sTbc39MjAG/uLxnnEVAKF9Bim0Z73MR6wjZ /UEfFFonAjwfqvAYBi5JNx47btffkBIfJWtAU1He1/hO3WuKve4QYe30NouUak4TfIBPwB F3rxOAieDIrRLeVYZHDGtD3oLR6PpNw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1659024789; h=from:from:reply-to: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=uFNLMsmaiX/KJpwTe1Kl7r0olPyBVX9u4w3byywnZaQ=; b=BamlEN9VBPnmc6zaO2Wyiok82LF254+J3XaWxFoJcCvvsGOldWETK2stJ6hX9DHKrZ6GK/ +7UKQ4UJEU1JeLCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AA7E913427; Thu, 28 Jul 2022 16:13:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4Ai7KJW14mKZDgAAMHmgww (envelope-from ); Thu, 28 Jul 2022 16:13:09 +0000 Message-ID: <33ae1986-6f92-aa15-1be5-c7ae79320a34@suse.cz> Date: Thu, 28 Jul 2022 18:13:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 09/15] mm/slab_common: cleanup kmalloc_large() Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Joe Perches , Vasily Averin , Matthew WilCox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20220712133946.307181-1-42.hyeyoo@gmail.com> <20220712133946.307181-10-42.hyeyoo@gmail.com> From: Vlastimil Babka In-Reply-To: <20220712133946.307181-10-42.hyeyoo@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_SOFTFAIL 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 On 7/12/22 15:39, Hyeonggon Yoo wrote: > 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> Reviewed-by: Vlastimil Babka > --- > 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);