Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2490948ybd; Mon, 24 Jun 2019 07:20:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzg1hYnbeqFNhkrJtUntq7/BhTwz6uNzRHAJYvH8hxmLT07XvgaS6IIvKgYl2oFqB9mbU/5 X-Received: by 2002:a63:d70b:: with SMTP id d11mr33237125pgg.178.1561386034504; Mon, 24 Jun 2019 07:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386034; cv=none; d=google.com; s=arc-20160816; b=EzzkiP/p0nSS5t5vJ9fTh/VhcMrBTlsCzoO3yd+WRPTF5avdf5/VRNdH2utukPV+Tz e1PgJzVubUgQZ3aA2aJXZmzKDUdM2ztDgo0k5aDoTnQ/uFjmj9rANdaetkFECqo7wMD5 eqL+g8BEi1W8F0ZPj/SKOXqGd7LyQ51q4nRAeOl5Atw64OWIHe27eSs17/hUNCc88W00 xh8HMcEOsk7JbEd/+gXX7f03xcjd4cLjkW37bX++y2MmDi0iGRs6PFMPfFHyt1fGXWjk RJ/2/x+XLG+4Dt/RdUdhpx9c8UhM9kvvzuBhJ2bmxdttDy7dXZmvK04C0nYRLfgKNa6K f7XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=KQGjP1kqPZQ6kqhwLcUUB/XWZCHe4Fi9u0ycu0vfeV4=; b=kVvtMcXZCi7oIbCn6O3RyXB/tmBEB6IVnk0/q9stB8Ob7Hp1Y46KeynZjhVfRNwpCF VH/t5PdrS1WC65bncdoW/tCmQ5KGneT6iUB8L0qBVn8R3ljoX9BxBeqFbR3TheG2OKEV Shd517sEHoGGKJU2H8L5ZmNvxzUhR9GbZ532N3z4J1ZtuivnI43rf4wZ45YSITvgoMxF Q9gplVInfBT3tCOkbeY79BFVgOu3mq/efjxvbSZl5e87gxu3fhz6E5eJSkpF23lg86b+ y9xPvfxUQ33u7//P/Fhx6c3Bm0Py4mpuMRC5R5pmc17CimEKkD9qqLVB3ox4EVO2mF4p OtJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si9656830pgs.308.2019.06.24.07.20.18; Mon, 24 Jun 2019 07:20:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728986AbfFXNzm (ORCPT + 99 others); Mon, 24 Jun 2019 09:55:42 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:36978 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbfFXNzm (ORCPT ); Mon, 24 Jun 2019 09:55:42 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hfPRQ-0003fw-2b; Mon, 24 Jun 2019 15:55:28 +0200 From: John Ogness To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Sergey Senozhatsky Subject: Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation References: <20190607162349.18199-1-john.ogness@linutronix.de> <20190607162349.18199-2-john.ogness@linutronix.de> Date: Mon, 24 Jun 2019 15:55:26 +0200 In-Reply-To: <20190607162349.18199-2-john.ogness@linutronix.de> (John Ogness's message of "Fri, 7 Jun 2019 18:29:48 +0206") Message-ID: <877e9bxf3l.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I would like to point out an important typo related to memory barriers... On 2019-06-07, John Ogness wrote: > diff --git a/lib/printk_ringbuffer.c b/lib/printk_ringbuffer.c > new file mode 100644 > index 000000000000..d0b2b6a549b0 > --- /dev/null > +++ b/lib/printk_ringbuffer.c [...] > +static struct prb_descr *remove_oldest_descr(struct printk_ringbuffer *rb) > +{ > + struct prb_list *l = &rb->descr_list; > + unsigned long oldest_id; > + struct prb_descr *d; > + unsigned long next; > + > + for (;;) { > + oldest_id = READ_ONCE(l->oldest); > + > + /* list empty */ > + if (oldest_id == EOL) > + return NULL; > + > + d = TO_DESCR(rb, oldest_id); > + > + /* only descriptors with _invalid_ data can be removed */ > + if (data_valid(rb, READ_ONCE(rb->data_list.oldest), > + READ_ONCE(rb->data_list.newest), > + READ_ONCE(d->data), > + READ_ONCE(d->data_next))) { > + return NULL; > + } > + > + /* > + * MB6: synchronize link descr > + * > + * In particular: l->oldest is loaded as a data dependency so > + * d->next and the following l->oldest will load afterwards, > + * respectively. > + */ > + next = smp_load_acquire(&d->next); > + > + if (next == EOL && READ_ONCE(l->oldest) == oldest_id) { > + /* > + * The oldest has no next, so this is a list of one > + * descriptor. Lists must always have at least one > + * descriptor. > + */ > + return NULL; > + } > + > + if (cmpxchg(&l->oldest, oldest_id, next) == oldest_id) { > + /* removed successfully */ > + break; > + } This is supposed to be cmpxchg_relaxed(), not cmpxchg(). I did not intend to include the general mb() memory barriers around the RMW operation. (For some reason I thought _relaxed was the default.) Sorry. John Ogness