From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbdBIGD6 (ORCPT ); Thu, 9 Feb 2017 01:03:58 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57374 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751480AbdBIGD4 (ORCPT ); Thu, 9 Feb 2017 01:03:56 -0500 Subject: Re: [PATCH 3/3] mm: Enable Buddy allocation isolation for CDM nodes To: Vlastimil Babka , Anshuman Khandual , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20170208140148.16049-1-khandual@linux.vnet.ibm.com> <20170208140148.16049-4-khandual@linux.vnet.ibm.com> <8ef1de25-d4fd-482c-c55e-df93d0730484@suse.cz> Cc: mhocko@suse.com, mgorman@suse.de, minchan@kernel.org, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, srikar@linux.vnet.ibm.com, haren@linux.vnet.ibm.com, jglisse@redhat.com, dave.hansen@intel.com, dan.j.williams@intel.com From: Anshuman Khandual Date: Thu, 9 Feb 2017 10:35:58 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <8ef1de25-d4fd-482c-c55e-df93d0730484@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020905-0044-0000-0000-000002288D3A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020905-0045-0000-0000-0000068083C5 Message-Id: <8982ccfc-3b96-89bd-60e6-471971aee609@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-09_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702090047 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/08/2017 10:48 PM, Vlastimil Babka wrote: > On 02/08/2017 03:01 PM, Anshuman Khandual wrote: >> This implements allocation isolation for CDM nodes in buddy allocator by >> discarding CDM memory zones all the time except in the cases where the >> gfp >> flag has got __GFP_THISNODE or the nodemask contains CDM nodes in cases >> where it is non NULL (explicit allocation request in the kernel or user >> process MPOL_BIND policy based requests). >> >> Signed-off-by: Anshuman Khandual >> --- >> mm/page_alloc.c | 19 +++++++++++++++++++ >> 1 file changed, 19 insertions(+) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 40908de..7d8c82a 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -64,6 +64,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -2908,6 +2909,24 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned >> int order, int alloc_flags, >> struct page *page; >> unsigned long mark; >> >> + /* >> + * CDM nodes get skipped if the requested gfp flag >> + * does not have __GFP_THISNODE set or the nodemask >> + * does not have any CDM nodes in case the nodemask >> + * is non NULL (explicit allocation requests from >> + * kernel or user process MPOL_BIND policy which has >> + * CDM nodes). >> + */ >> + if (is_cdm_node(zone->zone_pgdat->node_id)) { >> + if (!(gfp_mask & __GFP_THISNODE)) { >> + if (!ac->nodemask) >> + continue; >> + >> + if (!nodemask_has_cdm(*ac->nodemask)) >> + continue; > > nodemask_has_cdm() looks quite expensive, combined with the loop here > that's O(n^2). But I don't understand why you need it. If there is no > cdm node in the nodemask, then we never reach this code with a cdm node, > because the zonelist iterator already checks the nodemask? Am I missing > something? A CDM zone can be selected during zonelist iteration if (1) If nodemask is NULL (where all zones are eligible) (1) Skip it if __GFP_THISNODE is not mentioned (2) Pick it if __GFP_THISNODE is mentioned (2) If nodemask has CDM (where CDM zones are eligible) (1) Pick it if nodemask has CDM (2) Pick it if __GFP_THISNODE is mentioned (1) (1) Enforces the primary isolation (2) (1) Is the only option which could be O(n^2) as the worst case Checking for both the zone being a CDM zone and the nodemask containing CDM node has to happen together for (2) (1). But we dont run into this option unless we have first checked if request contains __GFP_THISNODE and that nodemask is really a non NULL value. Hence the number cases getting into (2) (1) should be less. IIUC only the user space MPOL_BIND ones will come here.