From nobody Mon Feb 9 17:23:03 2026 Received: from sg-1-102.ptr.blmpb.com (sg-1-102.ptr.blmpb.com [118.26.132.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BFDE3009E8 for ; Thu, 25 Dec 2025 08:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.102 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766650991; cv=none; b=jQqJJ0w3KbZEKrbeUA7BCWnuXNk3vsxA+yjAzBUm/m2FI4QocFHFC/icKZmj7Y+dIXek8bCb+ASezpzYgjEVJi6g1JbzC5/ZvNry7nEaOHd0zIRbo4V6BbiuX23FxVOJ8SOFILVKBBUCOHXuGg+oaQiQ682zdsA4GMJHf96eB2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766650991; c=relaxed/simple; bh=19IHJqxk/M2ErNLlDY57SvL6MQfjDBDHkQlYc5XLWKw=; h=From:Subject:Date:Content-Type:Mime-Version:In-Reply-To:Cc: Message-Id:References:To; b=rqm8aIyAvuouUp6uMtzqJSGpsSwICAna+Ln88SsFOgjApfvkzV++yXQyJHBVKG8Fk7uiLRqaPQxGC+PBtT/zsX16hq7552PrGhuHZ/MsDpfWjCrmaM1H7Cd1yZG4fYtMxv9EvL6Vp6PnKrmVtSVCFfn68oeA1GTZc3Or1MbzwYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=gGRlztR3; arc=none smtp.client-ip=118.26.132.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="gGRlztR3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1766650981; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=qUNVArIPsex5nogpbUGIxGPpwCyLHHmHwDKuXvJThPk=; b=gGRlztR3UjiRFRm4IOTs+IqU445D+8rupQB8fnJSn0F27FJtLkk0e6UqNNeQx+ybxznj3z POqIH/2v4/9JyNSNWr14bEeVbIZ+gcR5xbWe+aQ4pDewjMiPP01objFdxZCgQgw7Zokm04 uhlsvdbWXiQ8ImsWfVSJMkLGFouYWxv3ulVfreB7UcGNQwdptCUSo520OhEjOuMJSHtpi1 om+2/SfxBX7S8wa3kVO9hT3Kx4aUtdVE8MIR3XRdlwxOOgeNrmW3A0NAer3bN5dVNIkYdm mDwe6KAjRAMWWxx4qb5P7h4npE09KqovlDicdBkOHBdkhYi8Q1P4TSHibQnGww== From: =?utf-8?q?=E6=9D=8E=E5=96=86?= Subject: [PATCH 8/8] mm/hugetlb: limit event generation frequency of function do_zero_free_notify() Date: Thu, 25 Dec 2025 16:20:59 +0800 X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Lms-Return-Path: X-Original-From: lizhe.67@bytedance.com Content-Transfer-Encoding: quoted-printable In-Reply-To: <20251225082059.1632-1-lizhe.67@bytedance.com> Cc: , , Message-Id: <20251225082059.1632-9-lizhe.67@bytedance.com> References: <20251225082059.1632-1-lizhe.67@bytedance.com> To: , , , , Content-Type: text/plain; charset="utf-8" From: Li Zhe Throttling notifications reduces the number of scheduling notify_work making the mechanism far more efficient when huge numbers of huge folios are freed in rapid succession. Signed-off-by: Li Zhe --- mm/hugetlb_sysfs.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb_sysfs.c b/mm/hugetlb_sysfs.c index c063237249f6..dd47d48fe910 100644 --- a/mm/hugetlb_sysfs.c +++ b/mm/hugetlb_sysfs.c @@ -341,6 +341,8 @@ static bool hugetlb_sysfs_initialized __ro_after_init; struct node_hstate_item { struct kobject *hstate_kobj; struct work_struct notify_work; + unsigned long notified_at; + spinlock_t notify_lock; }; =20 /* @@ -364,11 +366,30 @@ static void pre_zero_notify_fun(struct work_struct *w= ork) sysfs_notify(item->hstate_kobj, NULL, "zeroable_hugepages"); } =20 +static void __do_zero_free_notify(struct node_hstate_item *item) +{ + unsigned long last; + unsigned long next; + +#define PRE_ZERO_NOTIFY_MIN_INTV DIV_ROUND_UP(HZ, 100) + spin_lock(&item->notify_lock); + last =3D item->notified_at; + next =3D last + PRE_ZERO_NOTIFY_MIN_INTV; + if (time_in_range(jiffies, last, next)) { + spin_unlock(&item->notify_lock); + return; + } + item->notified_at =3D jiffies; + spin_unlock(&item->notify_lock); + + schedule_work(&item->notify_work); +} + void do_zero_free_notify(struct hstate *h, int nid) { struct node_hstate *nhs =3D &node_hstates[nid]; =20 - schedule_work(&nhs->items[hstate_index(h)].notify_work); + __do_zero_free_notify(&nhs->items[hstate_index(h)]); } =20 static ssize_t zeroable_hugepages_show(struct kobject *kobj, @@ -593,6 +614,8 @@ void hugetlb_register_node(struct node *node) break; } INIT_WORK(&item->notify_work, pre_zero_notify_fun); + item->notified_at =3D jiffies; + spin_lock_init(&item->notify_lock); } } =20 --=20 2.20.1