From patchwork Wed May 24 11:54:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 100440 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp236862qge; Wed, 24 May 2017 04:57:25 -0700 (PDT) X-Received: by 10.98.214.14 with SMTP id r14mr37740678pfg.156.1495627045116; Wed, 24 May 2017 04:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495627045; cv=none; d=google.com; s=arc-20160816; b=OBqmANDdXteOFqO/3yevDg0Z+i3srPZ0iy/ZLSw8QwErx5IYkPrCF4NQbi17g0ZP1Q YsEBh0/3sQ+2QVl9E5/nP44wgcA+fnkQnGlojYljbBOUnf0YKBNUZod6TrywmHKG3KkY 6lc4r/t0bR0vOJO/qIxt7lOIvDs8MioLz17ZmTVC67D4Mj5iXyf6DB6932VpISEL/Lny TvF8vfAbLNeT8idtEIot3YiMQ81sj+vtgRXDcRDbs+eQKlnDkUIwgxhyX5Rk1Kq5ap3v zFOCxPwAbeAWfbtnf9/ZIVS1vnZjbaD12/3gQRXn/UAtYgq9PjlLv5LXapAsxEIfc/Ku xmvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=nbGqE1EDQT5wKMiLSNq599lxR6/VR9vzlg0GkfWfo0A=; b=ArZ/rCMeynDoBQ/D5JoHXc0C2VLy5BLLI6qotDsN068ahov1IkooZDozAaJUaiYnIl XyOICzOJ1+T2Qf5MUZkX6efbbAVWGb9hS1qhd5sExx9sI0l/ZgWKILNEinhdCkz6O1kZ cmow/vMgqWlXwUqa9SaPfIpQIALT5b/Un84m84nHkfkzkUfWT+hMUuMWq2JGW0tQh/j3 GbbUzsv3tPrk9YJGrUTabdspg1Qd7zBg8jj2ni83B5BhsQl51xWnc3g1Jj8yksGREsY5 xVlMkzpR9QPMOgwYUMejyEtX91yMjJACjvgR3zSe4+hSzYmvz7xY5gWbXvZ0PCxSUo8e 8v2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s80si24361715pfi.388.2017.05.24.04.57.24; Wed, 24 May 2017 04:57:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035344AbdEXL46 (ORCPT + 25 others); Wed, 24 May 2017 07:56:58 -0400 Received: from foss.arm.com ([217.140.101.70]:37002 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939993AbdEXLzZ (ORCPT ); Wed, 24 May 2017 07:55:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CAE08344; Wed, 24 May 2017 04:55:24 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.207.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 99C023F578; Wed, 24 May 2017 04:55:24 -0700 (PDT) From: Punit Agrawal To: akpm@linux-foundation.org Cc: Will Deacon , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, n-horiguchi@ah.jp.nec.com, kirill.shutemov@linux.intel.com, mike.kravetz@oracle.com, steve.capper@arm.com, mark.rutland@arm.com, linux-arch@vger.kernel.org, aneesh.kumar@linux.vnet.ibm.com, Punit Agrawal Subject: [PATCH v4 3/8] mm, gup: Remove broken VM_BUG_ON_PAGE compound check for hugepages Date: Wed, 24 May 2017 12:54:04 +0100 Message-Id: <20170524115409.31309-4-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170524115409.31309-1-punit.agrawal@arm.com> References: <20170524115409.31309-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon When operating on hugepages with DEBUG_VM enabled, the GUP code checks the compound head for each tail page prior to calling page_cache_add_speculative. This is broken, because on the fast-GUP path (where we don't hold any page table locks) we can be racing with a concurrent invocation of split_huge_page_to_list. split_huge_page_to_list deals with this race by using page_ref_freeze to freeze the page and force concurrent GUPs to fail whilst the component pages are modified. This modification includes clearing the compound_head field for the tail pages, so checking this prior to a successful call to page_cache_add_speculative can lead to false positives: In fact, page_cache_add_speculative *already* has this check once the page refcount has been successfully updated, so we can simply remove the broken calls to VM_BUG_ON_PAGE. Signed-off-by: Will Deacon Acked-by: Steve Capper Signed-off-by: Punit Agrawal Acked-by: "Kirill A. Shutemov" Cc: Aneesh Kumar K.V --- mm/gup.c | 3 --- 1 file changed, 3 deletions(-) -- 2.11.0 diff --git a/mm/gup.c b/mm/gup.c index d9e6fddcc51f..ccf8cb38234f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1361,7 +1361,6 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, head = pmd_page(orig); page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT); do { - VM_BUG_ON_PAGE(compound_head(page) != head, page); pages[*nr] = page; (*nr)++; page++; @@ -1400,7 +1399,6 @@ static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr, head = pud_page(orig); page = head + ((addr & ~PUD_MASK) >> PAGE_SHIFT); do { - VM_BUG_ON_PAGE(compound_head(page) != head, page); pages[*nr] = page; (*nr)++; page++; @@ -1438,7 +1436,6 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr, head = pgd_page(orig); page = head + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT); do { - VM_BUG_ON_PAGE(compound_head(page) != head, page); pages[*nr] = page; (*nr)++; page++;