Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3918298imj; Tue, 12 Feb 2019 06:55:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ0XAix4C8MkJVGh/nzFFPmS96hud+j65WUuGzfgj1z65lfPLpijnherof+myehg3anDSB7 X-Received: by 2002:a63:3fc8:: with SMTP id m191mr4055881pga.240.1549983344657; Tue, 12 Feb 2019 06:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549983344; cv=none; d=google.com; s=arc-20160816; b=AlMAVJgubRGBAWIR6oTb4BVTRkZTpMPIw0y9reT0B/sMfVuddx/lPbg/9JHnCs0X5o ZWAZjmdY2KWnRIcwZU5tfb81Jk5GKijDOj4QOJT9aVtJ2yOdgeY8PDiXWQuLiOMIZYZR 1bRdnUT7B6skfEYI4/GKRpb5DDbrL8+Im4KsyxdF3XSsyfSrT/sUTk4rdflPLbFSJj35 j2JLyM5imC3/vgS9LvKcXvzktyknnYxc/nEb1Ay1tErAA231RauaHHW7aF3rX3EaWnX6 OeKcmPhvZ6E3eQ2MeKNtK+QKVEJmNQTPU1tsj1sf0RjuT1j8OWJqrSV3Vlf05cfnmX5z 3g9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=WG+soCPXu9K+iDBgJX3SAI1J/I77IuQmnO8lQKCpp+o=; b=eKQShoRgH+TO0P5OzsdbZQmtiMFPGOdUIMH/gkCZwmuitqvsWw/4jQapFmOfq2gN4s Qm3Mchgyl0OpVRw29VZR14EQZsm21eCdrJjkj7XW6+hhv2TdVabPWAbRC5r3BbsJLuu5 dBuVj9FF9fphWnX4IRUIn8KFanBf8/scuMo9JAmZqIY3wvcX9T+jQuNBa2y9Rt9XMCcX eqFL7YZz4ciUZDl2X6uWfhzlNBfNtWxPiYlanUbYZmkhAZttuohZPfxQzqtVXL+4X3fx JP+79iI8UIR/1WNIOkBEEPzpCaNr0LLYMkqwn3gQDx13q4I6vXfouhvFTI3zD2Z83PW+ 3ulA== 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 b7si7169361plx.331.2019.02.12.06.55.25; Tue, 12 Feb 2019 06:55:44 -0800 (PST) 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 S1728605AbfBLOa1 (ORCPT + 99 others); Tue, 12 Feb 2019 09:30:27 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:43681 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbfBLOa1 (ORCPT ); Tue, 12 Feb 2019 09:30:27 -0500 Received: from [5.158.153.53] (helo=linux.lab.linutronix.de.) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1gtZ4e-0005Af-6B; Tue, 12 Feb 2019 15:30:12 +0100 From: John Ogness To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: [RFC PATCH v1 03/25] printk-rb: define ring buffer struct and initializer Date: Tue, 12 Feb 2019 15:29:41 +0100 Message-Id: <20190212143003.48446-4-john.ogness@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190212143003.48446-1-john.ogness@linutronix.de> References: <20190212143003.48446-1-john.ogness@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org See Documentation/printk-ringbuffer.txt for details about the initializer arguments. Signed-off-by: John Ogness --- include/linux/printk_ringbuffer.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/linux/printk_ringbuffer.h b/include/linux/printk_ringbuffer.h index 75f5708ea902..0e6e8dd0d01e 100644 --- a/include/linux/printk_ringbuffer.h +++ b/include/linux/printk_ringbuffer.h @@ -10,6 +10,20 @@ struct prb_cpulock { unsigned long __percpu *irqflags; }; +struct printk_ringbuffer { + void *buffer; + unsigned int size_bits; + + u64 seq; + + atomic_long_t tail; + atomic_long_t head; + atomic_long_t reserve; + + struct prb_cpulock *cpulock; + atomic_t ctx; +}; + #define DECLARE_STATIC_PRINTKRB_CPULOCK(name) \ static DEFINE_PER_CPU(unsigned long, _##name##_percpu_irqflags); \ static struct prb_cpulock name = { \ @@ -17,6 +31,20 @@ static struct prb_cpulock name = { \ .irqflags = &_##name##_percpu_irqflags, \ } +#define DECLARE_STATIC_PRINTKRB(name, szbits, cpulockptr) \ +static char _##name##_buffer[1 << (szbits)] \ + __aligned(__alignof__(long)); \ +static struct printk_ringbuffer name = { \ + .buffer = &_##name##_buffer[0], \ + .size_bits = szbits, \ + .seq = 0, \ + .tail = ATOMIC_LONG_INIT(-111 * sizeof(long)), \ + .head = ATOMIC_LONG_INIT(-111 * sizeof(long)), \ + .reserve = ATOMIC_LONG_INIT(-111 * sizeof(long)), \ + .cpulock = cpulockptr, \ + .ctx = ATOMIC_INIT(0), \ +} + /* utility functions */ void prb_lock(struct prb_cpulock *cpu_lock, unsigned int *cpu_store); void prb_unlock(struct prb_cpulock *cpu_lock, unsigned int cpu_store); -- 2.11.0