Commit 344ef45
mm/hugetlb: remove unnecessary holding of hugetlb_lock
In isolate_or_dissolve_huge_folio(), after acquiring the hugetlb_lock, it
is only for the purpose of obtaining the correct hstate, which is then
passed to alloc_and_dissolve_hugetlb_folio().
alloc_and_dissolve_hugetlb_folio() itself also acquires the hugetlb_lock.
We can have alloc_and_dissolve_hugetlb_folio() obtain the hstate by
itself, so that isolate_or_dissolve_huge_folio() no longer needs to
acquire the hugetlb_lock. In addition, we keep the folio_test_hugetlb()
check within isolate_or_dissolve_huge_folio(). By doing so, we can avoid
disrupting the normal path by vainly holding the hugetlb_lock.
replace_free_hugepage_folios() has the same issue, and we should address
it as well.
Addresses a possible performance problem which was added by the hotfix
113ed54 ("mm/hugetlb: fix kernel NULL pointer dereference when
replacing free hugetlb folios").
Link: https://lkml.kernel.org/r/1748317010-16272-1-git-send-email-yangge1116@126.com
Fixes: 113ed54 ("mm/hugetlb: fix kernel NULL pointer dereference when replacing free hugetlb folios")
Signed-off-by: Ge Yang <yangge1116@126.com>
Suggested-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <21cnbao@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 3746351 commit 344ef45
1 file changed
+17
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2787 | 2787 | | |
2788 | 2788 | | |
2789 | 2789 | | |
2790 | | - | |
2791 | 2790 | | |
2792 | 2791 | | |
2793 | 2792 | | |
2794 | 2793 | | |
2795 | | - | |
2796 | | - | |
| 2794 | + | |
| 2795 | + | |
2797 | 2796 | | |
2798 | | - | |
| 2797 | + | |
| 2798 | + | |
2799 | 2799 | | |
2800 | 2800 | | |
2801 | 2801 | | |
2802 | 2802 | | |
2803 | 2803 | | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
2804 | 2808 | | |
2805 | 2809 | | |
2806 | 2810 | | |
| |||
2829 | 2833 | | |
2830 | 2834 | | |
2831 | 2835 | | |
| 2836 | + | |
2832 | 2837 | | |
2833 | 2838 | | |
| 2839 | + | |
2834 | 2840 | | |
2835 | 2841 | | |
2836 | 2842 | | |
| |||
2874 | 2880 | | |
2875 | 2881 | | |
2876 | 2882 | | |
2877 | | - | |
2878 | 2883 | | |
2879 | 2884 | | |
2880 | | - | |
2881 | | - | |
2882 | | - | |
2883 | | - | |
2884 | | - | |
2885 | | - | |
2886 | | - | |
2887 | | - | |
2888 | | - | |
2889 | | - | |
| 2885 | + | |
| 2886 | + | |
2890 | 2887 | | |
2891 | | - | |
2892 | | - | |
2893 | 2888 | | |
2894 | 2889 | | |
2895 | 2890 | | |
2896 | 2891 | | |
2897 | 2892 | | |
2898 | 2893 | | |
2899 | | - | |
| 2894 | + | |
2900 | 2895 | | |
2901 | 2896 | | |
2902 | 2897 | | |
2903 | 2898 | | |
2904 | 2899 | | |
2905 | | - | |
| 2900 | + | |
2906 | 2901 | | |
2907 | 2902 | | |
2908 | 2903 | | |
| |||
2916 | 2911 | | |
2917 | 2912 | | |
2918 | 2913 | | |
2919 | | - | |
2920 | 2914 | | |
2921 | 2915 | | |
2922 | 2916 | | |
| |||
2925 | 2919 | | |
2926 | 2920 | | |
2927 | 2921 | | |
2928 | | - | |
2929 | | - | |
2930 | | - | |
2931 | | - | |
2932 | | - | |
2933 | | - | |
2934 | | - | |
2935 | | - | |
2936 | | - | |
2937 | | - | |
2938 | | - | |
2939 | | - | |
2940 | | - | |
2941 | | - | |
2942 | | - | |
2943 | | - | |
2944 | | - | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
2945 | 2925 | | |
2946 | 2926 | | |
2947 | 2927 | | |
| |||
0 commit comments