Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] Missing `!CONFIG_MEMCG` stubs for GPU memcg accounting functions 
(`mem_cgroup_charge_gpu_page`, etc.) causes a linker error.
--

commit ba45048ba307805ed185b05a25fe4419acb46277
Author: Dave Airlie <[email protected]>

memcontrol: allow objcg api when memcg is config off.

This commit adds a dummy function for get_obj_cgroup_from_current() when
CONFIG_MEMCG is disabled. This allows drivers like amdgpu to use the objcg
API without needing ifdef blocks around it.

> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 3a968c6be0c84..a8f74aa930c57 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -1804,6 +1804,11 @@ static inline void __memcg_kmem_uncharge_page(struct 
> page *page, int order)
>  {
>  }
>  
> +static inline struct obj_cgroup *get_obj_cgroup_from_current(void)
> +{
> +     return NULL;
> +}
> +

[Severity: Low]
Are there other objcg API functions that also need dummy stubs to prevent
linker errors when CONFIG_MEMCG is disabled?

For example, mem_cgroup_charge_gpu_page() is declared unconditionally in
include/linux/memcontrol.h:

bool mem_cgroup_charge_gpu_page(struct obj_cgroup *objcg, struct page *page,
                                unsigned int order,
                                gfp_t gfp_mask, bool reclaim);

This function is used directly without an ifdef block in the TTM driver:

drivers/gpu/drm/ttm/ttm_pool.c:ttm_pool_alloc_page() {
    ...
    if (!mem_cgroup_charge_gpu_page(objcg, p, order, gfp_flags, false)) {
    ...
}

Does building a kernel with CONFIG_MEMCG=n and CONFIG_DRM_TTM=y result in
undefined reference linker errors for mem_cgroup_charge_gpu_page() and
other related GPU memcg accounting functions?

>  static inline struct obj_cgroup *get_obj_cgroup_from_folio(struct folio 
> *folio)
>  {
>       return NULL;

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=7

Reply via email to