From nobody Wed Nov 27 21:37:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1690445427; cv=none; d=zohomail.com; s=zohoarc; b=LZORLntNKBCvZDsIgWEY51Dfpx9U4HpSnaYbM/TSWKF9O9OEFv8XDaOp6RfpnYpXX31fUQdnFiLEfctNCCrpSRFMjdnSWu4b3oZauuX1IioqA42Kg1ivhpYWIl7dGGXWK255jYD2cCczUTQBwBZJfmKu4tm/PmnZgr9Opv4QGKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445427; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zAZIQD5LE19JLWIPx8KiiULhQHk9tWBr8sqfFcta/MI=; b=hzC7xTjgCizjTwuYaeScNUWp8uTX77l74sBDeI05GrH9tbexwEl9PeqWDFwLZCuivm7rF4IGpRXwFKljJLCiw3+1WOdNI08a1TY/cMiMWrAez+1ZSNoEGTw0MyfF1f6+PTs33v+FXWhud+WcVAgrk4DRDKxpJ7ELWUXSz6GBPQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690445427271534.5270368143046; Thu, 27 Jul 2023 01:10:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570858.893189 (Exim 4.92) (envelope-from ) id 1qOw4X-00009j-QC; Thu, 27 Jul 2023 08:10:09 +0000 Received: by outflank-mailman (output) from mailman id 570858.893189; Thu, 27 Jul 2023 08:10:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw4X-00009Z-NR; Thu, 27 Jul 2023 08:10:09 +0000 Received: by outflank-mailman (input) for mailman id 570858; Thu, 27 Jul 2023 08:10:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw4W-0005Vh-Iy for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:10:08 +0000 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [2607:f8b0:4864:20::436]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id febf9b3f-2c54-11ee-8613-37d641c3527e; Thu, 27 Jul 2023 10:10:06 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6862d4a1376so189008b3a.0 for ; Thu, 27 Jul 2023 01:10:06 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:10:04 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: febf9b3f-2c54-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445405; x=1691050205; 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=zAZIQD5LE19JLWIPx8KiiULhQHk9tWBr8sqfFcta/MI=; b=NqYwP+7q26BX+05EQAE55Kus0VTZ4uDrn8hA+JsQeQZJT9fqe02P3PtEqTbWL+ex0x YIFFlprB9LN8XpWOyzBWvs6bF2o1el7zRiKvHm2Vd5z2Or8QA2PiX1E8ylBDH7Szeeh9 /iQcvqB1l/KdO3epgECrqpXSIR/s/RJamq92lbZYEsjapR5/FUExLIHgiZunap4eHVCx zA39TmQ89NL3AupWiP9iOshQQO6k89rLp1YMDCuDF8tqw1FNGVEm51b05cxcsW4A6ycO oxBBen2ORAG64Kh5EsfwftGMbRswk1n9HcylImCxbc9GAVmkCHyiC5Q0TKVbaeRFnqta TxEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445405; x=1691050205; 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=zAZIQD5LE19JLWIPx8KiiULhQHk9tWBr8sqfFcta/MI=; b=QbzMAGoczIfyXl5S8CxvYiK4v2mFWMbHhLd7bpOQ7pFqQURzvYM5nUZ6PJMgRs6+jf w5Sa6HeCn10PGYBvIM6LXcVwWzIaKR6JZEXGkn3zXahWslGueul4qmQ6k0rx2/KfIwXN yTb/smojVnVm8WKWtxwkRFz3+rjgFkJjDrrpOK3trsLHhSAb3fYc5K0K9vB6uP8w9sxm GbQx6fgo1h1+jQZMq3r3r0zYOxLycUMHp8gow2FqhICIv/tOVQZ77nKncntenMYNHYVJ ZY3s8NA3xyUV7qP/rznyiISPDnNjBOqvXf1X+bpEEKwB7matBDPX8RgYQNKaq3exZD8Z YaXw== X-Gm-Message-State: ABy/qLZLE3UONh3kxhQEpPd5lRyip7QdppI2UXpCh+jDYrOuk7+JX5qi Ss19lSoVgjZAoAOYH9ugayDYoA== X-Google-Smtp-Source: APBJJlGpZH0OiKzZvwM26WklEwoVdvnyU6bL6rc8uFjIqbOYU7fWKIX23eNXK117O9K5uschqUp2Jg== X-Received: by 2002:a05:6a00:4a83:b0:679:a1f1:a5f8 with SMTP id dr3-20020a056a004a8300b00679a1f1a5f8mr4623296pfb.3.1690445405268; Thu, 27 Jul 2023 01:10:05 -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, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mtd@lists.infradead.org, rcu@vger.kernel.org, netdev@vger.kernel.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-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Qi Zheng Subject: [PATCH v3 21/49] mm: thp: dynamically allocate the thp-related shrinkers Date: Thu, 27 Jul 2023 16:04:34 +0800 Message-Id: <20230727080502.77895-22-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1690445429195100001 Content-Type: text/plain; charset="utf-8" Use new APIs to dynamically allocate the thp-zero and thp-deferred_split shrinkers. Signed-off-by: Qi Zheng --- mm/huge_memory.c | 69 +++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e371503f7746..a0dbb55b4913 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -65,7 +65,11 @@ unsigned long transparent_hugepage_flags __read_mostly = =3D (1<count_objects =3D shrink_huge_zero_page_count; + huge_zero_page_shrinker->scan_objects =3D shrink_huge_zero_page_scan; + huge_zero_page_shrinker->seeks =3D DEFAULT_SEEKS; + shrinker_register(huge_zero_page_shrinker); + + deferred_split_shrinker->count_objects =3D deferred_split_count; + deferred_split_shrinker->scan_objects =3D deferred_split_scan; + deferred_split_shrinker->seeks =3D DEFAULT_SEEKS; + shrinker_register(deferred_split_shrinker); + + return 0; +} + +static void __init thp_shrinker_exit(void) +{ + shrinker_free(huge_zero_page_shrinker); + shrinker_free(deferred_split_shrinker); +} + static int __init hugepage_init(void) { int err; @@ -482,12 +516,9 @@ static int __init hugepage_init(void) if (err) goto err_slab; =20 - err =3D register_shrinker(&huge_zero_page_shrinker, "thp-zero"); - if (err) - goto err_hzp_shrinker; - err =3D register_shrinker(&deferred_split_shrinker, "thp-deferred_split"); + err =3D thp_shrinker_init(); if (err) - goto err_split_shrinker; + goto err_shrinker; =20 /* * By default disable transparent hugepages on smaller systems, @@ -505,10 +536,8 @@ static int __init hugepage_init(void) =20 return 0; err_khugepaged: - unregister_shrinker(&deferred_split_shrinker); -err_split_shrinker: - unregister_shrinker(&huge_zero_page_shrinker); -err_hzp_shrinker: + thp_shrinker_exit(); +err_shrinker: khugepaged_destroy(); err_slab: hugepage_exit_sysfs(hugepage_kobj); @@ -2833,7 +2862,7 @@ void deferred_split_folio(struct folio *folio) #ifdef CONFIG_MEMCG if (memcg) set_shrinker_bit(memcg, folio_nid(folio), - deferred_split_shrinker.id); + deferred_split_shrinker->id); #endif } spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags); @@ -2907,14 +2936,6 @@ static unsigned long deferred_split_scan(struct shri= nker *shrink, return split; } =20 -static struct shrinker deferred_split_shrinker =3D { - .count_objects =3D deferred_split_count, - .scan_objects =3D deferred_split_scan, - .seeks =3D DEFAULT_SEEKS, - .flags =3D SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE | - SHRINKER_NONSLAB, -}; - #ifdef CONFIG_DEBUG_FS static void split_huge_pages_all(void) { --=20 2.30.2