From patchwork Mon May 22 13:35:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 100299 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp249986qge; Mon, 22 May 2017 06:36:53 -0700 (PDT) X-Received: by 10.98.37.68 with SMTP id l65mr26019775pfl.175.1495460213312; Mon, 22 May 2017 06:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495460213; cv=none; d=google.com; s=arc-20160816; b=UCYcScbOWUtQYMPdzjpTKvZ4pI4xa/akuRlyAzbkMkiXB48aBJspNrlSAZ8L1w2S81 d3TZ43jk/em2fTb01zV+fwPz4CjY10dOObIYOhkhViEO5WWTf/aqKAIYVtW8EUrNngQx oEcA4KQPfk3C3gOqPu+3MnguFPmMrbipq29VyU3KbLNEOcIfw6aBy2c+8kvJ033bP0gF x8mJ1BQOSc+02CdmuSURXsJugKKjYvd/ywR9k+RyVlISAeMJSAhR6l/hegP7YSk6u6rE Jxjbw7xQPJr1++R1SPjtk6fsZ4dziBLzRomMTFh4x3S8J65bY/BBhsRjO/n0BDFNAbDa rlFA== 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=beT7hXJ9nV5ZoVACE+kBNoCco7GGMYLqCLuR5FWAkjQ=; b=SjaXptoh7adheX3ep0cCBWCgu8/k8/wDu7PCrG/qmk0w8DVIgGQtpcqj/pCqvlZDz6 93/fs7KMFDityTgECLhFAPLYNu8ZyHaFEiYNxJ5k8qyo7/kaqOhL8i6sXHLGwtWvQt0g mBnAjjGiNezjqeNtZHKOIoP+T3n88AUUPVT6mFYDBZiRRl6s2Z16fbhHRQz4TKLkSYv/ IhDCRAKk0SOaHUPxr7rvh+5R8HzSTyvcYpXQ4DnVXaR7nL5EVIgz4gE/PZcxpESkSn0l ahYxf8vNxvRBP7m+4uAZR43keVJeRvfLe0ViDN6HnUE1K2TdBeqGWz/VH5obX+/HBjl5 uzKA== 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 p17si17447959pfi.37.2017.05.22.06.36.52; Mon, 22 May 2017 06:36:53 -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 S1759743AbdEVNgr (ORCPT + 25 others); Mon, 22 May 2017 09:36:47 -0400 Received: from foss.arm.com ([217.140.101.70]:37262 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759279AbdEVNgo (ORCPT ); Mon, 22 May 2017 09:36:44 -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 D9B291570; Mon, 22 May 2017 06:36:43 -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 A8D6E3F53D; Mon, 22 May 2017 06:36:43 -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, hillf.zj@alibaba-inc.com, linux-arch@vger.kernel.org, aneesh.kumar@linux.vnet.ibm.com, Punit Agrawal Subject: [PATCH v3 1/6] mm, gup: Remove broken VM_BUG_ON_PAGE compound check for hugepages Date: Mon, 22 May 2017 14:35:59 +0100 Message-Id: <20170522133604.11392-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170522133604.11392-1-punit.agrawal@arm.com> References: <20170522133604.11392-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. Cc: "Kirill A. Shutemov" Cc: Aneesh Kumar K.V Signed-off-by: Will Deacon Acked-by: Steve Capper Signed-off-by: Punit Agrawal --- mm/gup.c | 3 --- 1 file changed, 3 deletions(-) -- 2.11.0 Acked-by: Kirill A. Shutemov 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++;