Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10601101rwd; Thu, 22 Jun 2023 02:06:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ur/l2HT1E6zHgfo1Qc3k7ynV5C4Mi8bw231eJ4+T6ljOqRPr9Y+Tp8CHhfmVteAqryKec X-Received: by 2002:a05:6a21:32a3:b0:11f:64ec:694c with SMTP id yt35-20020a056a2132a300b0011f64ec694cmr11333134pzb.32.1687424819611; Thu, 22 Jun 2023 02:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687424819; cv=none; d=google.com; s=arc-20160816; b=GTOiMAA83QEii5UgOAGwHqoSz+rP2i+/fqo1Aa+YSgGOsLt5C1nuFVmS4xYjK64OOl K7Zx7jmX/5e0Tcq42JU75WH9Vgv7mxrtrjcpgOTLMBEpLE5LNGLbpOxg6QGrpWRxyQ+Q VuU9yT0lIWQaLr3KxM2Il5oP9c1usDJfAlZsUQPm3JE0fRZMm3k/Hqj1Hn7RvjpCq7MJ /Vr2cFdZIv9Tt2XxMz6gTiy9cK39L/uFNnlAl0yShU9Hn4/mKNAGHVArXQWivisCH5S9 igLVw88v4jKe0mHy06CZdAfCfTfWFi+1/fMjSEiHtOEVas68W4+GrrgsnlxCmj0zqTSq ifpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aRQUwtIbFrjRbKaWDWITc6Upds+hXxxlwcQqvFPvJow=; b=libKfIRiBx4ry7Pn6Hpg4sxPspMUMFa9RTZBKRsd3/psMQNxl9PYs+e/Cv1IGX/6qU NEx7jmFXM4vd61tXNLHJ9n3zupkZ8W8aUd8f2hCf/wE3k475skMvWLjDTasH7yDmbFdb Y2piUGByaM2rU5Fb6jKFAkmk4gGLha4Y4CZkorb44qvlXTK12p4Vg8WYh13f/JIcRv0S jrDSoruILQr3F5Kix3Hafk5pWwixz/m114eHukDlEsQk1skeiw/ASlZF7KRRwWDLm8FE H96Nf1BQ5BBwV8TMedGozHuN6HSpXVPDj8gvp6S/nGZka6Q9JX2OEgDBKZDcs5yu/ry2 Ml4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Kv6dWh2I; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a170902e34c00b001b530ede2ebsi4632931plc.119.2023.06.22.02.06.46; Thu, 22 Jun 2023 02:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Kv6dWh2I; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbjFVJGR (ORCPT + 99 others); Thu, 22 Jun 2023 05:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232107AbjFVJFE (ORCPT ); Thu, 22 Jun 2023 05:05:04 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA1E84C07 for ; Thu, 22 Jun 2023 01:58:21 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1b515ec39feso12624265ad.0 for ; Thu, 22 Jun 2023 01:58:21 -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=C/SCG0buu1akneM6v5lQCWsdZWnoo5LZPiAod9j2Ddjb+HlCdRC40+0s1D+kAtBI4H ntTmw+G9U2a6AOZwE5hzcNflQkJFwpvfPU0Cw6cW9auOG6Koxl2br/2TkO0e6087LpS5 sFTu4MyvnEEBUXKrqVuywDKuQDRISvCNarLj12pLC13q72gg3lp/5G4SarGmrcsjcQPX IhJCLUnEzJ5i1DmnKN2J1pvlLIof3GOlt7BrGRYxE3vrJ2Y3xQ/8SqBWcfg49NiXJOUj Qt+rgoNqkc4SnI06COyTsNXDPX98ENtuML2AfzM7aMDdJ/kdY+AHCWW1KB2B5kB6x4E4 knfg== X-Gm-Message-State: AC+VfDwZWln13e5gy2j3zUxm6gx7Mz+J+vIQX8B4zPa5W1Jm5bupqAO4 mOuaB8rlSXoZCKQLmcjyX4UEPg== 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 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 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.30.2