linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: linux-mm@kvack.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	David Hildenbrand <david@redhat.com>,
	Oscar Salvador <osalvador@suse.de>, SeongJae Park <sj@kernel.org>
Subject: [PATCH v2 1/2] mm/cma: Inline cma_sysfs counter hooks
Date: Mon, 17 Nov 2025 11:56:02 +0100	[thread overview]
Message-ID: <20251117115602.7b9c7ccd@endymion> (raw)

Move cma_sysfs counter hooks from cma_sysfs.c to cma.c. These
one-liner functions are only used once each, but the compiler
currently can't inline them because they are defined in one object and
used in another. Letting the compiler inline these functions lowers
the footprint and runtime cost of the sysfs interface to CMA stats
even more.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
Changes in v2:
* Move the functions to cma.c as this is the only place where they
  are used.

 mm/cma.c       |   27 +++++++++++++++++++++++++++
 mm/cma.h       |   12 ------------
 mm/cma_sysfs.c |   15 ---------------
 3 files changed, 27 insertions(+), 27 deletions(-)

--- linux-6.17.orig/mm/cma.h
+++ linux-6.17/mm/cma.h
@@ -80,16 +80,4 @@ static inline unsigned long cma_bitmap_m
 	return cmr->count >> cma->order_per_bit;
 }
 
-#ifdef CONFIG_SYSFS
-void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages);
-void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages);
-void cma_sysfs_account_release_pages(struct cma *cma, unsigned long nr_pages);
-#else
-static inline void cma_sysfs_account_success_pages(struct cma *cma,
-						   unsigned long nr_pages) {};
-static inline void cma_sysfs_account_fail_pages(struct cma *cma,
-						unsigned long nr_pages) {};
-static inline void cma_sysfs_account_release_pages(struct cma *cma,
-						   unsigned long nr_pages) {};
-#endif
 #endif
--- linux-6.17.orig/mm/cma_sysfs.c
+++ linux-6.17/mm/cma_sysfs.c
@@ -14,21 +14,6 @@
 #define CMA_ATTR_RO(_name) \
 	static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
 
-void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages)
-{
-	atomic64_add(nr_pages, &cma->nr_pages_succeeded);
-}
-
-void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages)
-{
-	atomic64_add(nr_pages, &cma->nr_pages_failed);
-}
-
-void cma_sysfs_account_release_pages(struct cma *cma, unsigned long nr_pages)
-{
-	atomic64_add(nr_pages, &cma->nr_pages_released);
-}
-
 static inline struct cma *cma_from_kobj(struct kobject *kobj)
 {
 	return container_of(kobj, struct cma_kobject, kobj)->cma;
--- linux-6.17.orig/mm/cma.c
+++ linux-6.17/mm/cma.c
@@ -36,6 +36,33 @@
 struct cma cma_areas[MAX_CMA_AREAS];
 unsigned int cma_area_count;
 
+#ifdef CONFIG_SYSFS
+static void cma_sysfs_account_success_pages(struct cma *cma,
+					    unsigned long nr_pages)
+{
+	atomic64_add(nr_pages, &cma->nr_pages_succeeded);
+}
+
+static void cma_sysfs_account_fail_pages(struct cma *cma,
+					 unsigned long nr_pages)
+{
+	atomic64_add(nr_pages, &cma->nr_pages_failed);
+}
+
+static void cma_sysfs_account_release_pages(struct cma *cma,
+					    unsigned long nr_pages)
+{
+	atomic64_add(nr_pages, &cma->nr_pages_released);
+}
+#else
+static void cma_sysfs_account_success_pages(struct cma *cma,
+					    unsigned long nr_pages) {};
+static void cma_sysfs_account_fail_pages(struct cma *cma,
+					 unsigned long nr_pages) {};
+static void cma_sysfs_account_release_pages(struct cma *cma,
+					    unsigned long nr_pages) {};
+#endif
+
 phys_addr_t cma_get_base(const struct cma *cma)
 {
 	WARN_ON_ONCE(cma->nranges != 1);

-- 
Jean Delvare
SUSE L3 Support


             reply	other threads:[~2025-11-17 10:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 10:56 Jean Delvare [this message]
2025-11-17 11:15 ` [PATCH RFC 2/2] mm/cma: Consolidate accounting in dedicated functions Jean Delvare
2025-11-18  1:40   ` SeongJae Park
2025-11-17 11:22 ` [PATCH v2 1/2] mm/cma: Inline cma_sysfs counter hooks David Hildenbrand (Red Hat)
2025-11-18  1:34 ` SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251117115602.7b9c7ccd@endymion \
    --to=jdelvare@suse.de \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox