From patchwork Thu Jul 30 02:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Qiang" X-Patchwork-Id: 11692227 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 970EB14DD for ; Thu, 30 Jul 2020 02:40:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6436722B48 for ; Thu, 30 Jul 2020 02:40:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6436722B48 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 4FF266B0007; Wed, 29 Jul 2020 22:40:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4AFB56B0008; Wed, 29 Jul 2020 22:40:52 -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 3C7086B000A; Wed, 29 Jul 2020 22:40:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 27BCD6B0007 for ; Wed, 29 Jul 2020 22:40:52 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CBFD28E78 for ; Thu, 30 Jul 2020 02:40:51 +0000 (UTC) X-FDA: 77093189502.29.comb04_1901efc26f77 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 9E83718086E26 for ; Thu, 30 Jul 2020 02:40:51 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,qiang.zhang@windriver.com,,RULES_HIT:30045:30054:30070:30075:30090,0,RBL:147.11.1.11:@windriver.com:.lbl8.mailshell.net-62.18.0.75 64.10.201.10;04yf9x1pobjskhwhgi61hz4d6qnimocguxugz6buyixa1uxh7ujwyhi5b1u8krr.i3wkgfxxchaays4ambutxrm8iej7rfcwyiquonuyyujojg3kps6yco7bpkxwyx6.k-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: comb04_1901efc26f77 X-Filterd-Recvd-Size: 2784 Received: from mail.windriver.com (mail.windriver.com [147.11.1.11]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 30 Jul 2020 02:40:50 +0000 (UTC) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id 06U2efi2012132 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 29 Jul 2020 19:40:41 -0700 (PDT) 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; Wed, 29 Jul 2020 19:40:40 -0700 From: To: , , , , CC: , Subject: [PATCH v2] mm/slab.c: add node spinlock protect in __cache_free_alien Date: Thu, 30 Jul 2020 10:52:26 +0800 Message-ID: <20200730025226.10350-1-qiang.zhang@windriver.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 9E83718086E26 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 Due to cpu hotplug, the "cpuup_canceled" func be called, it's currently manipulating the alien cache for the canceled cpu's node and this node may be the same as the node which node's alien cache being operated in the "__cache_free_alien" func, so we should add a protect for node's alien cache in "__cache_free_alien" func. Fixes: 6731d4f12315 ("slab: Convert to hotplug state machine") Signed-off-by: Zhang Qiang --- v1->v2: change submission information and fixes tags. 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; }