lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201207093419.GH3040@hirez.programming.kicks-ass.net>
Date:   Mon, 7 Dec 2020 10:34:19 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Petr Mladek <pmladek@...e.com>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH next v2 2/3] printk: change @clear_seq to atomic64_t

On Sun, Dec 06, 2020 at 09:29:59PM +0106, John Ogness wrote:
> Yes, and it is read-only access. Perhaps atomic64_t is the wrong thing
> to use here. We could use a seqcount_latch and a shadow variable so that
> if a writer has been preempted, we can use the previous value. (Only
> kmsg_dump would need to use the lockless variant to read the value.)
> 
> void clear_seq_set(u64 val)
> {
>         spin_lock_irq(&clear_lock);
>         raw_write_seqcount_latch(&clear_latch);
>         clear_seq[0] = val;
>         raw_write_seqcount_latch(&clear_latch);
>         clear_seq[1] = val;
>         spin_unlock_irq(&clear_lock);
> }
> 
> u64 clear_seq_get_nolock(void)
> {
>         unsigned int seq, idx;
>         u64 val;
> 
>         do {
>                 seq = raw_read_seqcount_latch(&clear_latch);
>                 idx = seq & 0x1;
>                 val = clear_seq[idx];
>         } while (read_seqcount_latch_retry(&clear_latch, seq));
> 
>         return val;
> }

That's overly complicated.

If you're going to double the storage you can simply do:


	seq = val
	smp_wmb();
	seq_copy = val;

vs

	do {
		tmp = seq_copy;
		smp_rmb();
		val = seq;
	} while (val != tmp);


Also look for CONFIG_64_BIT in kernel/sched/fair.c.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ