Received: by 10.223.176.5 with SMTP id f5csp3379646wra; Mon, 29 Jan 2018 12:21:43 -0800 (PST) X-Google-Smtp-Source: AH8x227eorEWry7iB8PKCnhoBKfkplriXJp2jWd8qb97/K4NYOV1yHXujb0Zo3uTmISVdrHei+4/ X-Received: by 10.98.218.24 with SMTP id c24mr27998569pfh.145.1517257303638; Mon, 29 Jan 2018 12:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517257303; cv=none; d=google.com; s=arc-20160816; b=kUmMi+GDyPrd5d6ISwyZDRsaaFVCkQtj2SMh6Kkb9o68cJ8efNOiGcb5LhBYZAmunQ azAHRmijvisDxWncCK+6oTgzZcxtAtGTYDLuTUiwl78tNcPd7YwfY9gZ1kVb6YA6C/4d hpzrb2qjZFzYM4W9IcCpCTIuHZLjLaDFkkQ2dVjPzC22mUNIg2BJCTAyFEugsy/2v3Xv ayUSgO9ZVc2O+RQNL4eX5zfK9W5IOf8QjvziEnqNPuX0n8c/oVZmxkh6SxapsBqDNYix TGK6aKP818H8HuqmXZejR9Hp9GhHvijZkytWUych/PY6UK3r3hTkYmsXk2rb9ei7pkg/ 2+mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=l1h+R23KaO/5JZlKegdlnxLohpKnT1Qi+BI58QTPUtc=; b=MPROeB762QYG+sogyhcEWfu6sWR9SgnfZgSuKLHte/Xk9Jo9GeijjZe3L2BIWnodKz QawYAjJu2j22HJe1fzr0Yic9OYxnKLnykE04nQdeIt4Lzx4VD/kbwwGI5L62ACj8LKEB 9TurgT6jaBYeleMUctbuN6CUJmIOXRijuzGppAKIiOm/9dmKa+XSorK0OxsT7B9Hp7Q/ Azh6i3OTxaakhs6CXjsoC0E+PMxv4jE64+NuO93d+4Be3ZJ2a2g0vWC1oIARgAnOCKqv KF7BjF67hTDv+WuNTLr6sDb8CEg3v7LCP8xNqqID2MRPgekAvrc8n032/nnnY4DyT6wY +2Nw== 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 f9-v6si376556plo.697.2018.01.29.12.21.29; Mon, 29 Jan 2018 12:21: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 S932587AbeA2UU1 (ORCPT + 99 others); Mon, 29 Jan 2018 15:20:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45970 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754675AbeA2URA (ORCPT ); Mon, 29 Jan 2018 15:17:00 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E48352EF3; Mon, 29 Jan 2018 13:01:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlastimil Babka , Mel Gorman , Joonsoo Kim , Rik van Riel , David Rientjes , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 4.4 24/74] mm, page_alloc: fix potential false positive in __zone_watermark_ok Date: Mon, 29 Jan 2018 13:56:29 +0100 Message-Id: <20180129123848.715093273@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vlastimil Babka commit b050e3769c6b4013bb937e879fc43bf1847ee819 upstream. Since commit 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for order-0 allocations"), __zone_watermark_ok() check for high-order allocations will shortcut per-migratetype free list checks for ALLOC_HARDER allocations, and return true as long as there's free page of any migratetype. The intention is that ALLOC_HARDER can allocate from MIGRATE_HIGHATOMIC free lists, while normal allocations can't. However, as a side effect, the watermark check will then also return true when there are pages only on the MIGRATE_ISOLATE list, or (prior to CMA conversion to ZONE_MOVABLE) on the MIGRATE_CMA list. Since the allocation cannot actually obtain isolated pages, and might not be able to obtain CMA pages, this can result in a false positive. The condition should be rare and perhaps the outcome is not a fatal one. Still, it's better if the watermark check is correct. There also shouldn't be a performance tradeoff here. Link: http://lkml.kernel.org/r/20171102125001.23708-1-vbabka@suse.cz Fixes: 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for order-0 allocations") Signed-off-by: Vlastimil Babka Acked-by: Mel Gorman Cc: Joonsoo Kim Cc: Rik van Riel Cc: David Rientjes Cc: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/page_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2468,9 +2468,6 @@ static bool __zone_watermark_ok(struct z if (!area->nr_free) continue; - if (alloc_harder) - return true; - for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) { if (!list_empty(&area->free_list[mt])) return true; @@ -2482,6 +2479,9 @@ static bool __zone_watermark_ok(struct z return true; } #endif + if (alloc_harder && + !list_empty(&area->free_list[MIGRATE_HIGHATOMIC])) + return true; } return false; }