diff mbox series

[1/4] mm, memcontrol: avoid duplicated memcg enable check

Message ID 20241202184154.19321-2-ryncsn@gmail.com (mailing list archive)
State New
Headers show
Series mm/swap_cgroup: remove global swap cgroup lock | expand

Commit Message

Kairui Song Dec. 2, 2024, 6:41 p.m. UTC
From: Kairui Song <kasong@tencent.com>

mem_cgroup_uncharge_swap() implies a mem_cgroup_disabled() check,
which is already checked by the caller here. Skip it by calling
__mem_cgroup_uncharge_swap() directly.

Signed-off-by: Kairui Song <kasong@tencent.com>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yosry Ahmed Dec. 2, 2024, 7:10 p.m. UTC | #1
On Mon, Dec 2, 2024 at 10:42 AM Kairui Song <ryncsn@gmail.com> wrote:
>
> From: Kairui Song <kasong@tencent.com>
>
> mem_cgroup_uncharge_swap() implies a mem_cgroup_disabled() check,
> which is already checked by the caller here. Skip it by calling
> __mem_cgroup_uncharge_swap() directly.
>
> Signed-off-by: Kairui Song <kasong@tencent.com>
> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 7b3503d12aaf..d3d1eb506eee 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4615,7 +4615,7 @@ void mem_cgroup_swapin_uncharge_swap(swp_entry_t entry, unsigned int nr_pages)
>                  * let's not wait for it.  The page already received a
>                  * memory+swap charge, drop the swap entry duplicate.
>                  */
> -               mem_cgroup_uncharge_swap(entry, nr_pages);
> +               __mem_cgroup_uncharge_swap(entry, nr_pages);

Would it be better to instead remove the mem_cgroup_disabled() check
here and have a single check in this path?

Anyway, FWIW:

Reviewed-by: Yosry Ahmed <yosryahmed@google.com>

>         }
>  }
>
> --
> 2.47.0
>
Shakeel Butt Dec. 2, 2024, 9:37 p.m. UTC | #2
On Tue, Dec 03, 2024 at 02:41:51AM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> mem_cgroup_uncharge_swap() implies a mem_cgroup_disabled() check,
> which is already checked by the caller here. Skip it by calling
> __mem_cgroup_uncharge_swap() directly.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Roman Gushchin Dec. 2, 2024, 10:27 p.m. UTC | #3
On Tue, Dec 03, 2024 at 02:41:51AM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> mem_cgroup_uncharge_swap() implies a mem_cgroup_disabled() check,
> which is already checked by the caller here. Skip it by calling
> __mem_cgroup_uncharge_swap() directly.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>

Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>

Thanks!
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7b3503d12aaf..d3d1eb506eee 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4615,7 +4615,7 @@  void mem_cgroup_swapin_uncharge_swap(swp_entry_t entry, unsigned int nr_pages)
 		 * let's not wait for it.  The page already received a
 		 * memory+swap charge, drop the swap entry duplicate.
 		 */
-		mem_cgroup_uncharge_swap(entry, nr_pages);
+		__mem_cgroup_uncharge_swap(entry, nr_pages);
 	}
 }