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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 0105BC48BCF for ; Sat, 12 Jun 2021 16:16:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AC13260E0C for ; Sat, 12 Jun 2021 16:16:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC13260E0C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2FAC16B0070; Sat, 12 Jun 2021 12:16:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D1306B0071; Sat, 12 Jun 2021 12:16:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 171F76B0072; Sat, 12 Jun 2021 12:16:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id DB3546B0070 for ; Sat, 12 Jun 2021 12:16:38 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7C831181AF5C6 for ; Sat, 12 Jun 2021 16:16:38 +0000 (UTC) X-FDA: 78245574876.05.4D17D0A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id C79FDA00024C for ; Sat, 12 Jun 2021 16:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=53tO8p11whzwQRzfUP/thFEN7SV4qqVV48LGg1lsp/c=; b=MUYUHWqS6VqZY1nT3jcgwZIsQz W4mpQ3Ge1gE85Y3GalrWVDT/yFjEm5674k8+5qYgw09qeQZfdWr1b2DUo3U+/ju+8HWt7TzPd/KLh Vet0QiEAQYiM7glZ3UC18+/KL9kHPEmY6VpH0K4httYhNEneJKbCO995IUkJBl3tNt9JB0ChzFtk+ gHwTzM9rlktg2E2fZr9FgUA3cmiEMov5GUftKjApuo0MmzFAJ/+mXQuUxD4Lg9QJSDOLCFgAQSlEs qSpEGILXon4i7riaMVA8vuK/y1uclgUpNjKtGJXqDbUc5KehcpSPXMp/3rBBE0TeT3VXn65NGCS78 cJ+lfaSA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1ls6IX-003qN7-7p; Sat, 12 Jun 2021 16:15:56 +0000 Date: Sat, 12 Jun 2021 17:15:49 +0100 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , "Kirill A. Shutemov" , Zhang Yi , Mel Gorman , Mike Kravetz , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , Neel Natu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm, futex: Fix shared futex pgoff on shmem huge page Message-ID: References: <45e8fd67-51fd-7828-fe43-d261d6c33727@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45e8fd67-51fd-7828-fe43-d261d6c33727@google.com> Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MUYUHWqS; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: nmb9tcy4ttur5adm38bxeqdh3xns4xo9 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C79FDA00024C X-HE-Tag: 1623514591-301357 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 Fri, Jun 11, 2021 at 09:31:16PM -0700, Hugh Dickins wrote: > +++ linux/include/linux/pagemap.h 2021-06-11 17:30:28.726720252 -0700 > @@ -516,8 +516,7 @@ static inline struct page *read_mapping_ > } > > /* > - * Get index of the page with in radix-tree > - * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE) > + * Get index of the page within radix-tree (but not for hugetlb pages). > */ I think the TODO should be retained. It's still something that I intend to do. > static inline pgoff_t page_to_pgoff(struct page *page) > { > - if (unlikely(PageHeadHuge(page))) > - return page->index << compound_order(page); > - > + if (unlikely(PageHuge(page))) { > + extern pgoff_t hugetlb_basepage_index(struct page *page); > + return hugetlb_basepage_index(page); > + } > return page_to_index(page); > } Yes, this change absolutely makes sense. It's just a landmine if it returns the right answer for some tail pages but garbage for other kinds of tail pages. > --- 5.13-rc5/mm/hugetlb.c 2021-06-06 16:57:26.263006733 -0700 > +++ linux/mm/hugetlb.c 2021-06-11 17:30:28.730720276 -0700 > @@ -1588,15 +1588,12 @@ struct address_space *hugetlb_page_mappi > return NULL; > } > > -pgoff_t __basepage_index(struct page *page) > +pgoff_t hugetlb_basepage_index(struct page *page) > { > struct page *page_head = compound_head(page); > pgoff_t index = page_index(page_head); > unsigned long compound_idx; > > - if (!PageHuge(page_head)) > - return page_index(page); > - > if (compound_order(page_head) >= MAX_ORDER) > compound_idx = page_to_pfn(page) - page_to_pfn(page_head); > else > urgh. this trailing bit should be: #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) compound_idx = page_to_pfn(page) - page_to_pfn(page_head); #else compound_idx = page - page_head; #endif