Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757312AbcJXEeA (ORCPT ); Mon, 24 Oct 2016 00:34:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39586 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757159AbcJXEcb (ORCPT ); Mon, 24 Oct 2016 00:32:31 -0400 From: Anshuman Khandual To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: mhocko@suse.com, js1304@gmail.com, vbabka@suse.cz, mgorman@suse.de, minchan@kernel.org, akpm@linux-foundation.org, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com Subject: [RFC 4/8] mm: Accommodate coherent device memory nodes in MPOL_BIND implementation Date: Mon, 24 Oct 2016 10:01:53 +0530 X-Mailer: git-send-email 2.1.0 In-Reply-To: <1477283517-2504-1-git-send-email-khandual@linux.vnet.ibm.com> References: <1477283517-2504-1-git-send-email-khandual@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16102404-0012-0000-0000-000003438AC0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16102404-0013-0000-0000-0000198A5EDF Message-Id: <1477283517-2504-5-git-send-email-khandual@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-23_18:,, 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-1609300000 definitions=main-1610240081 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1899 Lines: 50 This change is part of the isolation requiring coherent device memory nodes implementation. Currently MPOL_MBIND interface simply fails on a coherent device memory node after the zonelist changes introduced earlier. Without __GFP_THISNODE flag, the first node of the nodemask will not be selected in the case where the local node (where the application is executing) is not part of the user provided nodemask for MPOL_MBIND. This will be the case for coherent memory nodes which are always CPU less. This changes the mbind() system call implementation so that memory can be allocated from coherent memory node through MPOL_MBIND interface. Signed-off-by: Anshuman Khandual --- mm/mempolicy.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 0b859af..cb1ba01 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1694,6 +1694,26 @@ static struct zonelist *policy_zonelist(gfp_t gfp, struct mempolicy *policy, if (unlikely(gfp & __GFP_THISNODE) && unlikely(!node_isset(nd, policy->v.nodes))) nd = first_node(policy->v.nodes); + +#ifdef CONFIG_COHERENT_DEVICE + /* + * Coherent device memory + * + * In case the local node is not part of the nodemask, test if + * the first node in the nodemask is a coherent device memory + * node in which case select it. + * + * FIXME: The check will be restricted to the first node of the + * nodemask or scan through the nodemask to select any present + * coherent device memory node on it or select the first one if + * all of the nodes in the nodemask are coherent device memory. + * These are various approaches possible. + */ + if (unlikely(!node_isset(nd, policy->v.nodes))) { + if (isolated_cdm_node(first_node(policy->v.nodes))) + nd = first_node(policy->v.nodes); + } +#endif break; default: BUG(); -- 2.1.0