From: Lai Jiangshan <laijs@linux.alibaba.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <laijs@linux.alibaba.com>,
Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH 3/4] workqueue: add a BUILD_BUG_ON() to check the size of struct pool_workqueue
Date: Mon, 1 Jun 2020 08:44:41 +0000 [thread overview]
Message-ID: <20200601084442.8284-4-laijs@linux.alibaba.com> (raw)
In-Reply-To: <20200601084442.8284-1-laijs@linux.alibaba.com>
Currently, the size of struct pool_workqueue is smaller than the
smellest requirement (1 << WORK_STRUCT_FLAG_BITS). When the size
of struct pool_workqueue is increasing in future development and
exceed the smellest requirement a little, it will be a big waste
due to alignment.
Add a check in case we don't skimp enough in future.
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
---
kernel/workqueue.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 35120b909234..1921c982f920 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5907,6 +5907,14 @@ void __init workqueue_init_early(void)
BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long));
+ /*
+ * If it complains when being built, there might be considerable
+ * memory waste in struct pool_workqueue. Whatever the reason is,
+ * an updated check here or a re-arrangement in
+ * struct pool_workqueue is required.
+ */
+ BUILD_BUG_ON(sizeof(struct pool_workqueue) > (1 << WORK_STRUCT_FLAG_BITS));
+
BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL));
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(hk_flags));
--
2.20.1
next prev parent reply other threads:[~2020-06-01 8:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 8:44 [PATCH 0/4] workqueue: reduce the sizeof pool_workqueue Lai Jiangshan
2020-06-01 8:44 ` [PATCH 1/4] workqueue: fix a piece of comment about reserved bits for work flags Lai Jiangshan
2020-06-01 8:44 ` [PATCH 2/4] workqueue: use BUILD_BUG_ON() for compile time test instead of WARN_ON() Lai Jiangshan
2020-06-01 15:08 ` Tejun Heo
2020-06-01 8:44 ` Lai Jiangshan [this message]
2020-06-01 8:44 ` [PATCH 4/4] workqueue: slash half memory usage in 32bit system Lai Jiangshan
2020-06-01 15:07 ` Tejun Heo
2020-06-02 0:08 ` Lai Jiangshan
2020-06-02 16:18 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200601084442.8284-4-laijs@linux.alibaba.com \
--to=laijs@linux.alibaba.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome