From patchwork Mon Jun 19 17:01:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 105905 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp944055obh; Mon, 19 Jun 2017 10:02:52 -0700 (PDT) X-Received: by 10.84.175.65 with SMTP id s59mr30416665plb.20.1497891772110; Mon, 19 Jun 2017 10:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891772; cv=none; d=google.com; s=arc-20160816; b=juFimPsu8bGytvOu4BPamPvJx6mMc/8J7Y5bDXNPLyKINGof18l37Gtwp6nIDDJUfl ugQ80tQ82j5CdqyBM7Iow/nngder2DWpCpdYR+5lO1oL6PE47QkbQcg3+z7OBz0KP7/4 ncOimD1MaTKRPCkg7Ak5R+QSV5uHWrQjprCWV/Kgd2yCBmCJp9qF4kJG4+9Z/g8pXWvZ +eI1s8x18Mx6GR661/WvBL79MW5llQXEuneJaphYDhgoghnY7h2amfEPZ6iKxsSnkBcJ TC1IDgNbSiw86kWlE05lQNUx+/zMjC9dc/YXg8Ps7StzCVB7TJannLMs1rr6qCyfTVGI mt4g== 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=vGkyJ7VWfQsTnQpVNLgr1HQqqxkfqJ9hng5xcT7C9cs=; b=06mju5YebEhP9MKR9+Dwuh59V/xzsROkbiv0zP93aQ5OCe7CskiQmq1Wtp+oicCLrt 1AK3h/v3EpyA/UQfgDzlc6RPGQFiRodNdqmXddb9/Y1OeEW1mqJuMmaNyeoWrNhdetWP jdK8PgTiBWaa5VRJG/HlGcxboM9297ipVShh79a/x/skegVs5SVoAFfTt6LxPZ3O9szm iVP5GDWfQyKPqDgMzW8yJT8P+0dORpm3940Hns0MzBh2pe3hZFePUIzRRPF4axxG/2CB ws5BgIGIiqAO7QTu6Ej/K9OzfqeJOJFpdNg7hAQV6nM0hpKX+Be1Sv476BVKw3kvQ9QV Welw== 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 g4si9055243plb.162.2017.06.19.10.02.51; Mon, 19 Jun 2017 10:02:52 -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 S1752550AbdFSRCr (ORCPT + 25 others); Mon, 19 Jun 2017 13:02:47 -0400 Received: from foss.arm.com ([217.140.101.70]:54468 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752520AbdFSRCp (ORCPT ); Mon, 19 Jun 2017 13:02:45 -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 35617344; Mon, 19 Jun 2017 10:02:35 -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 0228B3F41F; Mon, 19 Jun 2017 10:02:34 -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 v5 3/8] mm, gup: Remove broken VM_BUG_ON_PAGE compound check for hugepages Date: Mon, 19 Jun 2017 18:01:40 +0100 Message-Id: <20170619170145.25577-4-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619170145.25577-1-punit.agrawal@arm.com> References: <20170619170145.25577-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 b3c7214d710d..e74e0b5a0c7c 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1357,7 +1357,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++; @@ -1396,7 +1395,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++; @@ -1434,7 +1432,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++;