From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Daniel Bristot de Oliveira <bristot@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Ian Rogers <irogers@google.com>, Ingo Molnar <mingo@redhat.com>,
Jiri Olsa <jolsa@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Marco Elver <elver@google.com>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v4 3/6] perf: Shrink the size of the recursion counter.
Date: Mon, 1 Jul 2024 14:56:43 +0200 [thread overview]
Message-ID: <20240701125643.kqJWwrhW@linutronix.de> (raw)
In-Reply-To: <20240701123137.GF20127@noisy.programming.kicks-ass.net>
On 2024-07-01 14:31:37 [+0200], Peter Zijlstra wrote:
> On Mon, Jun 24, 2024 at 05:15:16PM +0200, Sebastian Andrzej Siewior wrote:
> > There are four recursion counter, one for each context. The type of the
> > counter is `int' but the counter is used as `bool' since it is only
> > incremented if zero.
> >
> > Reduce the type of the recursion counter to an unsigned char, keep the
> > increment/ decrement operation.
>
> Does this actually matter? Aren't u8 memops encoded by longer
> instructions etc..
The goal here isn't to reduce the opcodes but to add it to task_struct
without making it larger by filling a hole.
But since you made me look at assembly:
old:
316b: 65 48 8b 15 00 00 00 mov %gs:0x0(%rip),%rdx # 3173 <perf_swevent_get_recursion_context+0x33>
3173: 1c ff sbb $0xff,%al
3175: 48 0f be c8 movsbq %al,%rcx
3179: 48 8d 94 8a 00 00 00 lea 0x0(%rdx,%rcx,4),%rdx
3180: 00
317d: R_X86_64_32S .data..percpu+0x4c
3181: 8b 0a mov (%rdx),%ecx
3183: 85 c9 test %ecx,%ecx
3185: 75 0e jne 3195 <perf_swevent_get_recursion_context+0x55>
3187: c7 02 01 00 00 00 movl $0x1,(%rdx)
^^^
318d: 0f be c0 movsbl %al,%eax
new:
2ff8: 1c ff sbb $0xff,%al
2ffa: 81 e2 00 01 ff 00 and $0xff0100,%edx
3000: 83 fa 01 cmp $0x1,%edx
3003: 1c ff sbb $0xff,%al
3005: 48 0f be d0 movsbq %al,%rdx
3009: 48 8d 94 11 00 00 00 lea 0x0(%rcx,%rdx,1),%rdx
3010: 00
300d: R_X86_64_32S .data..percpu+0x4c
3011: 80 3a 00 cmpb $0x0,(%rdx)
3014: 75 0b jne 3021 <perf_swevent_get_recursion_context+0x51>
3016: c6 02 01 movb $0x1,(%rdx)
^^^
3019: 0f be c0 movsbl %al,%eax
301c: e9 00 00 00 00 jmp 3021 <perf_swevent_get_recursion_context+0x51>
So we do even save a few bytes. We could avoid the "movsbl" at 3019 by
making the return type `unsigned char' ;)
Sebastian
next prev parent reply other threads:[~2024-07-01 12:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 15:15 [PATCH v4 0/6] perf: Make SIGTRAP and __perf_pending_irq() work on RT Sebastian Andrzej Siewior
2024-06-24 15:15 ` [PATCH v4 1/6] perf: Move irq_work_queue() where the event is prepared Sebastian Andrzej Siewior
2024-06-24 15:15 ` [PATCH v4 2/6] perf: Enqueue SIGTRAP always via task_work Sebastian Andrzej Siewior
2024-07-01 12:28 ` Peter Zijlstra
2024-07-01 13:27 ` Sebastian Andrzej Siewior
2024-07-02 9:01 ` Peter Zijlstra
2024-10-28 8:30 ` Lai, Yi
2024-10-28 12:21 ` Frederic Weisbecker
2024-10-29 17:21 ` Sebastian Andrzej Siewior
2024-10-30 14:07 ` Sebastian Andrzej Siewior
2024-10-30 15:46 ` Frederic Weisbecker
2024-11-07 14:46 ` Sebastian Andrzej Siewior
2024-11-08 13:11 ` Frederic Weisbecker
2024-11-08 19:08 ` Oleg Nesterov
2024-11-08 22:26 ` Frederic Weisbecker
2024-11-11 12:08 ` Sebastian Andrzej Siewior
2024-12-04 3:02 ` Lai, Yi
2024-12-04 13:48 ` Oleg Nesterov
2024-12-05 0:19 ` Frederic Weisbecker
2024-12-05 9:20 ` Oleg Nesterov
2024-12-05 10:05 ` Frederic Weisbecker
2024-12-05 10:28 ` Oleg Nesterov
2024-12-13 22:52 ` Frederic Weisbecker
2024-12-16 19:19 ` Oleg Nesterov
2024-06-24 15:15 ` [PATCH v4 3/6] perf: Shrink the size of the recursion counter Sebastian Andrzej Siewior
2024-07-01 12:31 ` Peter Zijlstra
2024-07-01 12:56 ` Sebastian Andrzej Siewior [this message]
2024-07-01 13:10 ` Peter Zijlstra
2024-06-24 15:15 ` [PATCH v4 4/6] perf: Move swevent_htable::recursion into task_struct Sebastian Andrzej Siewior
2024-06-24 15:15 ` [PATCH v4 5/6] perf: Don't disable preemption in perf_pending_task() Sebastian Andrzej Siewior
2024-06-24 15:15 ` [PATCH v4 6/6] perf: Split __perf_pending_irq() out of perf_pending_irq() Sebastian Andrzej Siewior
2024-06-25 13:42 ` [PATCH v4 0/6] perf: Make SIGTRAP and __perf_pending_irq() work on RT Marco Elver
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=20240701125643.kqJWwrhW@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bristot@kernel.org \
--cc=elver@google.com \
--cc=frederic@kernel.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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®