mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Dave Airlie <airlied@gmail.com>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Sebastian Sewior <bigeasy@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Linux 6.15-rc3
Date: Wed, 23 Apr 2025 09:14:37 +0200	[thread overview]
Message-ID: <0981c1fe-05d2-4bab-a0a4-6dc5666d98d7@suse.cz> (raw)
In-Reply-To: <CAADnVQ+KnfDLd-=Mg1BDJxCf80K_=RN0dJy_yp681gf1dQMhtg@mail.gmail.com>

On 4/23/25 01:37, Alexei Starovoitov wrote:
> On Tue, Apr 22, 2025 at 4:01 PM Dave Airlie <airlied@gmail.com> wrote:
>>
>> > Alexei Starovoitov (2):
>> >       locking/local_lock, mm: replace localtry_ helpers with
>> > local_trylock_t type
>>
>> This seems to have upset some phoronix nginx workload
>> https://www.phoronix.com/review/linux-615-nginx-regression/2
> 
> 3x regression? wow.
> Thanks for heads up.
> I'm staring at the patch and don't see it.
> Adding more experts.

Incidentally my work on slab sheaves using local_trylock() got to a phase
yesterday when after rebasing on rc3 and some refactoring I was looking at
sheaf stats that showed the percpu sheaves were used exactly once per cpu,
and other attempts failed. Which would be explained by local_trylock()
failing. In the context of rc3 itself it would mean the memcg stocks aren't
used at all because they can't be try-locked. Which could make benchmarks
unhappy of course, although surprising that it would be that much.

What I suspect now is the _Generic() part doesn't work as expected. So consider:

local_trylock() (or _irqsave variant) has no _Generic() part, does the
"if (READ_ONCE(tl->acquired))" and "WRITE_ONCE(tl->acquired, 1)" directly,
succeeds the first attempt on each cpu where executed.

local_unlock() goes via __local_lock_release() and since the _Generic() part
there doesn't work, we don't do WRITE_ONCE(tl->acquired, 0); so it stays 1.

preempt or irq handling is fine so nothing like lockdep, preempt debugging,
watchdogs gets suspicious, just the cpu can never succeed local_trylock() again

local_lock(_irqsave()) uses __local_lock_acquire() which also has a
_Generic() part but since it doesn't work, the "lockdep_assert(tl->acquired
== 0);" there isn't triggered either

In fact I've put BUG() in the _Generic() sections of _acquire() and _release()
and it didn't trigger, which would prove the code isn't executed. But I don't
know why _Generic() doesn't recognize the correct type there.

--- a/include/linux/local_lock_internal.h
+++ b/include/linux/local_lock_internal.h
@@ -104,6 +104,7 @@ do {                                                                \
                _Generic((lock),                                        \
                        local_trylock_t *: ({                           \
                                lockdep_assert(tl->acquired == 0);      \
+                               BUG();                                  \
                                WRITE_ONCE(tl->acquired, 1);            \
                        }),                                             \
                        default:(void)0);                               \
@@ -173,6 +174,7 @@ do {                                                                \
                _Generic((lock),                                        \
                        local_trylock_t *: ({                           \
                                lockdep_assert(tl->acquired == 1);      \
+                               BUG();                                  \
                                WRITE_ONCE(tl->acquired, 0);            \
                        }),                                             \
                        default:(void)0);                               \




  parent reply	other threads:[~2025-04-23  7:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-20 21:01 Linus Torvalds
2025-04-20 23:03 ` Linus Torvalds
2025-04-21 13:20 ` Guenter Roeck
2025-04-22 23:01 ` Dave Airlie
2025-04-22 23:37   ` Alexei Starovoitov
2025-04-23  0:12     ` Shakeel Butt
2025-04-23  0:54       ` Michael Larabel
2025-04-23  8:42         ` Vlastimil Babka
2025-04-23 13:57           ` Michael Larabel
2025-04-23 15:41           ` Alexei Starovoitov
2025-04-23 16:05             ` Linus Torvalds
2025-04-23  7:14     ` Vlastimil Babka [this message]
2025-04-23  8:03       ` Vlastimil Babka
2025-04-23  8:08         ` Vlastimil Babka
2025-04-23 14:38           ` Michael Larabel
2025-04-23 15:06         ` Alexei Starovoitov

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=0981c1fe-05d2-4bab-a0a4-6dc5666d98d7@suse.cz \
    --to=vbabka@suse.cz \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=torvalds@linux-foundation.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®