Commit 5842bcb
mm/huge_memory: replace can_split_folio() with direct refcount calculation
can_split_folio() is just a refcount comparison, making sure only the
split caller holds an extra pin. Open code it with
folio_expected_ref_count() != folio_ref_count() - 1. For the extra_pins
used by folio_ref_freeze(), add folio_cache_ref_count() to calculate it.
Also replace folio_expected_ref_count() with folio_cache_ref_count() used
by folio_ref_unfreeze(), since they are returning the same values when a
folio is frozen and folio_cache_ref_count() does not have unnecessary
folio_mapcount() in its implementation.
Link: https://lkml.kernel.org/r/20251126210618.1971206-3-ziy@nvidia.com
Signed-off-by: Zi Yan <ziy@nvidia.com>
Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: Balbir Singh <balbirs@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent bdd0d69 commit 5842bcb
3 files changed
Lines changed: 22 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | | - | |
373 | 372 | | |
374 | 373 | | |
375 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3455 | 3455 | | |
3456 | 3456 | | |
3457 | 3457 | | |
3458 | | - | |
3459 | | - | |
3460 | | - | |
3461 | | - | |
3462 | | - | |
3463 | | - | |
3464 | | - | |
3465 | | - | |
3466 | | - | |
3467 | | - | |
3468 | | - | |
3469 | | - | |
3470 | | - | |
3471 | | - | |
3472 | | - | |
3473 | | - | |
3474 | | - | |
3475 | 3458 | | |
3476 | 3459 | | |
3477 | 3460 | | |
| |||
3767 | 3750 | | |
3768 | 3751 | | |
3769 | 3752 | | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
3770 | 3761 | | |
3771 | 3762 | | |
3772 | 3763 | | |
3773 | 3764 | | |
3774 | | - | |
| 3765 | + | |
3775 | 3766 | | |
3776 | 3767 | | |
3777 | 3768 | | |
| |||
3782 | 3773 | | |
3783 | 3774 | | |
3784 | 3775 | | |
3785 | | - | |
| 3776 | + | |
3786 | 3777 | | |
3787 | 3778 | | |
3788 | | - | |
3789 | 3779 | | |
3790 | 3780 | | |
3791 | 3781 | | |
| |||
3853 | 3843 | | |
3854 | 3844 | | |
3855 | 3845 | | |
3856 | | - | |
3857 | | - | |
| 3846 | + | |
| 3847 | + | |
3858 | 3848 | | |
3859 | 3849 | | |
3860 | 3850 | | |
| |||
3897 | 3887 | | |
3898 | 3888 | | |
3899 | 3889 | | |
3900 | | - | |
3901 | | - | |
| 3890 | + | |
3902 | 3891 | | |
3903 | 3892 | | |
3904 | 3893 | | |
| |||
3947 | 3936 | | |
3948 | 3937 | | |
3949 | 3938 | | |
3950 | | - | |
| 3939 | + | |
3951 | 3940 | | |
3952 | 3941 | | |
3953 | 3942 | | |
| |||
4028 | 4017 | | |
4029 | 4018 | | |
4030 | 4019 | | |
4031 | | - | |
| 4020 | + | |
4032 | 4021 | | |
4033 | 4022 | | |
4034 | 4023 | | |
| |||
4051 | 4040 | | |
4052 | 4041 | | |
4053 | 4042 | | |
4054 | | - | |
4055 | | - | |
| 4043 | + | |
4056 | 4044 | | |
4057 | 4045 | | |
4058 | 4046 | | |
| |||
4126 | 4114 | | |
4127 | 4115 | | |
4128 | 4116 | | |
4129 | | - | |
| 4117 | + | |
4130 | 4118 | | |
4131 | 4119 | | |
4132 | 4120 | | |
4133 | 4121 | | |
4134 | 4122 | | |
4135 | 4123 | | |
4136 | | - | |
| 4124 | + | |
4137 | 4125 | | |
4138 | 4126 | | |
4139 | 4127 | | |
4140 | 4128 | | |
4141 | 4129 | | |
4142 | | - | |
| 4130 | + | |
4143 | 4131 | | |
4144 | 4132 | | |
4145 | 4133 | | |
| |||
4632 | 4620 | | |
4633 | 4621 | | |
4634 | 4622 | | |
4635 | | - | |
| 4623 | + | |
4636 | 4624 | | |
4637 | 4625 | | |
4638 | 4626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1284 | 1284 | | |
1285 | 1285 | | |
1286 | 1286 | | |
1287 | | - | |
| 1287 | + | |
| 1288 | + | |
1288 | 1289 | | |
1289 | 1290 | | |
1290 | 1291 | | |
| |||
0 commit comments