Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10591444rwd; Thu, 22 Jun 2023 01:59:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NNow3eEJbK/1CCXxyqbTSnoAmW4MI959RXLiwmBsTsfxoRhPG/kJj2bOtG5vMts9hdN7S X-Received: by 2002:a05:620a:6846:b0:75d:54fc:47b1 with SMTP id ru6-20020a05620a684600b0075d54fc47b1mr20973704qkn.54.1687424345751; Thu, 22 Jun 2023 01:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687424345; cv=none; d=google.com; s=arc-20160816; b=rQVEXHyGAapBXRxNS+mNyF9cKyedFnIGVJSwglRbPCvFgk/qked/48gS23G706XxqK EaxV0FowAN4dWC6uCdRUlhoI4f9QuofDPJAiVL8D6o0sNRP+Qpxs6MHos2tPhzNqu4Z+ Ygs/wwYkbO2LvY1aKSkx4S5iBAzvTeuByiRlOzHDwd4zCAsyXjKgUjWaCIcG5d9cW7DW mt2YX5xRqoAmH84rhFxNcwaTwB21j/hVeNDeTcooHM/L8yxLFuhNU/Stbh+uctbwxQPn McRlsnVCocrV53KrrMCriXUB5EE0KVAT/oMxwacy2iCkIyoHzGfOz1su1zaDuSvBaKsm s0zQ== 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=u/vExFBLW3qTniAw4XeP9KQ69i9zow/4wwrpInqlwjM=; b=QPV+vl2M+PS3aXtWxGOtC7SsSbvXAyc9avieIfkeLJmlQU4ACTEw2/Ph/G4dxkIIhW 9NRdUKlKo8NWEd0eg5duRicbWp5RMVYdqhq0BvERmCeBSS31/vFVNHXeQ+urHqFHFjwn wZr9qfL1JzJx/hjmRGTCqsdqBPsw8QVAZ4K6JLlQi/35lblGHpsCAswhR2RmCGiFV0Vb ScyY0ovx9u4fuQr6xefJCNV0PKP3wgYXozhAOzHQBxU2kKkF5rrl0ZxQ1k2SwloRruDt 0sQ5U0kx+B9/gz4fLu61trOsGhWuT9Q0zINkBuL7XKDl8Znoz3Vu993WbSBw8VxIIwWP +bEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="f9niG/1n"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 h127-20020a636c85000000b0055373328de5si5702326pgc.204.2023.06.22.01.58.53; Thu, 22 Jun 2023 01:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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="f9niG/1n"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S229993AbjFVI6N (ORCPT + 99 others); Thu, 22 Jun 2023 04:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjFVI50 (ORCPT ); Thu, 22 Jun 2023 04:57:26 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1BE526AE for ; Thu, 22 Jun 2023 01:55:23 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b52418c25bso12032695ad.0 for ; Thu, 22 Jun 2023 01:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687424123; x=1690016123; 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=u/vExFBLW3qTniAw4XeP9KQ69i9zow/4wwrpInqlwjM=; b=f9niG/1nDZCnLyGAdmXOPnr0UhYRgdnlIknKHTp5fpAvQQctnSzqFRWkCf20Ww177d QG9jeeQWMuTex/IwaFDMA8vXlH6fpJPO6Zn2dpmhMfbdqmxsLU2UIGO2NDOzTGYWiDw7 ywIPFwnvUTjEHuZeccmcjrjEkLsXSYquHahbHd6ZdjnzqEP2RHdSMNMWgiY9L8TVZ0lC G4aVTSqjJ5NrWtnVCJTDf1mbR/bEFK3aai4gwzFQmPA34Ikuzxs8i6IqNfr5Nxc5N0yO /Hq8+LGyQI4XHPCqHbrNX4k2UTVR4h1zk7vD27aNaHUnKMeOkCqJba/XQtzAGJZToHzN Aj7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687424123; x=1690016123; 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=u/vExFBLW3qTniAw4XeP9KQ69i9zow/4wwrpInqlwjM=; b=FjS5Penydj0+5Fb7TtIIjgJxc4i3uci6srWLc00K62ntUwj4s7oTZag0lsCL4N6B+z nSNPGml+xOTUpk/jeikrO+eai8ldTAM/spw1eHQBtiPzsqhxT5q3FYswyO6k43QD2Fmi G60VomULawu6iKbC9VhrOAfPDyR/lDCi1z+ZiPLDmzdyuFrxrf6OtGX24jT+2azH9ImC YtBNUZO+JZMK/xR5aKY4m8BqEmjoTYkGQgA78kFfNkj4+t7bqVPH1QfYmM31kj4AHXkK WzEpOol3/fVzGvR3UZZgc5zZabd8R7itN9RxNCrsQfdaGAQGSxr33dlwBw8U8PEeYyO+ LMow== X-Gm-Message-State: AC+VfDw3ekPlayu6YDalWq8ocAw/uup/hnggCfOFZT1QZfp8NRG5ECXy A6m4lKYBZ3mFAhWypQxgb9AEpA== X-Received: by 2002:a17:902:dac6:b0:1a1:956d:2281 with SMTP id q6-20020a170902dac600b001a1956d2281mr22035085plx.3.1687424123198; Thu, 22 Jun 2023 01:55:23 -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.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 01:55:22 -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 10/29] vmw_balloon: dynamically allocate the vmw-balloon shrinker Date: Thu, 22 Jun 2023 16:53:16 +0800 Message-Id: <20230622085335.77010-11-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-nfs@vger.kernel.org In preparation for implementing lockless slab shrink, we need to dynamically allocate the vmw-balloon shrinker, so that it can be freed asynchronously using kfree_rcu(). Then it doesn't need to wait for RCU read-side critical section when releasing the struct vmballoon. Signed-off-by: Qi Zheng --- drivers/misc/vmw_balloon.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 9ce9b9e0e9b6..2f86f666b476 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -380,7 +380,7 @@ struct vmballoon { /** * @shrinker: shrinker interface that is used to avoid over-inflation. */ - struct shrinker shrinker; + struct shrinker *shrinker; /** * @shrinker_registered: whether the shrinker was registered. @@ -1569,7 +1569,7 @@ static unsigned long vmballoon_shrinker_count(struct shrinker *shrinker, static void vmballoon_unregister_shrinker(struct vmballoon *b) { if (b->shrinker_registered) - unregister_shrinker(&b->shrinker); + unregister_and_free_shrinker(b->shrinker); b->shrinker_registered = false; } @@ -1581,14 +1581,18 @@ static int vmballoon_register_shrinker(struct vmballoon *b) if (!vmwballoon_shrinker_enable) return 0; - b->shrinker.scan_objects = vmballoon_shrinker_scan; - b->shrinker.count_objects = vmballoon_shrinker_count; - b->shrinker.seeks = DEFAULT_SEEKS; + b->shrinker = shrinker_alloc_and_init(vmballoon_shrinker_count, + vmballoon_shrinker_scan, + 0, DEFAULT_SEEKS, 0, b); + if (!b->shrinker) + return -ENOMEM; - r = register_shrinker(&b->shrinker, "vmw-balloon"); + r = register_shrinker(b->shrinker, "vmw-balloon"); if (r == 0) b->shrinker_registered = true; + else + shrinker_free(b->shrinker); return r; } -- 2.30.2