From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbdA3DiP (ORCPT ); Sun, 29 Jan 2017 22:38:15 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56808 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751918AbdA3Dhu (ORCPT ); Sun, 29 Jan 2017 22:37:50 -0500 From: Anshuman Khandual To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: mhocko@suse.com, vbabka@suse.cz, 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 Subject: [RFC V2 04/12] mm: Change mbind(MPOL_BIND) implementation for CDM nodes Date: Mon, 30 Jan 2017 09:05:45 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170130033602.12275-1-khandual@linux.vnet.ibm.com> References: <20170130033602.12275-1-khandual@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17013003-0048-0000-0000-0000020002F9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17013003-0049-0000-0000-00004771DDBD Message-Id: <20170130033602.12275-5-khandual@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-30_02:,, 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-1701300038 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CDM nodes need a way of explicit memory allocation mechanism from the user space. After the previous FALLBACK zonelist rebuilding process changes, the mbind(MPOL_BIND) based allocation request fails on the CDM node. This is because allocation requesting local node's FALLBACK zonelist is selected for further nodemask processing targeted at MPOL_BIND implementation. As the CDM node's zones are not part of any other regular node's FALLBACK zonelist, the allocation simply fails without getting any valid zone. The allocation requesting node is always going to be different than the CDM node which does not have any CPU. Hence MPOL_MBIND implementation must choose given CDM node's FALLBACK zonelist instead of the requesting local node's FALLBACK zonelist. This implements that change. Signed-off-by: Anshuman Khandual --- mm/mempolicy.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 1e7873e..6089c711 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1692,6 +1692,27 @@ static struct zonelist *policy_zonelist(gfp_t gfp, struct mempolicy *policy, WARN_ON_ONCE(policy->mode == MPOL_BIND && (gfp & __GFP_THISNODE)); } +#ifdef CONFIG_COHERENT_DEVICE + /* + * Coherent Device Memory (CDM) + * + * In case the local requesting node is not part of the nodemask, test + * if the first node in the nodemask is CDM, in which case select it. + * + * XXX: There are multiple ways of doing this. This node check can be + * restricted to the first node in the node mask as implemented here or + * scan through the entire nodemask to find out any present CDM node on + * it or select the first CDM node only if all other nodes in the node + * mask are CDM. These are variour approaches possible, the first one + * is implemented here. + */ + if (policy->mode == MPOL_BIND) { + if (unlikely(!node_isset(nd, policy->v.nodes))) { + if (is_cdm_node(first_node(policy->v.nodes))) + nd = first_node(policy->v.nodes); + } + } +#endif return node_zonelist(nd, gfp); } -- 2.9.3