From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42A6BC4332D for ; Fri, 20 Mar 2020 08:45:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0D28620714 for ; Fri, 20 Mar 2020 08:45:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D28620714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A36626B0003; Fri, 20 Mar 2020 04:45:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E71C6B0006; Fri, 20 Mar 2020 04:45:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D5636B0007; Fri, 20 Mar 2020 04:45:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 7210C6B0003 for ; Fri, 20 Mar 2020 04:45:00 -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 1F27D181AC9BF for ; Fri, 20 Mar 2020 08:45:00 +0000 (UTC) X-FDA: 76615105560.05.rub18_82eb77979c115 X-HE-Tag: rub18_82eb77979c115 X-Filterd-Recvd-Size: 6317 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Mar 2020 08:44:59 +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 02K8XpMe003592 for ; Fri, 20 Mar 2020 04:44:59 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2yvqkdn3d3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 20 Mar 2020 04:44:58 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Mar 2020 08:44:57 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) 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) Fri, 20 Mar 2020 08:44:53 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02K8ipRF51904590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2020 08:44:51 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3807A4040; Fri, 20 Mar 2020 08:44:51 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FC9CA4053; Fri, 20 Mar 2020 08:44:49 +0000 (GMT) Received: from in.ibm.com (unknown [9.85.95.122]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 20 Mar 2020 08:44:49 +0000 (GMT) Date: Fri, 20 Mar 2020 14:14:47 +0530 From: Bharata B Rao To: Vlastimil Babka Cc: Sachin Sant , Nathan Lynch , Srikar Dronamraju , linuxppc-dev@lists.ozlabs.org, Michal Hocko , Pekka Enberg , linux-mm@kvack.org, Kirill Tkhai , David Rientjes , Christopher Lameter , Mel Gorman , Joonsoo Kim , Michael Ellerman , puvichakravarthy@in.ibm.com Subject: Re: [RFC 1/2] mm, slub: prevent kmalloc_node crashes and memory leaks Reply-To: bharata@linux.ibm.com References: <20200318144220.18083-1-vbabka@suse.cz> <20200318160610.GD26049@in.ibm.com> <0F67B5AA-96DF-4977-BDC6-D72959B3F7EF@linux.vnet.ibm.com> <658E6AB8-581F-4722-BCBB-4BDD2245D265@linux.vnet.ibm.com> <339cf655-393e-c48e-4797-86f61df56c35@suse.cz> <20200320034241.GE26049@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-TM-AS-GCONF: 00 x-cbid: 20032008-0016-0000-0000-000002F45BE7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20032008-0017-0000-0000-00003357E9B7 Message-Id: <20200320084447.GF26049@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-20_01:2020-03-19,2020-03-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 malwarescore=0 impostorscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003200035 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: On Fri, Mar 20, 2020 at 09:37:18AM +0100, Vlastimil Babka wrote: > On 3/20/20 4:42 AM, Bharata B Rao wrote: > > On Thu, Mar 19, 2020 at 02:47:58PM +0100, Vlastimil Babka wrote: > >> diff --git a/mm/slub.c b/mm/slub.c > >> index 17dc00e33115..7113b1f9cd77 100644 > >> --- a/mm/slub.c > >> +++ b/mm/slub.c > >> @@ -1973,8 +1973,6 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int 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); > >> if (object || node != NUMA_NO_NODE) > >> @@ -2563,17 +2561,27 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, > >> struct page *page; > >> > >> page = c->page; > >> - if (!page) > >> + if (!page) { > >> + /* > >> + * if the node is not online or has no normal memory, just > >> + * ignore the node constraint > >> + */ > >> + if (unlikely(node != NUMA_NO_NODE && > >> + !node_state(node, N_NORMAL_MEMORY))) > >> + node = NUMA_NO_NODE; > >> goto new_slab; > >> + } > >> 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); > >> - > >> - if (unlikely(!node_match(page, searchnode))) { > >> + /* > >> + * same as above but node_match() being false already > >> + * implies node != NUMA_NO_NODE > >> + */ > >> + if (!node_state(node, N_NORMAL_MEMORY)) { > >> + node = NUMA_NO_NODE; > >> + goto redo; > >> + } else { > >> stat(s, ALLOC_NODE_MISMATCH); > >> deactivate_slab(s, page, c->freelist, c); > >> goto new_slab; > > > > This fixes the problem I reported at > > https://lore.kernel.org/linux-mm/20200317092624.GB22538@in.ibm.com/ > > Thanks, I hope it means I can make it Reported-and-tested-by: you It was reeported first by PUVICHAKRAVARTHY RAMACHANDRAN You can add my tested-by. Regards, Bharata.