All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org,
	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>, Theodore Ts'o <tytso@mit.edu>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] locking/lockdep: Use sched_clock() for random numbers.
Date: Tue, 17 May 2022 14:08:12 +0200	[thread overview]
Message-ID: <YoOQLJeQtpY9gHMm@linutronix.de> (raw)
In-Reply-To: <YoNx9w1QocBY/P0I@zx2c4.com>

On 2022-05-17 11:59:19 [+0200], Jason A. Donenfeld wrote:
> On Tue, May 17, 2022 at 11:53:43AM +0200, Jason A. Donenfeld wrote:
> > Hi Sebastian,

Hi Jason,

> > Interesting RT consideration. I hope there aren't too many of these
> > special cases that would necessitate a general mechanism. Fingers
> > crossed this is the only one.

lockdep is special here. Haven't seen other explosions so far ;)

> > On Tue, May 17, 2022 at 11:16:14AM +0200, Sebastian Andrzej Siewior wrote:
> > > -			cookie.val = 1 + (prandom_u32() >> 16);
> > > +			cookie.val = 1 + (sched_clock() & 0xffff);
> > >  			hlock->pin_count += cookie.val;
> >  
> > I have no idea what the requirements here are. What would happen if you
> > just did atomic_inc_return(&some_global) instead? That'd be faster
> > anyhow, and it's not like 16 bits gives you much variance anyway...

it might work I guess. PeterZ? Would this_cpu_inc_return() work?

> Also, what is that `1 +` doing there? If the intention is to make sure
> this is non-zero, you might want the mask to be 0xfffe? Or you're
> counting on the assigned type being a u32 so it all overflows into the
> next zone the way you want it? Kinda weird.

hmm. It used to be 1 before prandom_u32() was introduced and the point
is probably to have a cookie != 0. val and pin_count are both unsigned
int/ 32bit so that overflow doesn't matter.

> Jason

Sebastian

  reply	other threads:[~2022-05-17 12:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17  9:16 [PATCH] locking/lockdep: Use sched_clock() for random numbers Sebastian Andrzej Siewior
2022-05-17  9:53 ` Jason A. Donenfeld
2022-05-17  9:59   ` Jason A. Donenfeld
2022-05-17 12:08     ` Sebastian Andrzej Siewior [this message]
2022-06-13  8:11       ` Peter Zijlstra
2022-06-13  8:05   ` Peter Zijlstra
2022-06-13  8:16     ` Jason A. Donenfeld
2022-06-07 16:51 ` Sebastian Andrzej Siewior
2022-06-12 15:43 ` Sasha Levin
2022-06-13  8:36 ` [tip: locking/urgent] " tip-bot2 for Sebastian Andrzej Siewior

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=YoOQLJeQtpY9gHMm@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=Jason@zx2c4.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=tglx@linutronix.de \
    --cc=tytso@mit.edu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.