Message ID | 20230807110936.21819-2-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | use refcount+RCU method to implement lockless slab shrink | expand |
> On Aug 7, 2023, at 19:08, Qi Zheng <zhengqi.arch@bytedance.com> wrote: > > The following functions are only used inside the mm subsystem, so it's > better to move their declarations to the mm/internal.h file. > > 1. shrinker_debugfs_add() > 2. shrinker_debugfs_detach() > 3. shrinker_debugfs_remove() > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> One nit bellow. [...] > + > +/* > + * shrinker related functions > + */ This is a multi-comment format. "/* shrinker related functions. */" is the right one-line format of comment. > + > +#ifdef CONFIG_SHRINKER_DEBUG > +extern int shrinker_debugfs_add(struct shrinker *shrinker); > +extern struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, > + int *debugfs_id); > +extern void shrinker_debugfs_remove(struct dentry *debugfs_entry, > + int debugfs_id); > +#else /* CONFIG_SHRINKER_DEBUG */ > +static inline int shrinker_debugfs_add(struct shrinker *shrinker) > +{ > + return 0; > +} > +static inline struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, > + int *debugfs_id) > +{ > + *debugfs_id = -1; > + return NULL; > +} > +static inline void shrinker_debugfs_remove(struct dentry *debugfs_entry, > + int debugfs_id) > +{ > +} > +#endif /* CONFIG_SHRINKER_DEBUG */ > + > #endif /* __MM_INTERNAL_H */ > -- > 2.30.2 >
On 2023/8/15 16:36, Muchun Song wrote: > > >> On Aug 7, 2023, at 19:08, Qi Zheng <zhengqi.arch@bytedance.com> wrote: >> >> The following functions are only used inside the mm subsystem, so it's >> better to move their declarations to the mm/internal.h file. >> >> 1. shrinker_debugfs_add() >> 2. shrinker_debugfs_detach() >> 3. shrinker_debugfs_remove() >> >> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > > Reviewed-by: Muchun Song <songmuchun@bytedance.com> > > One nit bellow. > > [...] > >> + >> +/* >> + * shrinker related functions >> + */ > > This is a multi-comment format. "/* shrinker related functions. */" is > the right one-line format of comment. Will do. Thanks, Qi > >> + >> +#ifdef CONFIG_SHRINKER_DEBUG >> +extern int shrinker_debugfs_add(struct shrinker *shrinker); >> +extern struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, >> + int *debugfs_id); >> +extern void shrinker_debugfs_remove(struct dentry *debugfs_entry, >> + int debugfs_id); >> +#else /* CONFIG_SHRINKER_DEBUG */ >> +static inline int shrinker_debugfs_add(struct shrinker *shrinker) >> +{ >> + return 0; >> +} >> +static inline struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, >> + int *debugfs_id) >> +{ >> + *debugfs_id = -1; >> + return NULL; >> +} >> +static inline void shrinker_debugfs_remove(struct dentry *debugfs_entry, >> + int debugfs_id) >> +{ >> +} >> +#endif /* CONFIG_SHRINKER_DEBUG */ >> + >> #endif /* __MM_INTERNAL_H */ >> -- >> 2.30.2 >> >
diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index 224293b2dd06..8dc15aa37410 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -106,28 +106,9 @@ extern void free_prealloced_shrinker(struct shrinker *shrinker); extern void synchronize_shrinkers(void); #ifdef CONFIG_SHRINKER_DEBUG -extern int shrinker_debugfs_add(struct shrinker *shrinker); -extern struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, - int *debugfs_id); -extern void shrinker_debugfs_remove(struct dentry *debugfs_entry, - int debugfs_id); extern int __printf(2, 3) shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...); #else /* CONFIG_SHRINKER_DEBUG */ -static inline int shrinker_debugfs_add(struct shrinker *shrinker) -{ - return 0; -} -static inline struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, - int *debugfs_id) -{ - *debugfs_id = -1; - return NULL; -} -static inline void shrinker_debugfs_remove(struct dentry *debugfs_entry, - int debugfs_id) -{ -} static inline __printf(2, 3) int shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...) { diff --git a/mm/internal.h b/mm/internal.h index 154da4f0d557..6f21926393af 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1143,4 +1143,32 @@ struct vma_prepare { struct vm_area_struct *remove; struct vm_area_struct *remove2; }; + +/* + * shrinker related functions + */ + +#ifdef CONFIG_SHRINKER_DEBUG +extern int shrinker_debugfs_add(struct shrinker *shrinker); +extern struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, + int *debugfs_id); +extern void shrinker_debugfs_remove(struct dentry *debugfs_entry, + int debugfs_id); +#else /* CONFIG_SHRINKER_DEBUG */ +static inline int shrinker_debugfs_add(struct shrinker *shrinker) +{ + return 0; +} +static inline struct dentry *shrinker_debugfs_detach(struct shrinker *shrinker, + int *debugfs_id) +{ + *debugfs_id = -1; + return NULL; +} +static inline void shrinker_debugfs_remove(struct dentry *debugfs_entry, + int debugfs_id) +{ +} +#endif /* CONFIG_SHRINKER_DEBUG */ + #endif /* __MM_INTERNAL_H */
The following functions are only used inside the mm subsystem, so it's better to move their declarations to the mm/internal.h file. 1. shrinker_debugfs_add() 2. shrinker_debugfs_detach() 3. shrinker_debugfs_remove() Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- include/linux/shrinker.h | 19 ------------------- mm/internal.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-)