From patchwork Tue Jun 14 15:26:35 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: 12881255 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 D7AD6C433EF for ; Tue, 14 Jun 2022 15:27:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68A1E6B009B; Tue, 14 Jun 2022 11:27:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6408A6B009C; Tue, 14 Jun 2022 11:27:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DC2A6B009D; Tue, 14 Jun 2022 11:27:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3E9BA6B009B for ; Tue, 14 Jun 2022 11:27:52 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 18C1B80A75 for ; Tue, 14 Jun 2022 15:27:52 +0000 (UTC) X-FDA: 79577221584.02.71AEF8D Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf20.hostedemail.com (Postfix) with ESMTP id 9FA201C000A for ; Tue, 14 Jun 2022 15:27:51 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id y196so8864670pfb.6 for ; Tue, 14 Jun 2022 08:27:51 -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=Ltjdf4nClYTj0XelJAJtg36z1Jux9omNUEK41q6yi7M=; b=QtyQbir4Y9sUl6i4lolVEHjyLNKDORyCBlQ83jsDhEYrSl22ArkRPV5MvciKeH4Z5G +w9XJBYR/r87pYBp2wkfGrlf507gx3PocBwGPZCjbE9rQOy0pw2XAyZBKi8iYJgy+0FL g8a6aBG4/kQYNYb7xXcGZvEpRdgWDYS2PG/4Gno/ta3Ky1KD9ZZyXmdNFMCqr9mBWxlf MjI4CGZdgHD1yQ+QFFBNIvYpnb2soDQbXDLAzkucjS/jRS37LR35+RPG8pp/P50pmPyt 770G3ZUyh62MXVJYtwAvkmH78RhZWiIoprqFDdSlWgpSjaEMYZHBlrHaddkJM4kR91/j vNRw== 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=Ltjdf4nClYTj0XelJAJtg36z1Jux9omNUEK41q6yi7M=; b=a6mLo3OCBovE77q5GoG/xDh7phW3f/TndsShXgAQXgZC4DLAJhw3dCfvsG9SOhQF73 lB0E8vz0I4TzDLmfIFAjZzqNraLJXhE8PAL1wpOT3oBdDpT+UZ6xq1HsSSjDGOL4NHNc 7nI+teISN8EcR3AHo3jIkQm0YLFv39xgJfX0OqgwrRuIzjoITqmxY29P4i2lMnhs+H74 Ch2z+kwYiR/qHJmzxHdt7oLK2QXdVPINxqqAyMLtQ3w9U9JUHB3SreAysB1VA7woczkE qAbaai/gclwG33pL9ZmhrP07z8QZ8sTE4+JxKWbmbskCWMuztXe+72+N4Qen7CsXULrT vISg== X-Gm-Message-State: AOAM5338b2QUl7tFqudMN4RW3bTV9ehkVWykUhs9JQQloRJxuuDiMIL2 fTzj9BLwKvlesqP+Qo2PqDU= X-Google-Smtp-Source: ABdhPJx50lGJLMUABwaSv2jszw7k8RcyKdAmwfPZC52HQEELJKyglOilR7rrtdGcrrx7a5ZO6nPe6g== X-Received: by 2002:a63:4853:0:b0:3fa:dc6:7ac2 with SMTP id x19-20020a634853000000b003fa0dc67ac2mr5017236pgk.298.1655220470643; Tue, 14 Jun 2022 08:27:50 -0700 (PDT) Received: from hyeyoo.. ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id e3-20020a17090ac20300b001ea5ef30096sm9598517pjt.10.2022.06.14.08.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 08:27:49 -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 2/2] mm/slab_common: move generic bulk alloc/free functions to SLOB Date: Wed, 15 Jun 2022 00:26:35 +0900 Message-Id: <20220614152635.23353-3-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655220471; 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=Ltjdf4nClYTj0XelJAJtg36z1Jux9omNUEK41q6yi7M=; b=rfzq1icVhhez7LPzb+TJmfQe2bbuJZwgrZSN12MpRcFpmSRBbzkJcWJ7uOSkZO51Zj33os k7VEduwxDBGTONEk44o5V0mKuGElpinfgJXqhooiAmyyy0/ezlXtsQyL/VP3aUTm+PkPeO 5hD9sp+V7tsFoEOo/ajTHcUCzRwk2YA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655220471; a=rsa-sha256; cv=none; b=KiMVB/P/J2skVe+lOzCGnnktURdH9rNxZbw31JzX8CgEIidV/stzSebOiDuVxhlNyyz2UY 9hEQ6uzdmpBnK7Vi93OkCxCFogHbM41CeprhIJ/xFOH7GUWlb9F4KvhO8BqjRMZC/xX1ii 2vVz6CGnfP/UfUST1uvVz8yR1N1tijs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QtyQbir4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QtyQbir4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: z14hnnpax6w3oxkghg5qqbu8j8acjcbf X-Rspamd-Queue-Id: 9FA201C000A X-HE-Tag: 1655220471-601046 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: Now that only SLOB use __kmem_cache_{alloc,free}_bulk(), move them to SLOB. No functional change intended. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slab.h | 9 --------- mm/slab_common.c | 27 --------------------------- mm/slob.c | 25 +++++++++++++++++++++---- 3 files changed, 21 insertions(+), 40 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index db9fb5c8dae7..a6837605e4cc 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -380,15 +380,6 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s); ssize_t slabinfo_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos); -/* - * Generic implementation of bulk operations - * These are useful for situations in which the allocator cannot - * perform optimizations. In that case segments of the object listed - * may be allocated or freed using these operations. - */ -void __kmem_cache_free_bulk(struct kmem_cache *, size_t, void **); -int __kmem_cache_alloc_bulk(struct kmem_cache *, gfp_t, size_t, void **); - static inline enum node_stat_item cache_vmstat_idx(struct kmem_cache *s) { return (s->flags & SLAB_RECLAIM_ACCOUNT) ? diff --git a/mm/slab_common.c b/mm/slab_common.c index 77c3adf40e50..a6787fd39aa4 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -105,33 +105,6 @@ static inline int kmem_cache_sanity_check(const char *name, unsigned int size) } #endif -void __kmem_cache_free_bulk(struct kmem_cache *s, size_t nr, void **p) -{ - size_t i; - - for (i = 0; i < nr; i++) { - if (s) - kmem_cache_free(s, p[i]); - else - kfree(p[i]); - } -} - -int __kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t nr, - void **p) -{ - size_t i; - - for (i = 0; i < nr; i++) { - void *x = p[i] = kmem_cache_alloc(s, flags); - if (!x) { - __kmem_cache_free_bulk(s, i, p); - return 0; - } - } - return i; -} - /* * Figure out what the alignment of the objects will be given a set of * flags, a user specified alignment and the size of the objects. diff --git a/mm/slob.c b/mm/slob.c index f47811f09aca..f8babd0806ee 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -692,16 +692,33 @@ void kmem_cache_free(struct kmem_cache *c, void *b) } EXPORT_SYMBOL(kmem_cache_free); -void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p) +void kmem_cache_free_bulk(struct kmem_cache *s, size_t nr, void **p) { - __kmem_cache_free_bulk(s, size, p); + size_t i; + + for (i = 0; i < nr; i++) { + if (s) + kmem_cache_free(s, p[i]); + else + kfree(p[i]); + } } EXPORT_SYMBOL(kmem_cache_free_bulk); -int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, +int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t nr, void **p) { - return __kmem_cache_alloc_bulk(s, flags, size, p); + size_t i; + + for (i = 0; i < nr; i++) { + void *x = p[i] = kmem_cache_alloc(s, flags); + + if (!x) { + kmem_cache_free_bulk(s, i, p); + return 0; + } + } + return i; } EXPORT_SYMBOL(kmem_cache_alloc_bulk);