commit 3d67869ba083e38208b62e15600c34d8e4c126ad Author: Alexandre Frade Date: Thu Jul 1 17:15:11 2021 +0000 Linux 5.13.0-xanmod2 Signed-off-by: Alexandre Frade commit 1a2a0e2ca14bb3203eefb46f0641ed6d3ec929c9 Author: Alexandre Frade Date: Wed Jun 30 19:40:01 2021 +0000 futex2: fix shared futex2 pgoff on shmem huge page This commit is based on the commit fe19bd3dae3d15d2fbfdb3de8839a6ea0fe94264 original for futex. If more than one futex2 is placed on a shmem huge page, it can happen that waking the second wakes the first instead, and leaves the second waiting: the key's index is wrong. When 3.11 commit 13d60f4b6ab5 ("futex: Take hugepages into account when generating futex_key"), the only shared huge pages came from hugetlbfs, and the code added to deal with its exceptional page->index was put into hugetlb source. Then that was missed when 4.8 added shmem huge pages. page_to_pgoff() is what others use for this nowadays: except that, as currently written, it gives the right answer on hugetlbfs head, but nonsense on hugetlbfs tails. Fix that by calling hugetlbfs-specific hugetlb_basepage_index() on PageHuge tails as well as on head. Yes, it's unconventional to declare hugetlb_basepage_index() there in pagemap.h, rather than in hugetlb.h; but I do not expect anything but page_to_pgoff() ever to need it. [akpm@linux-foundation.org: give hugetlb_basepage_index() prototype the correct scope] Link: https://lkml.kernel.org/r/b17d946b-d09-326e-b42a-52884c36df32@google.com Fixes: 800d8c63b2e9 ("shmem: add huge pages support") Reported-by: Neel Natu Signed-off-by: Alexandre Frade