Received: by 10.223.176.5 with SMTP id f5csp2396810wra; Thu, 8 Feb 2018 13:23:57 -0800 (PST) X-Google-Smtp-Source: AH8x226H41TCEbM4V5bfucuUEu3midhgLO0kSQ4GAECEei7SSnty/IPyFLanD7UeO91UcXRpjpOV X-Received: by 10.98.186.18 with SMTP id k18mr394760pff.115.1518125037438; Thu, 08 Feb 2018 13:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518125037; cv=none; d=google.com; s=arc-20160816; b=BSXnVP6akdmtXSIPvqfZ+sB2qkQC7H4hjyuf8vxiwEX9Y7zhbMkZ0iciNN/YBrYEb1 rWlNNHKTvvEXBjFy5L94GRbmFMZdY8aJecTHS6+YWYYPUbeDd6SSf0j3g1K7I/os0wmX oyewQryVMwSvGEgWqQ8fH12m1hUGkDMU5B70oZnlpFlfsDMDt1S1ry57Jd4lA9KqT1Vu utkWXoqzY+8rIextb/P/ff58zow3AtIfeo9Y33q5q681OjHf0jiPKqfvPNm4Wa2LbiRv jjymVQwcKTJMvh4UZRvpF0Qj1xcKZaPF89f6FtiWSephxSMJ6VWBcfrGmqex+f0I3hoW uLog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iKxBVWYOp+5udxSR9vPjjqVL5lA4xCorB25nEZNc28c=; b=nNSUuEPw0wQXil//4hQJd7xVRXFcPhfcPeRAVdMJIAo/w6LJlLHezMaUDzBMSdF66G 6zWwgSWIEPVnNcc28qsEOq/Aa/iemyPHZM+HK7UOgY8yj+XtA7LGt/1uVF1eklNl/Bby AMcPPouxfy8AieXwwZgyBkTrDrayI+baj8SGIL4EIVn67PHTP4L8jklCXiOg6YxNdtsz VqYmoxvYsavRvyJFggsnyryOW4mqxZnojz64dqE47gPFjyAJ8cSAnJn541dnteNFw8KF omdcbpp0xXYB39eVtlkqjHS573LaSEhfZ45pkfYNWWqqmCaZEVhS5xkyG08L2NBUE+kf HHXg== 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 d13si444909pgf.26.2018.02.08.13.23.41; Thu, 08 Feb 2018 13:23:57 -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 S1752540AbeBHVVo (ORCPT + 99 others); Thu, 8 Feb 2018 16:21:44 -0500 Received: from mga18.intel.com ([134.134.136.126]:21394 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752519AbeBHVVl (ORCPT ); Thu, 8 Feb 2018 16:21:41 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 13:21:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,480,1511856000"; d="scan'208";a="29299067" Received: from alexey-system-product-name.iil.intel.com ([10.236.193.131]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2018 13:21:37 -0800 From: Alexey Skidanov To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Alexey Skidanov Subject: [PATCH] mm: Free CMA pages to the buddy allocator instead of per-cpu-pagelists Date: Thu, 8 Feb 2018 23:21:53 +0200 Message-Id: <1518124913-31290-1-git-send-email-alexey.skidanov@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current code frees pages to the per-cpu-pagelists (pcp) according to their migrate type. The exception is isolated pages that are freed directly to the buddy allocator. The pages are marked as isolate to indicate the buddy allocator that they are not supposed to be allocated as opposite to the pages located in the pcp lists that are immediate candidates for the upcoming allocation requests. This was likely an oversight when the CMA migrate type was added. As a result of this, freed CMA pages go to the MIGRATE_MOVABLE per-cpu-list. This sometime leads to CMA page allocation instead of Movable one, increasing the probability of CMA page pining, which may cause to CMA allocation failure. In addition, there is no gain to free CMA page to the pcp because the CMA pages mainly allocated for DMA purpose. To fix this, we free CMA page directly to the buddy allocator. This avoids the CMA page allocation instead of MOVABLE one. Actually, the CMA pages are very similar to the isolated ones - both of them should not be supposed as immediate candidates for upcoming allocation requests and thus shouldn't be freed to pcp. I've audited all the other checks for isolated pageblocks to ensure that this mistake was not repeated elsewhere. Signed-off-by: Alexey Skidanov --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 59d5921..9a76b68 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2644,7 +2644,8 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn) * excessively into the page allocator */ if (migratetype >= MIGRATE_PCPTYPES) { - if (unlikely(is_migrate_isolate(migratetype))) { + if (unlikely(is_migrate_isolate(migratetype) || + is_migrate_cma(migratetype))) { free_one_page(zone, page, pfn, 0, migratetype); return; } -- 2.7.4