Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3750124pxj; Tue, 15 Jun 2021 07:54:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFHR38JDRxv8uAwbhAx6d47Z6/WBW72irDUt3W/vMxCxmazfl95LKNTOewTPCvY3qZgC2l X-Received: by 2002:a05:6e02:12a6:: with SMTP id f6mr18961665ilr.121.1623768864817; Tue, 15 Jun 2021 07:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623768864; cv=none; d=google.com; s=arc-20160816; b=SkTXKdY9qC2fFR12sNe2bXzBsOQcqS/3L0UrRmfe2m1omu8cBSsCkoFI1wfw8unI6z YG12VEbj1lzYMU/jeF8lqkeYPGMAEBgpcgp/TVw2tn8l5dK76pw9kP+u3STSVjNO9Rdf DV0IbNRKOQ4g7GUN8M07wVXR3rCXr5ybi78CAkmrwAAN5r1pd6a+keDkoTuXR/TyeC0W 3ARqzsd+JR76oc2xdS8IYtNGhFMJtTqxyOL3srTeqH1PeyihI8YK8QJRAMJ9DL+f5Dbb m6DMRlPGSgxxd6rWrxMp2A5TS6ArKsUdk9uI+2aFVSe30NOGH8pr6A7HrK3yRgZMDbKT DK+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=e93NAi6ZEiulkbcdd6o8Ahtb1+0Pma6KZlwIxXZGnpI=; b=LXia97olV1xAWC2aNEdwebbYKkRXSjBdimHUVRKV3Jjm2KzUu0dKUDhiXuuSHFZJvb 42oRhbP6jGrFMIYbD06YWWKrVBVSIkJ0cWN7Azs1jv3sKJXtjpIi/MzpJbBkMhjEviS3 48/I+cn0VkTYY8pegj9IPB2YS90KbY9DE7uk4153MNJxgibATr1AtLkydEna28wVhgVv Z/igzKtYsAwLXpoHZgWUSPJW3Svy1yvwYEv3K/vENf0Pghj7ayzKeWnMI7yB1OWKEAvs QHBJ5P020pD1WwgtPy2ZW4SO/ihsNPWWMOLBzxxbBRniDyQtB406TQyVrW1U+iaRy4mn 1CpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jMoV7aWk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h78si21549170iof.66.2021.06.15.07.54.12; Tue, 15 Jun 2021 07:54:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jMoV7aWk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbhFOOze (ORCPT + 99 others); Tue, 15 Jun 2021 10:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbhFOOzd (ORCPT ); Tue, 15 Jun 2021 10:55:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9F62C061574 for ; Tue, 15 Jun 2021 07:53:28 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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