From patchwork Tue Jun 14 15:26:34 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: 12881254 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 63487C433EF for ; Tue, 14 Jun 2022 15:27:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F15496B0099; Tue, 14 Jun 2022 11:27:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC5166B009A; Tue, 14 Jun 2022 11:27:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D66246B009B; Tue, 14 Jun 2022 11:27:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C5C026B0099 for ; Tue, 14 Jun 2022 11:27:49 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id E0C7C120C01 for ; Tue, 14 Jun 2022 15:27:48 +0000 (UTC) X-FDA: 79577221416.06.1FF6AB4 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf04.hostedemail.com (Postfix) with ESMTP id 76A11400A0 for ; Tue, 14 Jun 2022 15:27:48 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id k5-20020a17090a404500b001e8875e6242so9352787pjg.5 for ; Tue, 14 Jun 2022 08:27:48 -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=912xltr934Z4L5T63d1EXEDHHaljNP8GxHWdMk96Wwc=; b=JwuzhpkJKIsABcpJu51mH42/VAtJ5jzo+eIZsv5lP0WXLqDCcMIF580Pb8nOHgUgyJ B3dwPUkfLjK+hzDuP7VkrLRMTB+g7M0iLjB4ZHyVbb0OSC98xetbRzVwiFHXeq0yQ/O1 1c0+IBew5tlRJvFhRiIyaoNOp+5HG9I5QrW3KiwPrRFjgRWkBm/uZw+A2pCrFw32qANl b1fesS7jSGow/noky/5tnicQdu2CNW5q0hy9AmITJ395Pl2MEvHwQCI4EIrXlnkrTBVp 6TwkHeSlVmzZq1daHIaDHBvHtMRR8crx0TsNw36srwGitHx9k3JsoXwpdYE2cywdpXmn lypw== 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=912xltr934Z4L5T63d1EXEDHHaljNP8GxHWdMk96Wwc=; b=4bzjFoDgkkwtSjLliEXTCnuUpXOgOchldB9CozE9cynlKEjXy4p/xaoJsEMNDx/vxd ibGtdMlJDdk57zpbBWgtFFoN/DigFg6vjvDbHhkgIpJyvwK4UcRBN/i3118+X1PJ3pvS U8h91myrkU1w1KHTZulPy1k+tKVMX3IbOnhl5IWlZ+poBQrRt1HhLJWEM7x/O6KMVYCm LyOqSd3Bi0fG0gimaj2umP2dP3Nfrt/WLx63ueIumsh0bMe5IHPdIN4zY2sWjk8enci5 LC2HwxIhxcpFxX26Am3RJKN4uz1w6q17M0mtDjtx8F9Q6Tz7X9KTmZm797o/LfAAi9sr HUMw== X-Gm-Message-State: AJIora8d6qrEV9nGWh7cjPZmGKF2OhsSesh7MtdvxyIN5PGfbUb1P5xT nTL8eEKPdzFejpUESvuvZ28= X-Google-Smtp-Source: AGRyM1scUeBKFwK1mzflZ6060xNgnAv/ua/q+FN++57VOiIyBU+GK+EYJw3Oz0bRS8och+nmCtaI0g== X-Received: by 2002:a17:902:ca03:b0:168:ed8e:fce7 with SMTP id w3-20020a170902ca0300b00168ed8efce7mr3638894pld.155.1655220467286; Tue, 14 Jun 2022 08:27:47 -0700 (PDT) Received: from hyeyoo.. ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id e3-20020a17090ac20300b001ea5ef30096sm9598517pjt.10.2022.06.14.08.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 08:27:46 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Matthew Wilcox Cc: linux-mm@kvack.org Subject: [PATCH 1/2] mm/sl[au]b: use own bulk free function when bulk alloc failed Date: Wed, 15 Jun 2022 00:26:34 +0900 Message-Id: <20220614152635.23353-2-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220614152635.23353-1-42.hyeyoo@gmail.com> References: <20220614152635.23353-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655220468; a=rsa-sha256; cv=none; b=SlJNe8K8qPITFjVtG374J7UFhPsIXzvhDmW0hQy7wH8lBQuikq2n8L1ej1+GVy3u12ntSQ kbuTPsmGU9ZrJmskzhMHAWmWXd4fGM+DuIBhrQIZMpYk4veIGZoXUzCQNfiM064PgnyY+c WkFNnLfUSxKBZcem6xPZB5nNPVwr6FE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JwuzhpkJ; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655220468; 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=912xltr934Z4L5T63d1EXEDHHaljNP8GxHWdMk96Wwc=; b=t+/l5xYA9GMuEjrvy8J1fQ6ArJsPbzELdEpYjxkgniHNbNORXrvPVMsKwag2j726y2x+50 DM61iDAyRwBwrtTSGmkiyPzwrazLN+eP1Fzk171PgqkuvqpAsfv6nw3JmRKCIUJG1zzIZH 72Pp/UlBZY/KE1Vnei5fAxWHKuzTOn8= X-Stat-Signature: 3jizsrsiyag3346oqcocuoqtdohsngqh X-Rspamd-Queue-Id: 76A11400A0 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JwuzhpkJ; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1655220468-192700 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: There is no benefit to call generic bulk free function when kmem_cache_alloc_bulk() failed. Use own kmem_cache_free_bulk() instead of generic function. Note that if kmem_cache_alloc_bulk() fails to allocate first object in SLUB, size is zero. So allow passing size == 0 to kmem_cache_free_bulk() like SLAB's. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slab.c | 2 +- mm/slub.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index f8cd00f4ba13..ede27ce84326 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -3553,7 +3553,7 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, local_irq_enable(); cache_alloc_debugcheck_after_bulk(s, flags, i, p, _RET_IP_); slab_post_alloc_hook(s, objcg, flags, i, p, false); - __kmem_cache_free_bulk(s, i, p); + kmem_cache_free_bulk(s, i, p); return 0; } EXPORT_SYMBOL(kmem_cache_alloc_bulk); diff --git a/mm/slub.c b/mm/slub.c index b1281b8654bd..ca9d42e7b579 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3669,7 +3669,7 @@ int build_detached_freelist(struct kmem_cache *s, size_t size, /* Note that interrupts must be enabled when calling this function. */ void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p) { - if (WARN_ON(!size)) + if (!size) return; memcg_slab_free_hook(s, p, size); @@ -3760,7 +3760,7 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, error: slub_put_cpu_ptr(s->cpu_slab); slab_post_alloc_hook(s, objcg, flags, i, p, false); - __kmem_cache_free_bulk(s, i, p); + kmem_cache_free_bulk(s, i, p); return 0; } EXPORT_SYMBOL(kmem_cache_alloc_bulk);