From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD873C48BE5 for ; Tue, 15 Jun 2021 14:53:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A59561580 for ; Tue, 15 Jun 2021 14:53:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A59561580 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 939DB6B0071; Tue, 15 Jun 2021 10:53:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E9576B0072; Tue, 15 Jun 2021 10:53:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B0F56B0073; Tue, 15 Jun 2021 10:53:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 4B9BA6B0071 for ; Tue, 15 Jun 2021 10:53:30 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D2EFE181AC1F5 for ; Tue, 15 Jun 2021 14:53:29 +0000 (UTC) X-FDA: 78256251738.03.56A28F6 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf24.hostedemail.com (Postfix) with ESMTP id F1802A00025C for ; Tue, 15 Jun 2021 14:53:19 +0000 (UTC) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1623768807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e93NAi6ZEiulkbcdd6o8Ahtb1+0Pma6KZlwIxXZGnpI=; b=jMoV7aWk49uxTY1kg2gMCOHt6ChpE95KIyYuXqF7ZNR9YOEtc1hivB2tT/UfbmF+ao8xyH rGGvCDZrjZlPpSBnMsqlt56FNz2+b/GG1hGeTSBOzV41a7RQuG0KDA9pmxx6Ghx9hpMqOv yWhJXETSXYYwus6sLsqKclWgG7TmNDBmtgoVCLhin5qK9PRC2hlISJ1NEDXN79Kzmj5ewt POBCJTmeykB3twO5sk6X7WfHiEvXuWY8CblQ2QkJCDbptyksDXLvHnohYoZYNUJ/lt6skR rsD3A9ftbVsCJBZQJVyGa0fswFhLiRhG2fYvoH7LAAZj0vQ4ghfl9xvz8qzoNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1623768807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e93NAi6ZEiulkbcdd6o8Ahtb1+0Pma6KZlwIxXZGnpI=; b=JvI/9XwPrTpEfCpYz9x6ibWwJYy1EBrVh1uz2bHbaTVcVQ9kzkrtYCUmiaxXlC0q6ic9s7 iGMhUWdmX5dvB2Cg== To: Hugh Dickins , Andrew Morton Cc: Hugh Dickins , Matthew Wilcox , "Kirill A. Shutemov" , Zhang Yi , Mel Gorman , Mike Kravetz , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , Neel Natu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm, futex: Fix shared futex pgoff on shmem huge page In-Reply-To: References: <45e8fd67-51fd-7828-fe43-d261d6c33727@google.com> Date: Tue, 15 Jun 2021 16:53:27 +0200 Message-ID: <87mtrrgowo.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=jMoV7aWk; dkim=pass header.d=linutronix.de header.s=2020e header.b="JvI/9XwP"; spf=pass (imf24.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Stat-Signature: 1jcqx49segn3taydyetfaa3snmoqr5g7 X-Rspamd-Queue-Id: F1802A00025C X-Rspamd-Server: rspam06 X-HE-Tag: 1623768799-529338 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jun 12 2021 at 20:16, Hugh Dickins wrote: > If more than one futex 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 shared.pgoff 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. > > Fixes: 800d8c63b2e9 ("shmem: add huge pages support") > Reported-by: Neel Natu > Signed-off-by: Hugh Dickins > Cc: Assuming this goes through mm: Acked-by: Thomas Gleixner