From patchwork Fri Nov 8 09:38:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 178864 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2415841ilf; Fri, 8 Nov 2019 01:38:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwy8qfZZ46QQGWCtYTI9g/52ThlxGJtYCc7FTPi/7pIAFg8mWVp7iWnHYT8jM2am2+GoyCF X-Received: by 2002:a05:6402:110c:: with SMTP id u12mr9097490edv.127.1573205923773; Fri, 08 Nov 2019 01:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573205923; cv=none; d=google.com; s=arc-20160816; b=X1jbD9YdOB/qthDivO0LmAnjyupN5LS7kdVt/Zf98JJeUSKB5VOVwhZSGfh/zg5Tsa VDCFOGMys3AZjVr86bkNupG7jCkzMvkXVNKnSTrQgfdy6jAZQDP3jUq1UwzqVK24xxcg eNEl5TSECahAV3LjDpHNFSen50VjFW+MpB3czN0s0WqKwD2FgYvc9R/eSvwIiH36+E42 68LKfhdgRioZ5GnR8UjW14VxEeKwjCE92lRuMQ2UAsO4lOnEE5/7Z0+ls/oiUZXb4jDt 0sYZeCN2x8FEa8hczctTstC8ymaQNjC3Q5gy7c9mV+/5ipNcnvy5bUZrPR6oXLFbM0KA /Q5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=S3OMinzRx10lIKrGSpcZz1IGLhQ+kDR0I/tFOdQBFF4=; b=EOqpBhmWhPkeAskD1x304pa9jvdJlbPpN3hXBl/ZctWMXbx3Dv8/jaqXbBl9Gq9XLW RjT0H0qItLtmCM5kPfYZmnJySdK/fc1xWuaXeoJch++W0BzJnEthv9YsX4sgtXxGQF96 oDCDZbW+nHvXwRuFrOpj3VVV7he22NQbLPCSIU47Q2V107od2T+AmGSTKueUK8ik3K15 E+D7GfHQ1Nc2yCmo9TaZ8Wn0kakUbMxmNdVsNUPFNQt2Gfo0piIxOi+f1unKVFKlVsDJ OcWZWh5skR/KpOf24vwk0+trhsEow+PQYrer41EVSCMf4sc1HKOCKwKwD4ssq971dFNt TglQ== 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 s12si3095715eja.47.2019.11.08.01.38.43; Fri, 08 Nov 2019 01:38:43 -0800 (PST) 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 S1731658AbfKHJik (ORCPT + 26 others); Fri, 8 Nov 2019 04:38:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:39772 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731444AbfKHJi2 (ORCPT ); Fri, 8 Nov 2019 04:38:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0B306AE8A; Fri, 8 Nov 2019 09:38:24 +0000 (UTC) From: Vlastimil Babka To: stable@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ajay Kaher , Will Deacon , Punit Agrawal , Steve Capper , "Kirill A . Shutemov" , "Aneesh Kumar K . V" , Catalin Marinas , Naoya Horiguchi , Mark Rutland , Hillf Danton , Michal Hocko , Mike Kravetz , Andrew Morton , Linus Torvalds , Vlastimil Babka Subject: [PATCH STABLE 4.4 1/8] mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages Date: Fri, 8 Nov 2019 10:38:07 +0100 Message-Id: <20191108093814.16032-2-vbabka@suse.cz> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108093814.16032-1-vbabka@suse.cz> References: <20191108093814.16032-1-vbabka@suse.cz> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: Vlastimil Babka --- mm/gup.c | 3 --- 1 file changed, 3 deletions(-) -- 2.23.0 diff --git a/mm/gup.c b/mm/gup.c index 2cd3b31e3666..6f9088cb8ebe 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1134,7 +1134,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++; @@ -1181,7 +1180,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++; @@ -1224,7 +1222,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++;