From nobody Sat Jul 25 04:53:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 943803438BD; Fri, 17 Jul 2026 17:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784308749; cv=none; b=XlPYwRmsaaQ+Erkws9YkW6IoPjGj0tVra0sj7eb1FzbqOeI8OrO/FQ8UXfmXPY9jks9sGVFBcAgLGIEnrm/Ugf8U4VgsHKsXbDB5+UvjENJMFCLB8L3sv0AShMFPpKtDSl3fV5/S5OaZ8O+0MJo8JhkaqkX+wxiXvVh71aLTBBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784308749; c=relaxed/simple; bh=gy2q0RK7WDIkIOGW93hsTcCDqk61g8WyUGqOEI/CueU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ObTfHd2OLp4A/W3fCUqpAuaq8CPaY5EgTjkFiijsnr00Pk8tzw5JmqvgQ1X6WtrykEofdv+kI6WHGZ1MF5OyUAXpSfDjQugIc4HBvF4cBLJaDKpzep+44tOwZpwtiUkM7VJOTZs9jHtoY7N1WypkqKt5h41/pIJScEe+pyTUl1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kRf0u4qE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kRf0u4qE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA9811F00A3A; Fri, 17 Jul 2026 17:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784308748; bh=UnHkVLMCAQLQ4+B9er/X7SytQ44lCRGiRd6XPR5oP94=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kRf0u4qE80aV1ogajGbTyHdXWPlHKbE/VDn6x8aVweD54mvFOkEHhUTXxOFlJx7TF 38wNt/63GXdBRVHUq+8rkUzmgcBrVH7/zYeCkmi5ovM2ZSiMOU2v2HiSzHWpRhA7aX P/xzZfB12XnJ7K2G3IBa3UFxi8q/j4gd/k9z/o90d451S1pAw4C0uo6wQ90XC8bY4z fcJBzDTkCASxwiTspwIsq2jrywly81dyDcAvZK+w9sT4VyLNzRyIu/jUJ480umW5Ly Eji2UGevleFA1PobcZzS7lmRyKgib0I4c5Jx+O8gRRQRKenUWu/5kzi709ygeG0PSH XHaBIP0fzQh9A== From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Daniel Jordan , Steffen Klassert , Eric Biggers Subject: [PATCH 1/2] padata: Mark remaining code as __init and data as __initdata Date: Fri, 17 Jul 2026 10:18:30 -0700 Message-ID: <20260717171831.27994-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260717171831.27994-1-ebiggers@kernel.org> References: <20260717171831.27994-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since the serialized job support was removed from padata, the remaining code is used only by the multithreaded job support, whose public functions are __init. Therefore, also mark the internal functions as __init and the internal data as __initdata. This makes them be discarded after the kernel boots. It also eliminates the need to mark padata_work_init() as __ref. Signed-off-by: Eric Biggers Reviewed-by: Daniel Jordan --- kernel/padata.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/kernel/padata.c b/kernel/padata.c index 6eb130d31024..e7f89e3e44e9 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -31,9 +31,9 @@ struct padata_work { void *pw_data; }; =20 -static DEFINE_SPINLOCK(padata_works_lock); -static struct padata_work *padata_works; -static LIST_HEAD(padata_free_works); +static __initdata DEFINE_SPINLOCK(padata_works_lock); +static __initdata struct padata_work *padata_works; +static __initdata LIST_HEAD(padata_free_works); =20 struct padata_mt_job_state { spinlock_t lock; @@ -46,7 +46,7 @@ struct padata_mt_job_state { =20 static void __init padata_mt_helper(struct work_struct *work); =20 -static struct padata_work *padata_work_alloc(void) +static struct padata_work *__init padata_work_alloc(void) { struct padata_work *pw; =20 @@ -60,16 +60,8 @@ static struct padata_work *padata_work_alloc(void) return pw; } =20 -/* - * This function is marked __ref because this function may be optimized in= such - * a way that it directly refers to work_fn's address, which causes modpos= t to - * complain when work_fn is marked __init. This scenario was observed with= clang - * LTO, where padata_work_init() was optimized to refer directly to - * padata_mt_helper() because the calls to padata_work_init() with other w= ork_fn - * values were eliminated or inlined. - */ -static void __ref padata_work_init(struct padata_work *pw, work_func_t wor= k_fn, - void *data, int flags) +static void __init padata_work_init(struct padata_work *pw, work_func_t wo= rk_fn, + void *data, int flags) { if (flags & PADATA_WORK_ONSTACK) INIT_WORK_ONSTACK(&pw->pw_work, work_fn); @@ -98,7 +90,7 @@ static int __init padata_work_alloc_mt(int nworks, void *= data, return i; } =20 -static void padata_work_free(struct padata_work *pw) +static void __init padata_work_free(struct padata_work *pw) { lockdep_assert_held(&padata_works_lock); list_add(&pw->pw_list, &padata_free_works); --=20 2.55.0 From nobody Sat Jul 25 04:53:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A24D1344D92; Fri, 17 Jul 2026 17:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784308749; cv=none; b=UOGtGvVFGk5bGZAhzNPH5Ib19ffM51pdy5d9l5d7jodxgduWehZihvggUoIQrKSgir4xUqHKkScGRfkiSqUqoaHHb5FeWnJMfwzmGw50As9rWbzyrTAknsZuqCkHjym/WeXrFBW5XlMeRwEbUorSSBntvaBCOn5QLiuMcOyaf58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784308749; c=relaxed/simple; bh=mXPn6s7C8Yhd1oSMkIbEUnvqqM3b1cHQpmNzRefZ1KQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DKYWf7c1yLsOkcFZjvGD1xLjV9WcybA9r9aMFI3daJI4lyUPjkfk6EaWNM4zCwtUTfDcze/ZrKy5LlTe1cpIaqzwZ38jibdzx6posgsNEhEJmhMcWLhmrTcKzfG83u5vfTfrDXICA/EQDR3jcYkZvDwZdm9JRYtzo6J6NIm7ucw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M99CA3MG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M99CA3MG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A1EA1F00A3E; Fri, 17 Jul 2026 17:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784308748; bh=aCaoliOTEjCXok/Twq0CGRKlTzYFk428lNaVQzhxRRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M99CA3MGC/ybAH7nrwoURHGzWuL86s2FIEeLeA/wCwlwiVqgTFMau0euDZnbXvcqN 6CZ/2401Iezvf7keRvpjDojW5cIMurIghZxOfQYUmU5RlAB7lQ4/bd2sGm/jAibjOv Th5Mk+VqRHT2/ZREtuoJ80LFz4CGwqRvImzOD+Bgb84XHcciAHBTWW7DO7UEYWbC8d wQP/x3rH4rUrJcUiEl5b1jrGMLBxSP+qY3DUES5cVby39/3vxs2mVSrJs9JvpzhWWO PLkDpJrEp4JLUKEV4MI2RfZxzxVskupkhKYHdJKKyGXF0ukXIfP25EcB3qF27oeO1n V7NJdLI2yWrlQ== From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Daniel Jordan , Steffen Klassert , Eric Biggers Subject: [PATCH 2/2] padata: Free the padata_works when they're no longer needed Date: Fri, 17 Jul 2026 10:18:31 -0700 Message-ID: <20260717171831.27994-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260717171831.27994-1-ebiggers@kernel.org> References: <20260717171831.27994-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The memory pointed to by 'padata_works' is never freed. Originally this was necessary because it was used to support the serialized job APIs used by pcrypt, which can be used long after boot. However, now that's been removed, and the remaining code in padata.c is used only at boot time. The pointer 'padata_works' is now __initdata. The result is that this essentially turned into a memory leak. Fix it. Signed-off-by: Eric Biggers Reviewed-by: Daniel Jordan --- kernel/padata.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/padata.c b/kernel/padata.c index e7f89e3e44e9..a28fe0c4f66b 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -230,3 +230,12 @@ void __init padata_init(void) for (i =3D 0; i < possible_cpus; ++i) list_add(&padata_works[i].pw_list, &padata_free_works); } + +static int __init padata_exit(void) +{ + kfree(padata_works); + padata_works =3D NULL; + INIT_LIST_HEAD(&padata_free_works); + return 0; +} +late_initcall_sync(padata_exit); --=20 2.55.0