Message ID | 20230622085335.77010-28-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 BD120EB64DD for <linux-mm@archiver.kernel.org>; Thu, 22 Jun 2023 08:57:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C0228D000F; Thu, 22 Jun 2023 04:57:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 570638D0001; Thu, 22 Jun 2023 04:57:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4604D8D000F; Thu, 22 Jun 2023 04:57:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 377FA8D0001 for <linux-mm@kvack.org>; Thu, 22 Jun 2023 04:57:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0CB8F1C810D for <linux-mm@kvack.org>; Thu, 22 Jun 2023 08:57:43 +0000 (UTC) X-FDA: 80929780806.16.0458B99 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf13.hostedemail.com (Postfix) with ESMTP id 3C1532000C for <linux-mm@kvack.org>; Thu, 22 Jun 2023 08:57:40 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Kv6dWh2I; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf13.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687424261; 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=aRQUwtIbFrjRbKaWDWITc6Upds+hXxxlwcQqvFPvJow=; b=zfHRe1Fhk8MAL2GcrqeUovO7fRWk9/pgL/Y/8AQvs9quLA2danVoBUDbTArF8JGC8xVF9a mUoUcZCpaYOzrNoT0XGbvGyauGiW/TdWCi6AoOrwR+VhTt5tuYcZzNQ7IO8ylO1IIZeZoF H7T5S/tRoyMAxVVh5MMjxg3qB7kNaxY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Kv6dWh2I; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf13.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687424261; a=rsa-sha256; cv=none; b=2iH1Zx64m1kOvC0k6nM1tyG72X/HneShnwwddpNcFoQQyOACEJTpPTItUnI5g39Q5p+prD PdW58oBQoGBYwZQfGElNBAEoaRlstFggazHaWyj5rEvWXlWf8fum+12pPJpGHqbvT7aR75 1TBNWd/HTz2BMNNUQdk3PcEOVNiZC/M= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1b515ec39feso12624225ad.0 for <linux-mm@kvack.org>; Thu, 22 Jun 2023 01:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687424260; x=1690016260; 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=aRQUwtIbFrjRbKaWDWITc6Upds+hXxxlwcQqvFPvJow=; b=Kv6dWh2IIchnBu9RbCVLsx8HZLugRgYdolMOnFdVv/Mze68pcgFvadMFaompRsV/Ii Vr4ahAwXirWdfwADAjPFAtSTivwacduawKzyeKPVnp7cESQMTGYfaqAI7425tQvAdQ85 8rLDDpZCwcAbH67+6k+hMmW8Fi1etqH6LYFHkuQfbD+ESFiwPmeSocm5kXqI50kDiSjf PCd9vDumWTECSSKSpOEWhL8aCyPGbcSxO0SaB85LOV7uPD9a5LVIfvAATYV0qgfKCSQQ J+7inf8lDO5dvyUSQTFKKOcNdRaAbUMX2WbzVCHQayCH8tZA09PfVWiof+vKchWmVnWN 0e0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687424260; x=1690016260; 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=aRQUwtIbFrjRbKaWDWITc6Upds+hXxxlwcQqvFPvJow=; b=VBytiE382eWliQZ3RxTgAUj/XTJ4/tIQtLHauTRdj9nVbyWMk7imHnBPOZm8HtkQHK 3/fSDZd/R7URXypbejX7naXqjelrs1I0YwMtLXCI0p4L5nu75phPmEYXpifmDxmKZTq1 TmZWG15svXtNg0rHyo1ZipgendaySmnxIWVJoF++JIkoCMebWR1GLw8Fj8oZIQUL20kN e/1iBWx0KUc33FUbu+stdF2Obx8CrU/FIk0TGoTl+2Z9Lrn6E6HAG2h3S6Mba0oIXJ00 XJ/iILzRdBn1MiE+3I0CwmF/+Vj23xuHb1L3HoXyGdSUjFOewJ9DQCxHk7tpofKqgjQo wvTw== X-Gm-Message-State: AC+VfDyFE+ltHDKkmC/qnsJ2x4037liuuaC0v0hulYlJmvWG6GVfjniw 8oRgdLkBoL+H4opbvIs9I1lo+A== X-Google-Smtp-Source: ACHHUZ4KKZ8AXrupsFYw18EsJWvGfL6qm7cyYV/rSPTKOdYWRQ8IhOkLOim7I9s7W96jDohmbJS9Lg== X-Received: by 2002:a17:903:41d2:b0:1a6:cf4b:4d7d with SMTP id u18-20020a17090341d200b001a6cf4b4d7dmr21650808ple.2.1687424260203; Thu, 22 Jun 2023 01:57:40 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id h2-20020a170902f7c200b001b549fce345sm4806971plw.230.2023.06.22.01.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 01:57:39 -0700 (PDT) From: Qi Zheng <zhengqi.arch@bytedance.com> To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH 27/29] mm: vmscan: hold write lock to reparent shrinker nr_deferred Date: Thu, 22 Jun 2023 16:53:33 +0800 Message-Id: <20230622085335.77010-28-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230622085335.77010-1-zhengqi.arch@bytedance.com> References: <20230622085335.77010-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3C1532000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: b5hwup9nrwn6hjubhrpp7um4pi5tu7g3 X-HE-Tag: 1687424260-38298 X-HE-Meta: U2FsdGVkX1+fEBHUsXeOZ0w7AvuJjJZk/ZCN0yE3f3xx/M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UPK45cw7AetJhKVbc1Z+ngDAjyoNiREXuB7LbVWCbx53WJVmKU08guovmXps66r1H9Q3vsRt06HWgX1fmecZCUbwJ2JlMFgs9/SdIzHN12/EYjbgwyrE70HWAKkSuAfWaKkiet+qKWa7F432yATKtrAwaYIJCL9wB2GLL7wj0X3xsH67Ka1ks4wx6FK36w5PMe8has5zmWdJtTRmZBwLgcvuwdSAlRBmoqE1st5U3HDDH0IMxuWW9lI7TfRZ6JPoimBLu2nSl75b9YmYvA3oFnfJsh2aNscJUlh8iTVz+xMBe7B/rbI2yGeQiIp8Vru54Z8aYp9dtFHxXUkGtFVr1Z7YCA== 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 |
use refcount+RCU method to implement lockless slab shrink
|
expand
|
diff --git a/mm/vmscan.c b/mm/vmscan.c index 357a1f2ad690..0711b63e68d9 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -433,7 +433,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); @@ -442,7 +442,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(-)