From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-121.mta0.migadu.com [91.218.175.121]) (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 B18A914EC73 for ; Mon, 17 Aug 2026 06:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.121 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786948031; cv=none; b=E19T9Ob9wM7lnBOsdmcvUyEfEVDUA/FPKXWo3H0BDdxhddP5cBZeIXKjeINTB5Ir9utDOXiZJa1jAuvarZ13AVsSW/Keee0b80jEDbZ1F4qbzweujxrZf6vQNpSWTq5pE+GX19yII6bXgMaQ1mdAEq8XKECBIVmSUKBlFJiF3q8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786948031; c=relaxed/simple; bh=GCy+WguWNDQlk/N3Wy1cyqoO2byfKnIj9nX7d8+026w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lJhoSFolDiSD+YLJLH2Tvj3G6OwHWceI83lYSUp1BtSk3BkM0cvIi4bB4L03VotS9Bk9BNt9B9XpcPPFzS+CvtOGyVhVZQtuLoMqnM81O6IxP3tMNbXodnLOjliff6Cs8cVotexgroyFQuNSIilfzWk+yjzNOILldw48EbgMf4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kFbNfxaJ; arc=none smtp.client-ip=91.218.175.121 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kFbNfxaJ" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=GCy+WguWNDQlk/N3Wy1cyqoO2byfKnIj9nX7d8+026w=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786948027; v=1; x=1787552827; b=kFbNfxaJSQd+teceRATDLlPSixZxjsV8yAQQTFTaMNe/YvC9puCwBjg/ettFEm6/+fUoaNbb 7MJJxnolOK4L7K4Dggjgc45fFCIIlCWx7ogYTjXWmjiLaaleurv36c2Zf/w0ohsYoqzFQ9Y07Pl tkd57W5y/eedfZCdfiZwQUbg= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost.localdomain (116.128.244.169) by smtp.migadu.com with ESMTPS id b5ed0a00273cb5ad; Mon, 17 Aug 2026 06:27:07 +0000 X-Migadu-Flow: FLOW_OUT From: Hao Ge To: Suren Baghdasaryan , Kent Overstreet , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Hao Ge , Sashiko , stable@vger.kernel.org Subject: [PATCH 2/2] alloc_tag: remove /proc/allocinfo outside of mod_lock Date: Mon, 17 Aug 2026 14:27:26 +0800 Message-Id: <20260817062726.106511-3-hao.ge@linux.dev> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260817062726.106511-1-hao.ge@linux.dev> References: <20260817062726.106511-1-hao.ge@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit shutdown_mem_profiling() calls remove_proc_entry() from reserve_module_tags(), which runs under mod_lock held for write. remove_proc_entry() waits for readers, and a reader takes mod_lock for read in allocinfo_start(): CPU0 (insmod) CPU1 (read /proc/allocinfo) ---------------- ---------------------------- reserve_module_tags() down_write(&mod_lock) [held] use_pde() [in_use++] allocinfo_start() down_read(&mod_lock) <- blocks shutdown_mem_profiling() remove_proc_entry() wait for in_use == 0 <- blocks Move remove_proc_entry() to a workqueue. Reported-by: Sashiko Fixes: 4835f747d3ed ("alloc_tag: support for page allocation tag compression") Cc: stable@vger.kernel.org Signed-off-by: Hao Ge --- mm/alloc_tag.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c index 80eccaca665a..b1d48532a25a 100644 --- a/mm/alloc_tag.c +++ b/mm/alloc_tag.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -591,6 +592,13 @@ void pgalloc_tag_swap(struct folio *new, struct folio *old) put_page_tag_ref(handle_new); } +static void remove_allocinfo_file(struct work_struct *work) +{ + remove_proc_entry(ALLOCINFO_FILE_NAME, NULL); +} + +static DECLARE_WORK(remove_allocinfo_work, remove_allocinfo_file); + static void shutdown_mem_profiling(bool remove_file) { if (mem_alloc_profiling_enabled()) @@ -600,7 +608,7 @@ static void shutdown_mem_profiling(bool remove_file) return; if (remove_file) - remove_proc_entry(ALLOCINFO_FILE_NAME, NULL); + schedule_work(&remove_allocinfo_work); mem_profiling_support = false; } -- 2.25.1