mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] lockdep: optimise "struct lock_class" layout
Date: Thu, 16 Nov 2023 14:25:35 +0300	[thread overview]
Message-ID: <e527403e-9be1-4aa2-98c0-a3ab1f02787f@p183> (raw)

struct lock_class does

	const struct lock_trace *	usage_traces[];
	int				name_version;
	const char *			name;

which wastes 4 bytes after "name_version".

Put pointer after pointers shrinking sizeof from 208 bytes to 200 bytes.
Space savings are considerable for such a trivial patch:

	$ ./scripts/bloat-o-meter ../vmlinux-000 ../obj/vmlinux
	add/remove: 0/0 grow/shrink: 1/11 up/down: 2/-65640 (-65638)
	Function                       old     new   delta
	check_irq_usage               2852    2854      +2
	reacquire_held_locks           486     484      -2
	lock_chain_get_class            41      39      -2
	l_start                         34      32      -2
	check_noncircular              276     274      -2
	print_usage_bug.part           688     683      -5
	print_circular_bug            1017    1011      -6
	hlock_conflict                 141     135      -6
	print_deadlock_bug             944     935      -9
	mark_lock                     3791    3769     -22
	__lock_acquire                9801    9753     -48
	lock_classes               1703936 1638400  -65536
	Total: Before=21163908, After=21098270, chg -0.31%

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 include/linux/lockdep_types.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/include/linux/lockdep_types.h
+++ b/include/linux/lockdep_types.h
@@ -127,12 +127,12 @@ struct lock_class {
 	unsigned long			usage_mask;
 	const struct lock_trace		*usage_traces[LOCK_TRACE_STATES];
 
+	const char			*name;
 	/*
 	 * Generation counter, when doing certain classes of graph walking,
 	 * to ensure that we check one node only once:
 	 */
 	int				name_version;
-	const char			*name;
 
 	u8				wait_type_inner;
 	u8				wait_type_outer;

             reply	other threads:[~2023-11-16 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 11:25 Alexey Dobriyan [this message]
2023-11-16 12:42 ` Waiman Long

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=e527403e-9be1-4aa2-98c0-a3ab1f02787f@p183 \
    --to=adobriyan@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@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

all inboxes | Powered by JetHome®