From patchwork Tue Jul 23 11:08:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 169467 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8280310ilk; Mon, 22 Jul 2019 20:08:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0IzOJbbqL6e5jB8HOuUiPbV0LaYi64Yk94SPin8TGiAz83vMrMJf0VqwtSZzwUIRy5hha X-Received: by 2002:a17:90a:360c:: with SMTP id s12mr81260859pjb.30.1563851336530; Mon, 22 Jul 2019 20:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563851336; cv=none; d=google.com; s=arc-20160816; b=fsXXZ66X2kJg4mqOc6ggkQcnjUpdDFdmH1ltqJUt0aBIKU4B61fnYY6NLL6frn6KWp ckllX2u/3EOsnJEP9QYOHqaaV/0JxQkZKutPQGIbAnpngXVP4ZgF9v+e6JH0YdRnHX0R lSZ0u4rlFkOnekoVErNDiVq9KZyh0SgVWG7vaHfYaYf+TZtuB2BEkG3IhPfZ/lLnLYYR 9snUxcvQAG63u+uer/NEDQwjAE3FJpfPbZ8dohEf+9xY6KYDwNTAOW0WkuLd0/eBnUwF 2xpuL/ORhNn+P8QLUS9360QuwE6tt9d2x6qqPKriwj1jI9u7mUyvV8OvbKKPrNshwJt1 cJgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=kZ03H+qhlgW0YO4gWzSfYLlWKY2j7omqfMdJATRwHOA=; b=fqopRK0JzXSmSFWw1BEr72KJNf/GRM9/tSaJNxY7qD6AUpAaf3UPoZvQo5HC/UMOdU YrginfSIwn96/8JoU5BjxFYV1N77bOvh0MLn59FOh+4O8uFA/Hai1s16zY57ovjurI9j ZcNZAZ6HPsU3SFfN/+wsWdP49lMWAjAJVzGU33IdmwvAdqOpJQyW71VNz4XfzvufHp6c VR2zooTeRoE52x1/6voxCB9q8WBJ6GV3O4gy2zZA1/u+rVpRHkXHqJxcEFoFIlMqimR0 S8UuDaE/qraJEyR5gcyA1+wQmBirrWWpmEWG50r3uN2Y3ZVpQtSak/+GeVBpzVrU1OpP sHQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p95si11620725pjp.4.2019.07.22.20.08.56; Mon, 22 Jul 2019 20:08:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387917AbfGWDIz (ORCPT + 14 others); Mon, 22 Jul 2019 23:08:55 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:6468 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387905AbfGWDIv (ORCPT ); Mon, 22 Jul 2019 23:08:51 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Jul 2019 20:08:35 -0700 Received: from akaher-lnx-dev.eng.vmware.com (unknown [10.110.19.203]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id C081CB24DB; Mon, 22 Jul 2019 23:08:43 -0400 (EDT) From: Ajay Kaher To: CC: , , , , , , , , , , , , , , , , , , Will Deacon , Punit Agrawal , "Aneesh Kumar K . V" , Catalin Marinas , Naoya Horiguchi , Mark Rutland , Hillf Danton , Michal Hocko , Mike Kravetz , Andrew Morton Subject: [PATCH 4/8] mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages Date: Tue, 23 Jul 2019 16:38:27 +0530 Message-ID: <1563880111-19058-5-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563880111-19058-1-git-send-email-akaher@vmware.com> References: <1563880111-19058-1-git-send-email-akaher@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: akaher@vmware.com does not designate permitted sender hosts) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Will Deacon commit a3e328556d41bb61c55f9dfcc62d6a826ea97b85 upstream. 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. Link: http://lkml.kernel.org/r/20170522133604.11392-2-punit.agrawal@arm.com Signed-off-by: Will Deacon Signed-off-by: Punit Agrawal Acked-by: Steve Capper Acked-by: Kirill A. Shutemov Cc: Aneesh Kumar K.V Cc: Catalin Marinas Cc: Naoya Horiguchi Cc: Mark Rutland Cc: Hillf Danton Cc: Michal Hocko Cc: Mike Kravetz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Srivatsa S. Bhat (VMware) Signed-off-by: Ajay Kaher --- mm/gup.c | 3 --- 1 file changed, 3 deletions(-) -- 2.7.4 diff --git a/mm/gup.c b/mm/gup.c index 45c544b..6e7cfaa 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1136,7 +1136,6 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT); tail = page; do { - VM_BUG_ON_PAGE(compound_head(page) != head, page); pages[*nr] = page; (*nr)++; page++; @@ -1183,7 +1182,6 @@ static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr, page = head + ((addr & ~PUD_MASK) >> PAGE_SHIFT); tail = page; do { - VM_BUG_ON_PAGE(compound_head(page) != head, page); pages[*nr] = page; (*nr)++; page++; @@ -1226,7 +1224,6 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr, page = head + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT); tail = page; do { - VM_BUG_ON_PAGE(compound_head(page) != head, page); pages[*nr] = page; (*nr)++; page++;