[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240902044128.664075-4-surenb@google.com>
Date: Sun, 1 Sep 2024 21:41:25 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: akpm@...ux-foundation.org
Cc: kent.overstreet@...ux.dev, corbet@....net, arnd@...db.de,
mcgrof@...nel.org, rppt@...nel.org, paulmck@...nel.org, thuth@...hat.com,
tglx@...utronix.de, bp@...en8.de, xiongwei.song@...driver.com,
ardb@...nel.org, david@...hat.com, vbabka@...e.cz, mhocko@...e.com,
hannes@...xchg.org, roman.gushchin@...ux.dev, dave@...olabs.net,
willy@...radead.org, liam.howlett@...cle.com, pasha.tatashin@...een.com,
souravpanda@...gle.com, keescook@...omium.org, dennis@...nel.org,
jhubbard@...dia.com, yuzhao@...gle.com, vvvvvv@...gle.com,
rostedt@...dmis.org, iamjoonsoo.kim@....com, rientjes@...gle.com,
minchan@...gle.com, kaleshsingh@...gle.com, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org, linux-mm@...ck.org,
linux-modules@...r.kernel.org, kernel-team@...roid.com, surenb@...gle.com
Subject: [PATCH v2 3/6] alloc_tag: eliminate alloc_tag_ref_set
To simplify further refactoring, open-code the only two callers
of alloc_tag_ref_set().
Signed-off-by: Suren Baghdasaryan <surenb@...gle.com>
---
include/linux/alloc_tag.h | 25 ++-----------------------
include/linux/pgalloc_tag.h | 12 +++++++++++-
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
index 99cbc7f086ad..21e3098220e3 100644
--- a/include/linux/alloc_tag.h
+++ b/include/linux/alloc_tag.h
@@ -143,36 +143,15 @@ static inline void alloc_tag_add_check(union codetag_ref *ref, struct alloc_tag
static inline void alloc_tag_sub_check(union codetag_ref *ref) {}
#endif
-/* Caller should verify both ref and tag to be valid */
-static inline void __alloc_tag_ref_set(union codetag_ref *ref, struct alloc_tag *tag)
-{
- ref->ct = &tag->ct;
- /*
- * We need in increment the call counter every time we have a new
- * allocation or when we split a large allocation into smaller ones.
- * Each new reference for every sub-allocation needs to increment call
- * counter because when we free each part the counter will be decremented.
- */
- this_cpu_inc(tag->counters->calls);
-}
-
-static inline void alloc_tag_ref_set(union codetag_ref *ref, struct alloc_tag *tag)
-{
- alloc_tag_add_check(ref, tag);
- if (!ref || !tag)
- return;
-
- __alloc_tag_ref_set(ref, tag);
-}
-
static inline void alloc_tag_add(union codetag_ref *ref, struct alloc_tag *tag, size_t bytes)
{
alloc_tag_add_check(ref, tag);
if (!ref || !tag)
return;
- __alloc_tag_ref_set(ref, tag);
+ ref->ct = &tag->ct;
this_cpu_add(tag->counters->bytes, bytes);
+ this_cpu_inc(tag->counters->calls);
}
static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes)
diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h
index 207f0c83c8e9..244a328dff62 100644
--- a/include/linux/pgalloc_tag.h
+++ b/include/linux/pgalloc_tag.h
@@ -103,7 +103,17 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr)
page_ext = page_ext_next(page_ext);
for (i = 1; i < nr; i++) {
/* Set new reference to point to the original tag */
- alloc_tag_ref_set(codetag_ref_from_page_ext(page_ext), tag);
+ ref = codetag_ref_from_page_ext(page_ext);
+ alloc_tag_add_check(ref, tag);
+ if (ref) {
+ ref->ct = &tag->ct;
+ /*
+ * We need in increment the call counter every time we split a
+ * large allocation into smaller ones because when we free each
+ * part the counter will be decremented.
+ */
+ this_cpu_inc(tag->counters->calls);
+ }
page_ext = page_ext_next(page_ext);
}
out:
--
2.46.0.469.g59c65b2a67-goog
Powered by blists - more mailing lists