diff mbox series

[1/6] hugetlb_cgroup: remove unneeded nr_pages > 0 check

Message ID 20220728121949.20985-2-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few cleanup patches for hugetlb_cgroup | expand

Commit Message

Miaohe Lin July 28, 2022, 12:19 p.m. UTC
When code reaches here, nr_pages must be > 0. Remove unneeded nr_pages > 0
check to simplify the code.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/hugetlb_cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mina Almasry July 28, 2022, 5:44 p.m. UTC | #1
On Thu, Jul 28, 2022 at 5:20 AM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> When code reaches here, nr_pages must be > 0. Remove unneeded nr_pages > 0
> check to simplify the code.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks Miaohe,

Reviewed-by: Mina Almasry <almasrymina@google.com>

> ---
>  mm/hugetlb_cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
> index c86691c431fd..d16eb00c947d 100644
> --- a/mm/hugetlb_cgroup.c
> +++ b/mm/hugetlb_cgroup.c
> @@ -442,7 +442,7 @@ void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv,
>         if (hugetlb_cgroup_disabled() || !resv || !rg || !nr_pages)
>                 return;
>
> -       if (rg->reservation_counter && resv->pages_per_hpage && nr_pages > 0 &&
> +       if (rg->reservation_counter && resv->pages_per_hpage &&
>             !resv->reservation_counter) {
>                 page_counter_uncharge(rg->reservation_counter,
>                                       nr_pages * resv->pages_per_hpage);
> --
> 2.23.0
>
diff mbox series

Patch

diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index c86691c431fd..d16eb00c947d 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -442,7 +442,7 @@  void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv,
 	if (hugetlb_cgroup_disabled() || !resv || !rg || !nr_pages)
 		return;
 
-	if (rg->reservation_counter && resv->pages_per_hpage && nr_pages > 0 &&
+	if (rg->reservation_counter && resv->pages_per_hpage &&
 	    !resv->reservation_counter) {
 		page_counter_uncharge(rg->reservation_counter,
 				      nr_pages * resv->pages_per_hpage);