@@ -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)
@@ -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:
To simplify further refactoring, open-code the only two callers of alloc_tag_ref_set(). Signed-off-by: Suren Baghdasaryan <surenb@google.com> --- include/linux/alloc_tag.h | 25 ++----------------------- include/linux/pgalloc_tag.h | 12 +++++++++++- 2 files changed, 13 insertions(+), 24 deletions(-)