From patchwork Sun Jun 9 16:42:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 166235 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp57424ilk; Sun, 9 Jun 2019 09:53:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNHy2i0t9RJubjm0W8viZJOOoh9cWu//mgpZC6Oi8+Uc5lFc5FVbGv1nbj33kunAbBvmAd X-Received: by 2002:a17:902:9b81:: with SMTP id y1mr41591976plp.194.1560099237633; Sun, 09 Jun 2019 09:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560099237; cv=none; d=google.com; s=arc-20160816; b=ebWGDv28DjxbtSTsWELgTevvk36u56+/Z/yyyixRW/rJhToMuTmgQ5b+9hnKwJ1wh8 /dNFLEjH130O2e5GdIAdhyyy2lnXftDfSi69fVUg0xyiNunEh0isTrUXLq7jc+q+dlKx 8GYCfHDiZodxHrEE/Sg3HYWtfD2WP34yIrdzhVKrS6PoJx5g9zhLUb8gx0VyM9NfeCij GUQV8eTOerIwKnzqsWcIya62lb630L/xMkJd+nvKokAjt4WT4wZVHaB+vbA7AXLmKqDG 6Gw/ShHzW0xk/DmavdJylSWSwn4xfO9jL9idjvkkCYJsviOraTPwObjauYSQdL9N0e5o QnZw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KfqijX2r/iikQcFMzXBj2Ij5QGpwRL5hRfJEYyMN4q4=; b=PHvOjqtazsk8Tcq2f5+FHIy/ovaq8hfPOi4R9XiwxT/OlkRwiZavqwBVPAkycUwrsr RNHLqky/pUrkq+cFyMnqPFYJZOG06RoHoD4qj5jBcdFn+1o4fxP1agFQvPQM/+ijE40T 2LaLgyz3MSvrvnfCePvZymw7hnC5Gecjt5e5WXvJDlpAKoQJyexBX6tAMD8/EGA4c0Cg PNZhBgmIHKnNTklb8w8Nx2rjKBxriwXcVkLby5V3OlAjLMPijT1/MQ0BLhaqgeUy1EzS WYwWn1CvTI8y06EKW5OWhXh3SFCbMqIYImFaJ8SprPN2GSSBrmOHkK5JPjb08adtlXWe vr6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rNxuJoHv; 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 m20si8005470pjn.40.2019.06.09.09.53.57; Sun, 09 Jun 2019 09:53:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rNxuJoHv; 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 S1732506AbfFIQx4 (ORCPT + 30 others); Sun, 9 Jun 2019 12:53:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:55250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732496AbfFIQxw (ORCPT ); Sun, 9 Jun 2019 12:53:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61AAC204EC; Sun, 9 Jun 2019 16:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099230; bh=jn5STUV+VcC4A12rzncY3TQ86QUZFyuFr8waJzuPqhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNxuJoHv6T/M4dfVv6m74Um4s+Bx0mmWZJx3YZz4ILkINWJuDoveX3lljK2bng10b 66Z4OkEGCvcuADD9SXq8gzcHnadfaT7/1KCdRQ0M86+eXS+8G+T3GD7vr1z2GpQzxu Pwlp1MdILAj81BdJTrc0q/VFqRe4ql5mISYJ1AFI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, 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 , Ben Hutchings Subject: [PATCH 4.9 55/83] mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages Date: Sun, 9 Jun 2019 18:42:25 +0200 Message-Id: <20190609164132.620872548@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164127.843327870@linuxfoundation.org> References: <20190609164127.843327870@linuxfoundation.org> User-Agent: quilt/0.66 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: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- mm/gup.c | 3 --- 1 file changed, 3 deletions(-) --- a/mm/gup.c +++ b/mm/gup.c @@ -1316,7 +1316,6 @@ static int gup_huge_pmd(pmd_t orig, pmd_ 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++; @@ -1351,7 +1350,6 @@ static int gup_huge_pud(pud_t orig, pud_ 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++; @@ -1387,7 +1385,6 @@ static int gup_huge_pgd(pgd_t orig, pgd_ 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++;