From patchwork Tue Mar 17 13:17:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikar Dronamraju X-Patchwork-Id: 11442909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FA9A1668 for ; Tue, 17 Mar 2020 13:20:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3EA7E20752 for ; Tue, 17 Mar 2020 13:20:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EA7E20752 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 546676B0006; Tue, 17 Mar 2020 09:20:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4F7216B0007; Tue, 17 Mar 2020 09:20:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40CAE6B0008; Tue, 17 Mar 2020 09:20:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id 29A6B6B0006 for ; Tue, 17 Mar 2020 09:20:48 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E6E63824556B for ; Tue, 17 Mar 2020 13:20:47 +0000 (UTC) X-FDA: 76604914134.21.bread72_23f2c99501452 X-Spam-Summary: 2,0,0,bdede46851bf2f24,d41d8cd98f00b204,srikar@linux.vnet.ibm.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1345:1359:1431:1437:1535:1542:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2553:2559:2562:2741:2915:3138:3139:3140:3141:3142:3353:3865:3867:3870:3871:4117:4321:5007:6261:6742:7903:7904:8660:10004:11026:11473:11658:11914:12043:12296:12297:12438:12555:12895:12986:13148:13221:13229:13230:13846:14181:14394:14721:14819:21080:21251:21451:21627:30054:30069:30070:30090,0,RBL:148.163.156.1:@linux.vnet.ibm.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:412,LUA_SUMMARY:none X-HE-Tag: bread72_23f2c99501452 X-Filterd-Recvd-Size: 6461 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Mar 2020 13:20:46 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02HD2XEZ103692 for ; Tue, 17 Mar 2020 09:20:45 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yrutkvs5x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Mar 2020 09:20:45 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Mar 2020 13:20:42 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 17 Mar 2020 13:20:39 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02HDKcvB62586982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Mar 2020 13:20:39 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DDE2DA405C; Tue, 17 Mar 2020 13:20:38 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1E50A405B; Tue, 17 Mar 2020 13:20:34 +0000 (GMT) Received: from srikart450.in.ibm.com (unknown [9.85.71.34]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Mar 2020 13:20:34 +0000 (GMT) From: Srikar Dronamraju To: Andrew Morton Cc: Srikar Dronamraju , linux-mm@kvack.org, Mel Gorman , Michael Ellerman , Sachin Sant , Michal Hocko , Christopher Lameter , linuxppc-dev@lists.ozlabs.org, Joonsoo Kim , Kirill Tkhai , Vlastimil Babka , Bharata B Rao Subject: [PATCH 1/4] mm: Check for node_online in node_present_pages Date: Tue, 17 Mar 2020 18:47:50 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200317131753.4074-1-srikar@linux.vnet.ibm.com> References: <3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com> <20200317131753.4074-1-srikar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20031713-0020-0000-0000-000003B5E0B2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20031713-0021-0000-0000-0000220E451C Message-Id: <20200317131753.4074-2-srikar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-17_04:2020-03-17,2020-03-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003170056 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Calling a kmalloc_node on a possible node which is not yet onlined can lead to panic. Currently node_present_pages() doesn't verify the node is online before accessing the pgdat for the node. However pgdat struct may not be available resulting in a crash. NIP [c0000000003d55f4] ___slab_alloc+0x1f4/0x760 LR [c0000000003d5b94] __slab_alloc+0x34/0x60 Call Trace: [c0000008b3783960] [c0000000003d5734] ___slab_alloc+0x334/0x760 (unreliable) [c0000008b3783a40] [c0000000003d5b94] __slab_alloc+0x34/0x60 [c0000008b3783a70] [c0000000003d6fa0] __kmalloc_node+0x110/0x490 [c0000008b3783af0] [c0000000003443d8] kvmalloc_node+0x58/0x110 [c0000008b3783b30] [c0000000003fee38] mem_cgroup_css_online+0x108/0x270 [c0000008b3783b90] [c000000000235aa8] online_css+0x48/0xd0 [c0000008b3783bc0] [c00000000023eaec] cgroup_apply_control_enable+0x2ec/0x4d0 [c0000008b3783ca0] [c000000000242318] cgroup_mkdir+0x228/0x5f0 [c0000008b3783d10] [c00000000051e170] kernfs_iop_mkdir+0x90/0xf0 [c0000008b3783d50] [c00000000043dc00] vfs_mkdir+0x110/0x230 [c0000008b3783da0] [c000000000441c90] do_mkdirat+0xb0/0x1a0 [c0000008b3783e20] [c00000000000b278] system_call+0x5c/0x68 Fix this by verifying the node is online before accessing the pgdat structure. Fix the same for node_spanned_pages() too. Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: Mel Gorman Cc: Michael Ellerman Cc: Sachin Sant Cc: Michal Hocko Cc: Christopher Lameter Cc: linuxppc-dev@lists.ozlabs.org Cc: Joonsoo Kim Cc: Kirill Tkhai Cc: Vlastimil Babka Cc: Srikar Dronamraju Cc: Bharata B Rao Reported-by: Sachin Sant Tested-by: Sachin Sant Signed-off-by: Srikar Dronamraju --- include/linux/mmzone.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index f3f264826423..88078a3b95e5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -756,8 +756,10 @@ typedef struct pglist_data { atomic_long_t vm_stat[NR_VM_NODE_STAT_ITEMS]; } pg_data_t; -#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages) -#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages) +#define node_present_pages(nid) \ + (node_online(nid) ? NODE_DATA(nid)->node_present_pages : 0) +#define node_spanned_pages(nid) \ + (node_online(nid) ? NODE_DATA(nid)->node_spanned_pages : 0) #ifdef CONFIG_FLAT_NODE_MEM_MAP #define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr)) #else From patchwork Tue Mar 17 13:17:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikar Dronamraju X-Patchwork-Id: 11442911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 796311668 for ; Tue, 17 Mar 2020 13:20:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42E3F20752 for ; Tue, 17 Mar 2020 13:20:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42E3F20752 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C4AF76B0007; Tue, 17 Mar 2020 09:20:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C246C6B0008; Tue, 17 Mar 2020 09:20:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEB986B000A; Tue, 17 Mar 2020 09:20:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 986046B0007 for ; Tue, 17 Mar 2020 09:20:50 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5A72152C0 for ; Tue, 17 Mar 2020 13:20:50 +0000 (UTC) X-FDA: 76604914260.17.cloth93_24600de86a834 X-Spam-Summary: 2,0,0,88fccde06692f793,d41d8cd98f00b204,srikar@linux.vnet.ibm.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1261:1345:1359:1431:1437:1535:1543:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3867:3871:4118:4321:4385:5007:6119:6261:6742:7903:7904:8660:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12555:12895:12986:13148:13221:13229:13230:13846:14096:14181:14394:14721:21080:21324:21451:21627:21990:30054,0,RBL:148.163.158.5:@linux.vnet.ibm.com:.lbl8.mailshell.net-64.201.201.201 62.8.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: cloth93_24600de86a834 X-Filterd-Recvd-Size: 7311 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Mar 2020 13:20:49 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02HDKIlp142761 for ; Tue, 17 Mar 2020 09:20:49 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2yty84887s-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Mar 2020 09:20:48 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Mar 2020 13:20:47 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 17 Mar 2020 13:20:43 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02HDKgZ145744366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Mar 2020 13:20:42 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BC45A405F; Tue, 17 Mar 2020 13:20:42 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59FE0A4054; Tue, 17 Mar 2020 13:20:39 +0000 (GMT) Received: from srikart450.in.ibm.com (unknown [9.85.71.34]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Mar 2020 13:20:39 +0000 (GMT) From: Srikar Dronamraju To: Andrew Morton Cc: Srikar Dronamraju , linux-mm@kvack.org, Mel Gorman , Michael Ellerman , Sachin Sant , Michal Hocko , Christopher Lameter , linuxppc-dev@lists.ozlabs.org, Joonsoo Kim , Kirill Tkhai , Vlastimil Babka , Bharata B Rao Subject: [PATCH 2/4] mm/slub: Use mem_node to allocate a new slab Date: Tue, 17 Mar 2020 18:47:51 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200317131753.4074-1-srikar@linux.vnet.ibm.com> References: <3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com> <20200317131753.4074-1-srikar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20031713-0020-0000-0000-000003B5E0B4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20031713-0021-0000-0000-0000220E451E Message-Id: <20200317131753.4074-3-srikar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-17_04:2020-03-17,2020-03-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=762 adultscore=0 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003170056 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently while allocating a slab for a offline node, we use its associated node_numa_mem to search for a partial slab. If we don't find a partial slab, we try allocating a slab from the offline node using __alloc_pages_node. However this is bound to fail. NIP [c00000000039a300] __alloc_pages_nodemask+0x130/0x3b0 LR [c00000000039a3c4] __alloc_pages_nodemask+0x1f4/0x3b0 Call Trace: [c0000008b36837f0] [c00000000039a3b4] __alloc_pages_nodemask+0x1e4/0x3b0 (unreliable) [c0000008b3683870] [c0000000003d1ff8] new_slab+0x128/0xcf0 [c0000008b3683950] [c0000000003d6060] ___slab_alloc+0x410/0x820 [c0000008b3683a40] [c0000000003d64a4] __slab_alloc+0x34/0x60 [c0000008b3683a70] [c0000000003d78b0] __kmalloc_node+0x110/0x490 [c0000008b3683af0] [c000000000343a08] kvmalloc_node+0x58/0x110 [c0000008b3683b30] [c0000000003ffd44] mem_cgroup_css_online+0x104/0x270 [c0000008b3683b90] [c000000000234e08] online_css+0x48/0xd0 [c0000008b3683bc0] [c00000000023dedc] cgroup_apply_control_enable+0x2ec/0x4d0 [c0000008b3683ca0] [c0000000002416f8] cgroup_mkdir+0x228/0x5f0 [c0000008b3683d10] [c000000000520360] kernfs_iop_mkdir+0x90/0xf0 [c0000008b3683d50] [c00000000043e400] vfs_mkdir+0x110/0x230 [c0000008b3683da0] [c000000000441ee0] do_mkdirat+0xb0/0x1a0 [c0000008b3683e20] [c00000000000b278] system_call+0x5c/0x68 Mitigate this by allocating the new slab from the node_numa_mem. Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: Mel Gorman Cc: Michael Ellerman Cc: Sachin Sant Cc: Michal Hocko Cc: Christopher Lameter Cc: linuxppc-dev@lists.ozlabs.org Cc: Joonsoo Kim Cc: Kirill Tkhai Cc: Vlastimil Babka Cc: Srikar Dronamraju Cc: Bharata B Rao Reported-by: Sachin Sant Tested-by: Sachin Sant Signed-off-by: Srikar Dronamraju --- mm/slub.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 1c55bf7892bf..fdf7f38f96e6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1970,14 +1970,8 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node, struct kmem_cache_cpu *c) { void *object; - int searchnode = node; - if (node == NUMA_NO_NODE) - searchnode = numa_mem_id(); - else if (!node_present_pages(node)) - searchnode = node_to_mem_node(node); - - object = get_partial_node(s, get_node(s, searchnode), c, flags); + object = get_partial_node(s, get_node(s, node), c, flags); if (object || node != NUMA_NO_NODE) return object; @@ -2470,6 +2464,11 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags, WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO)); + if (node == NUMA_NO_NODE) + node = numa_mem_id(); + else if (!node_present_pages(node)) + node = node_to_mem_node(node); + freelist = get_partial(s, flags, node, c); if (freelist) @@ -2569,12 +2568,10 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, redo: if (unlikely(!node_match(page, node))) { - int searchnode = node; - if (node != NUMA_NO_NODE && !node_present_pages(node)) - searchnode = node_to_mem_node(node); + node = node_to_mem_node(node); - if (unlikely(!node_match(page, searchnode))) { + if (unlikely(!node_match(page, node))) { stat(s, ALLOC_NODE_MISMATCH); deactivate_slab(s, page, c->freelist, c); goto new_slab; From patchwork Tue Mar 17 13:17:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikar Dronamraju X-Patchwork-Id: 11442913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A9281667 for ; Tue, 17 Mar 2020 13:20:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 20D3120752 for ; Tue, 17 Mar 2020 13:20:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20D3120752 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 398C46B0008; Tue, 17 Mar 2020 09:20:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 322786B000A; Tue, 17 Mar 2020 09:20:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 210636B000C; Tue, 17 Mar 2020 09:20:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 096946B0008 for ; Tue, 17 Mar 2020 09:20:55 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D1CF4181AC9B6 for ; Tue, 17 Mar 2020 13:20:54 +0000 (UTC) X-FDA: 76604914428.05.ducks79_2503f226bb628 X-Spam-Summary: 2,0,0,8957cca0c68d16e8,d41d8cd98f00b204,srikar@linux.vnet.ibm.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1345:1359:1431:1437:1535:1542:1711:1730:1747:1777:1792:1981:2194:2198:2199:2200:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3874:4250:4321:4605:5007:6261:6742:7903:7904:10004:11026:11658:11914:12043:12297:12555:12895:12986:13221:13229:13846:14181:14394:14721:21080:21451:21627:21990:30034:30054,0,RBL:148.163.158.5:@linux.vnet.ibm.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: ducks79_2503f226bb628 X-Filterd-Recvd-Size: 5952 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Mar 2020 13:20:54 +0000 (UTC) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02HD4FqD148238 for ; Tue, 17 Mar 2020 09:20:53 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yrt352uyp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Mar 2020 09:20:52 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Mar 2020 13:20:50 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 17 Mar 2020 13:20:47 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02HDKkMk55050322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Mar 2020 13:20:46 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DB5DA4060; Tue, 17 Mar 2020 13:20:46 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1331CA4054; Tue, 17 Mar 2020 13:20:43 +0000 (GMT) Received: from srikart450.in.ibm.com (unknown [9.85.71.34]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Mar 2020 13:20:42 +0000 (GMT) From: Srikar Dronamraju To: Andrew Morton Cc: Srikar Dronamraju , linux-mm@kvack.org, Mel Gorman , Michael Ellerman , Sachin Sant , Michal Hocko , Christopher Lameter , linuxppc-dev@lists.ozlabs.org, Joonsoo Kim , Kirill Tkhai , Vlastimil Babka , Bharata B Rao Subject: [PATCH 3/4] mm: Implement reset_numa_mem Date: Tue, 17 Mar 2020 18:47:52 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200317131753.4074-1-srikar@linux.vnet.ibm.com> References: <3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com> <20200317131753.4074-1-srikar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20031713-0016-0000-0000-000002F2929B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20031713-0017-0000-0000-00003356131A Message-Id: <20200317131753.4074-4-srikar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-17_04:2020-03-17,2020-03-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=974 mlxscore=0 spamscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 impostorscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003170056 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: For a memoryless or offline nodes, node_numa_mem refers to a N_MEMORY fallback node. Currently kernel has an API set_numa_mem that sets node_numa_mem for memoryless node. However this API cannot be used for offline nodes. Hence all offline nodes will have their node_numa_mem set to 0. However systems can themselves have node 0 as offline i.e memoryless and cpuless at this time. In such cases, node_to_mem_node() fails to provide a N_MEMORY fallback node. Mitigate this by having a new API that sets the default node_numa_mem for offline nodes to be first_memory_node. Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: Mel Gorman Cc: Michael Ellerman Cc: Sachin Sant Cc: Michal Hocko Cc: Christopher Lameter Cc: linuxppc-dev@lists.ozlabs.org Cc: Joonsoo Kim Cc: Kirill Tkhai Cc: Vlastimil Babka Cc: Srikar Dronamraju Cc: Bharata B Rao Reported-by: Sachin Sant Tested-by: Sachin Sant Signed-off-by: Srikar Dronamraju --- include/asm-generic/topology.h | 3 +++ include/linux/topology.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h index 238873739550..e803ee7850e6 100644 --- a/include/asm-generic/topology.h +++ b/include/asm-generic/topology.h @@ -68,6 +68,9 @@ #ifndef set_numa_mem #define set_numa_mem(node) #endif +#ifndef reset_numa_mem +#define reset_numa_mem(node) +#endif #ifndef set_cpu_numa_mem #define set_cpu_numa_mem(cpu, node) #endif diff --git a/include/linux/topology.h b/include/linux/topology.h index eb2fe6edd73c..bebda80038bf 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -147,6 +147,13 @@ static inline int node_to_mem_node(int node) } #endif +#ifndef reset_numa_mem +static inline void reset_numa_mem(int node) +{ + _node_numa_mem_[node] = first_memory_node; +} +#endif + #ifndef numa_mem_id /* Returns the number of the nearest Node with memory */ static inline int numa_mem_id(void) From patchwork Tue Mar 17 13:17:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikar Dronamraju X-Patchwork-Id: 11442925 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25A6D1668 for ; Tue, 17 Mar 2020 13:23:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0C8620752 for ; Tue, 17 Mar 2020 13:23:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0C8620752 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3E5396B0005; Tue, 17 Mar 2020 09:23:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3BC8B6B0006; Tue, 17 Mar 2020 09:23:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AE406B0007; Tue, 17 Mar 2020 09:23:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 12D1E6B0005 for ; Tue, 17 Mar 2020 09:23:33 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A3F671260 for ; Tue, 17 Mar 2020 13:23:32 +0000 (UTC) X-FDA: 76604921064.10.alarm59_3bfb9bb81fa4e X-Spam-Summary: 2,0,0,4d1cc047b3136678,d41d8cd98f00b204,srikar@linux.vnet.ibm.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1345:1359:1431:1437:1535:1541:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:2741:2898:2903:3138:3139:3140:3141:3142:3352:3865:3866:3871:3874:4321:5007:6261:6742:7903:7904:10004:11026:11658:11914:12296:12297:12438:12555:12895:12986:13069:13221:13229:13311:13357:13846:14096:14181:14384:14394:14721:21080:21451:21627:21740:21990:30054:30070,0,RBL:148.163.158.5:@linux.vnet.ibm.com:.lbl8.mailshell.net-64.201.201.201 62.8.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: alarm59_3bfb9bb81fa4e X-Filterd-Recvd-Size: 5337 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Mar 2020 13:23:32 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02HDNQaR114693 for ; Tue, 17 Mar 2020 09:23:31 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2yrr6u606u-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Mar 2020 09:23:29 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Mar 2020 13:20:55 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 17 Mar 2020 13:20:51 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02HDKoW951380454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Mar 2020 13:20:50 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 416F6A4060; Tue, 17 Mar 2020 13:20:50 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C6A1A4064; Tue, 17 Mar 2020 13:20:46 +0000 (GMT) Received: from srikart450.in.ibm.com (unknown [9.85.71.34]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Mar 2020 13:20:46 +0000 (GMT) From: Srikar Dronamraju To: Andrew Morton Cc: Srikar Dronamraju , linux-mm@kvack.org, Mel Gorman , Michael Ellerman , Sachin Sant , Michal Hocko , Christopher Lameter , linuxppc-dev@lists.ozlabs.org, Joonsoo Kim , Kirill Tkhai , Vlastimil Babka , Bharata B Rao Subject: [PATCH 4/4] powerpc/numa: Set fallback nodes for offline nodes Date: Tue, 17 Mar 2020 18:47:53 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200317131753.4074-1-srikar@linux.vnet.ibm.com> References: <3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com> <20200317131753.4074-1-srikar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20031713-0008-0000-0000-0000035EB8F3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20031713-0009-0000-0000-00004A800FA8 Message-Id: <20200317131753.4074-5-srikar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-17_04:2020-03-17,2020-03-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003170056 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently fallback nodes for offline nodes aren't set. Hence by default node 0 ends up being the default node. However node 0 might be offline. Fix this by explicitly setting fallback node. Ensure first_memory_node is set before kernel does explicit setting of fallback node. Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: Mel Gorman Cc: Michael Ellerman Cc: Sachin Sant Cc: Michal Hocko Cc: Christopher Lameter Cc: linuxppc-dev@lists.ozlabs.org Cc: Joonsoo Kim Cc: Kirill Tkhai Cc: Vlastimil Babka Cc: Srikar Dronamraju Cc: Bharata B Rao Reported-by: Sachin Sant Tested-by: Sachin Sant Signed-off-by: Srikar Dronamraju --- arch/powerpc/mm/numa.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 281531340230..6e97ab6575cb 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -827,7 +827,16 @@ void __init dump_numa_cpu_topology(void) if (!numa_enabled) return; - for_each_online_node(node) { + for_each_node(node) { + /* + * For all possible but not yet online nodes, ensure their + * node_numa_mem is set correctly so that kmalloc_node works + * for such nodes. + */ + if (!node_online(node)) { + reset_numa_mem(node); + continue; + } pr_info("Node %d CPUs:", node); count = 0;