Skip to content

Commit 88f86dc

Browse files
sjp38torvalds
authored andcommitted
mm/damon: convert macro functions to static inline functions
Patch series "mm/damon: Misc cleanups". This patchset contains miscellaneous cleanups for DAMON's macro functions and documentation. This patch (of 6): This commit converts macro functions in DAMON to static inline functions, for better type checking, code documentation, etc[1]. [1] https://lore.kernel.org/linux-mm/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Cc: Jonathan Corbet <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 234d687 commit 88f86dc

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

include/linux/damon.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,20 @@ struct damon_ctx {
399399
struct list_head schemes;
400400
};
401401

402-
#define damon_next_region(r) \
403-
(container_of(r->list.next, struct damon_region, list))
402+
static inline struct damon_region *damon_next_region(struct damon_region *r)
403+
{
404+
return container_of(r->list.next, struct damon_region, list);
405+
}
404406

405-
#define damon_prev_region(r) \
406-
(container_of(r->list.prev, struct damon_region, list))
407+
static inline struct damon_region *damon_prev_region(struct damon_region *r)
408+
{
409+
return container_of(r->list.prev, struct damon_region, list);
410+
}
407411

408-
#define damon_last_region(t) \
409-
(list_last_entry(&t->regions_list, struct damon_region, list))
412+
static inline struct damon_region *damon_last_region(struct damon_target *t)
413+
{
414+
return list_last_entry(&t->regions_list, struct damon_region, list);
415+
}
410416

411417
#define damon_for_each_region(r, t) \
412418
list_for_each_entry(r, &t->regions_list, list)

mm/damon/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,10 @@ static void kdamond_apply_schemes(struct damon_ctx *c)
729729
}
730730
}
731731

732-
#define sz_damon_region(r) (r->ar.end - r->ar.start)
732+
static inline unsigned long sz_damon_region(struct damon_region *r)
733+
{
734+
return r->ar.end - r->ar.start;
735+
}
733736

734737
/*
735738
* Merge two adjacent regions into one region

mm/damon/vaddr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
* 't->id' should be the pointer to the relevant 'struct pid' having reference
2727
* count. Caller must put the returned task, unless it is NULL.
2828
*/
29-
#define damon_get_task_struct(t) \
30-
(get_pid_task((struct pid *)t->id, PIDTYPE_PID))
29+
static inline struct task_struct *damon_get_task_struct(struct damon_target *t)
30+
{
31+
return get_pid_task((struct pid *)t->id, PIDTYPE_PID);
32+
}
3133

3234
/*
3335
* Get the mm_struct of the given target

0 commit comments

Comments
 (0)