From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x224FGtvs3o7pV3W81RYN4vwIJhXIigHn1/BB+Dig6vcrJJnQGQwoZjhloxWfh8S70ah0fPnw ARC-Seal: i=1; a=rsa-sha256; t=1517257021; cv=none; d=google.com; s=arc-20160816; b=owDIs1KjHnVfIvVEgVgTTxHu5HDoINfGc1pvowhq1z/edfxnQ5kNO/sZMLJr+FqYvt oW6g5mSyGk3yZV+2Mxxi4G1mP830gYRl2SZg9J3vwQw6hdPjjIhUunnhxcm7KJUQfOgO xrvNCltPykJ9sJOKT6Sw5ZcF+6LxL+n0RKM/U2zhvBfV3BCyZ9kz3mpKZtSIByyz8QbX VfWvGeuH69BdN7o+GRQtlh8bFQqUHrPShVwyk8RBS/wQnatxWYea5U0IRrmYp3pFtvEB Yph74g5DOa/HCmKfimronDOa3KBvAeA4yxlHqxpsdTjusuiQ+A4aI3RwbeDKOATQggFa FYRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=l1h+R23KaO/5JZlKegdlnxLohpKnT1Qi+BI58QTPUtc=; b=EH48LQPmXiabL4/KowCYSEPLo05Jv6MuDiQFBeUgcvgClz2fFigfjv+iaqT+V/JSnD tX/iDmAbGh32JBjvuChPj68qc9f+qguukEmj6VKhcYGR/cT4eDc44NdX7Krzx3DYvyTI OsqKsWBMljz27ZqWVbuKgNVHVdra2YWYamNofKm3dzWjC5m1T82OFcJdHHC78OHKu0yb fYzkprXB3vLuP+OoE5A5sbN8/G5SHRKiF9R07tYSXUHCnsGC7ImhYSubLpy8g8+C0Q8F IFlaaJQTWAwnNLkBrw9OwXd6bJkzQiHVmCyfU9j01ZhvzT5NVhJVW0uSUOYj78yUzNI8 ehwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958660133940935?= X-GMAIL-MSGID: =?utf-8?q?1590959298924774655?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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; }