Message ID | 20230226144655.79778-7-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93C39C64ED6 for <linux-mm@archiver.kernel.org>; Sun, 26 Feb 2023 14:48:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39F716B007D; Sun, 26 Feb 2023 09:48:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34F486B007E; Sun, 26 Feb 2023 09:48:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 219BB6B0080; Sun, 26 Feb 2023 09:48:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0EC646B007D for <linux-mm@kvack.org>; Sun, 26 Feb 2023 09:48:48 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E12221C5D79 for <linux-mm@kvack.org>; Sun, 26 Feb 2023 14:48:47 +0000 (UTC) X-FDA: 80509724694.25.0BADB9A Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf21.hostedemail.com (Postfix) with ESMTP id 1B8141C000D for <linux-mm@kvack.org>; Sun, 26 Feb 2023 14:48:45 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=lIKiq8Er; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677422926; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=c6cuoJEo92PScDqgnKjc0MgPFLiMUUPUvBDJj7SgxHo=; b=XgpIithzxhJvVsUarXMz5TL2uhJbvFUQK5uHALkILAs64Jc39hkEn+y/bwRCwEsAud0jbd rgVKLrhzwCzdN5g8nh2wYWt3ULQltznGsyQB0WAHrCQDu5rb6MnYK3+MS0oeVuMpOE4L65 I8HMa3WmWOI5eeh2ntqSjlVuIdJOim8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=lIKiq8Er; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677422926; a=rsa-sha256; cv=none; b=ZUlrke+CKLvI46mjxeDKk9WNlAp07iKAAg5gNMfCfiWDW1/HvN4KUnLz9c4+JgA5TKTIkx 9piylUEbl3UgrjEsNkF4t3RbO06ZrQ1ipzBxnaHNMKDPz+PrqHGpIFS57FoSqNkv9VahGC nxOAYcYsg8gRk7dBQjX8naxVV3nb2X0= Received: by mail-pl1-f171.google.com with SMTP id bh1so4177179plb.11 for <linux-mm@kvack.org>; Sun, 26 Feb 2023 06:48:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1677422925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c6cuoJEo92PScDqgnKjc0MgPFLiMUUPUvBDJj7SgxHo=; b=lIKiq8ErtDRmfz+i/ano83moR805w7pQEVFBs5DWz8iogOWtMgCKlWMtTjjG4CUYGf qZUEa/ayLAYcSmEePRMBNnD4UMS+HxFoUzmlroe0ZVHuqZ3z2bv2HGbh7Yq0wKCvHk4k QE8yyj88IWGiNyUTVZhSPdvEoYldgr4C6pMLd3y42cOtg65TmytTMhFeDnjLzWUSuqD4 9aNiX3gjRzbrv4MYxQIZGaPfntfaShxVFiNdV3/73U+gNlaqjtHmoW98ZiAC2kGLB21U 7G4hnPw+a24oAWIJ7kfT7KLIQYmuet0PscCXlnmSZhQ2rIyHh9ik/cyvUbqhLd+kEnv8 Uwjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677422925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c6cuoJEo92PScDqgnKjc0MgPFLiMUUPUvBDJj7SgxHo=; b=LMpmzeks2mwr4szAExhGREinpguTYvQcypAqo+UMiekncWnKlTjZ3lncbuChz5YnNL OyXcgm9TLR8qaqmKUbyGbmSaGbfk1U8hTWqQ15cqyBPXMliYcBweyR5RumRMJWSXdSqM Jg1ue9bW0+w430RqjvcPrMpLafg+AzjrJVoEK6r7WYEGBYrWjjD8Qq1PKsiem5SsQO/3 dxp34fGsAeriNKh3ZgWLVOIJHsRmgFMQaLAvEQT/fCFPaRcAzOk8OC6q3gYC7pZ0zCQG X1UuTHiy5sm8/Qy8MZIcaYbHCal2EqRBtZvnFC72/J5dkpqcJGAYhFZXB8VAVzXh/ssq ujNg== X-Gm-Message-State: AO0yUKWC1Zr4O7orkOBPztBgLXT1y3dQ5UrlTTtlY2gX5oNsfZeJd/Td Cr/zPaD+uZ1j/DqfG0hnvc1leA== X-Google-Smtp-Source: AK7set+XvuciT55+1IMf9hAHsturuZDzsZyl61PmuY/3HoeWXaqHrVSGXMTK34S3WOCoi78lnQD8RA== X-Received: by 2002:a17:902:bb0f:b0:197:8e8e:f15 with SMTP id im15-20020a170902bb0f00b001978e8e0f15mr23385229plb.6.1677422925086; Sun, 26 Feb 2023 06:48:45 -0800 (PST) Received: from localhost.localdomain ([139.177.225.248]) by smtp.gmail.com with ESMTPSA id y20-20020a170902ed5400b0019c2cf12d15sm2755589plb.116.2023.02.26.06.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 06:48:44 -0800 (PST) From: Qi Zheng <zhengqi.arch@bytedance.com> To: akpm@linux-foundation.org, tkhai@ya.ru, hannes@cmpxchg.org, shakeelb@google.com, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, david@redhat.com, shy828301@gmail.com Cc: sultan@kerneltoast.com, dave@stgolabs.net, penguin-kernel@I-love.SAKURA.ne.jp, paulmck@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH v3 6/8] mm: vmscan: hold write lock to reparent shrinker nr_deferred Date: Sun, 26 Feb 2023 22:46:53 +0800 Message-Id: <20230226144655.79778-7-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230226144655.79778-1-zhengqi.arch@bytedance.com> References: <20230226144655.79778-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1B8141C000D X-Stat-Signature: orkrbd64gfdooxndueqycj14crjnhytf X-HE-Tag: 1677422925-457733 X-HE-Meta: U2FsdGVkX1+R+KJlXjHhk8iROShnD9RGKMbxJDLWzsNdd1Plnw/QTymCNZuPVICh4gaFTKrkV8APFkAMkpMWklQD6s4cfxRW0H8ry3sR2FwUGza0XKt+g7vIKBp+KNZSYEPjAoj1zMj14DVwYIyofyz/umJtyUYDjRXetCHH8+mZr6zMWtfc2ebyKHSEGzG/lP3YjAssIwmAooKRAqAhpGr4M8yoBSyksXHjoGgWUQ6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UUlgZzVJ96GQbJGx66M+reW2L1LHIujysidWj0XJwdGPg5DI4zfyFE+U5qhObDNdb3fPpVyZXD5lX/cnbHScuyfL+HgjTej+rKEqlS0Hh4RqI9RCyU9Qub3ajVM7N1Yfx0Nti1dDXkdmrbQ/gZl3kS2n2zmgGinRm5y 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: <linux-mm.kvack.org> |
Series |
make slab shrink lockless
|
expand
|
diff --git a/mm/vmscan.c b/mm/vmscan.c index 99e852c0ab9e..16ff64813175 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -451,7 +451,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg) parent = root_mem_cgroup; /* Prevent from concurrent shrinker_info expand */ - down_read(&shrinker_rwsem); + down_write(&shrinker_rwsem); for_each_node(nid) { child_info = shrinker_info_protected(memcg, nid); parent_info = shrinker_info_protected(parent, nid); @@ -460,7 +460,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg) atomic_long_add(nr, &parent_info->nr_deferred[i]); } } - up_read(&shrinker_rwsem); + up_write(&shrinker_rwsem); } static bool cgroup_reclaim(struct scan_control *sc)
For now, reparent_shrinker_deferred() is the only holder of read lock of shrinker_rwsem. And it already holds the global cgroup_mutex, so it will not be called in parallel. Therefore, in order to convert shrinker_rwsem to shrinker_mutex later, here we change to hold the write lock of shrinker_rwsem to reparent. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)