From patchwork Tue Jul 28 09:55:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Qiang" X-Patchwork-Id: 11688769 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 9603C138A for ; Tue, 28 Jul 2020 09:45:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62F7E20838 for ; Tue, 28 Jul 2020 09:45:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62F7E20838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 871056B0023; Tue, 28 Jul 2020 05:45:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7FB9C6B0024; Tue, 28 Jul 2020 05:45:46 -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 6EAAA6B0025; Tue, 28 Jul 2020 05:45:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 53EF86B0023 for ; Tue, 28 Jul 2020 05:45:46 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0EBD3A8EA for ; Tue, 28 Jul 2020 09:45:46 +0000 (UTC) X-FDA: 77087002692.23.angle87_2e0619d26f68 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id D4ABC37612 for ; Tue, 28 Jul 2020 09:45:45 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,qiang.zhang@windriver.com,,RULES_HIT:30003:30054:30090,0,RBL:192.103.53.11:@windriver.com:.lbl8.mailshell.net-64.10.201.10 62.18.0.100;04yfdfti4dznp143uhaj1hce1hthhyc4c46c7u1kuwhn3sq5itbuoh4fiyk4w8o.z6tdyh91jdsqaobpxbz1gh3wx97ha11r35mxnwm8kktgqyqzrf84tm45mqhxxja.y-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: angle87_2e0619d26f68 X-Filterd-Recvd-Size: 2528 Received: from mail5.wrs.com (mail5.windriver.com [192.103.53.11]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Jul 2020 09:45:44 +0000 (UTC) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id 06S9iHF0005340 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 28 Jul 2020 02:44:28 -0700 Received: from pek-lpg-core1-vm1.wrs.com (128.224.156.106) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.487.0; Tue, 28 Jul 2020 02:44:07 -0700 From: To: , , , , CC: , Subject: [PATCH] mm/slab.c: add node spinlock protect in __cache_free_alien Date: Tue, 28 Jul 2020 17:55:51 +0800 Message-ID: <20200728095551.30634-1-qiang.zhang@windriver.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: D4ABC37612 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Zhang Qiang We should add node spinlock protect "n->alien" which may be assigned to NULL in cpuup_canceled func. cause address access exception. Fixes: 18bf854117c6 ("slab: use get_node() and kmem_cache_node() functions") Signed-off-by: Zhang Qiang --- mm/slab.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index a89633603b2d..290523c90b4e 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -759,8 +759,10 @@ static int __cache_free_alien(struct kmem_cache *cachep, void *objp, n = get_node(cachep, node); STATS_INC_NODEFREES(cachep); + spin_lock(&n->list_lock); if (n->alien && n->alien[page_node]) { alien = n->alien[page_node]; + spin_unlock(&n->list_lock); ac = &alien->ac; spin_lock(&alien->lock); if (unlikely(ac->avail == ac->limit)) { @@ -769,14 +771,15 @@ static int __cache_free_alien(struct kmem_cache *cachep, void *objp, } ac->entry[ac->avail++] = objp; spin_unlock(&alien->lock); - slabs_destroy(cachep, &list); } else { + spin_unlock(&n->list_lock); n = get_node(cachep, page_node); spin_lock(&n->list_lock); free_block(cachep, &objp, 1, page_node, &list); spin_unlock(&n->list_lock); - slabs_destroy(cachep, &list); } + + slabs_destroy(cachep, &list); return 1; }