From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40522C43457 for ; Thu, 15 Oct 2020 08:03:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D941F2224D for ; Thu, 15 Oct 2020 08:03:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIbVuymX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387578AbgJOIDI (ORCPT ); Thu, 15 Oct 2020 04:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbgJOIDE (ORCPT ); Thu, 15 Oct 2020 04:03:04 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77914C061755 for ; Thu, 15 Oct 2020 01:03:04 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id e23so2150131wme.2 for ; Thu, 15 Oct 2020 01:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JeD/PZuPdhoZksxwF3qbmvZCPoyUNVOL4ytJnfR+4ro=; b=eIbVuymXgFgySc13nrj17X/fdRbvmyAr4Iz8LSq11GY8WciSPDqJe9t0H0BHtGcB0N jCMjloEA26av6VVHoB0/2rbb7H/hLjaaC1RKetux1x3N7WjJrcGVmIY4BtIB6BcxoD+n +PutmbSdslXDr/Z2QKbWa71X+KRxs5Zt/+uRbEVLeJEv3EsTYVuOBwLkEdVSbehpCngc K7SZPT8NvEsUntjAxjr6ifN/VEcEcnq9AF8ZXSwOTyiwJBqnrTr67zBVS/wCBJfFUPT3 N82N3aTXi6L/sDB4l0XMt3vju/+yxVNPQCbSX1QYnNketZaHkI6pa40V/P1VD2GAIivQ QErA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JeD/PZuPdhoZksxwF3qbmvZCPoyUNVOL4ytJnfR+4ro=; b=Gxq7qcPAcbGvNRjW+Lbp8ok604S/wnMQDirhGtlo4Y0+r2d3cXYPJqwHLjm4UGTBnv sipBRXSAHm/h57LL4feT6gBbB7cpHyedr7M/5v+kHiXaoFGeYvPXvVC1jxr57xLkbUts bfFMDC8xIrEbK24XlB30b/3XqMfsT9JYCyHEZ6G3Ewj4N587tkIj6ZpcOKEITNInt+fG BdtMKRB5JQrnHcKj3ZcpLjgQGzaoYzPUtn3YhkTN+7oQZ9WOcFilrLHVGdm9hKj9wi9V TNQ7ETwGUyWJmToNFYDLiud7VhsfrwmkqejjY2czbDWG+Og5e/68sAjNAaJeCsRIbQEO lYXg== X-Gm-Message-State: AOAM5322VMMjVUl607/hRQ6uNgjxDC5vT7sERrMBWadgbGUpF5Sl7xKW 6qGoBMmj/Iw6c3OzqYYq+6I= X-Google-Smtp-Source: ABdhPJwp4WCvWTTlehWKhL1Zd3WDtb+BWHK5gCqttJo/4+iNRsr527oj4dM4QNpO83e8Q0wzS7rduw== X-Received: by 2002:a1c:6488:: with SMTP id y130mr2611854wmb.94.1602748983223; Thu, 15 Oct 2020 01:03:03 -0700 (PDT) Received: from alley (176-114-240-43.rychlydrat.cz. [176.114.240.43]) by smtp.gmail.com with ESMTPSA id 67sm3232231wmb.31.2020.10.15.01.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 01:03:02 -0700 (PDT) From: Petr Mladek X-Google-Original-From: Petr Mladek Date: Thu, 15 Oct 2020 10:03:00 +0200 To: Rasmus Villemoes Cc: Geert Uytterhoeven , Linus Torvalds , Sergey Senozhatsky , Steven Rostedt , John Ogness , Andy Shevchenko , Peter Zijlstra , Linux Kernel Mailing List , Daniel Thompson Subject: Re: [GIT PULL] printk for 5.10 (includes lockless ringbuffer) Message-ID: <20201015080300.GE13775@alley> References: <20201012144916.GB10602@alley> <49292e1a-7e46-b078-d15d-fb2f406317db@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49292e1a-7e46-b078-d15d-fb2f406317db@rasmusvillemoes.dk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2020-10-14 16:58:27, Rasmus Villemoes wrote: > On 14/10/2020 16.16, Geert Uytterhoeven wrote: > > Hi Petr, > > > > On Mon, Oct 12, 2020 at 4:50 PM Petr Mladek wrote: > >> - Fully lockless ringbuffer implementation, including the support for > >> continuous lines. It will allow to store and read messages in any > >> situation wihtout the risk of deadlocks and without the need > >> of temporary per-CPU buffers. > > > > linux-m68k-atari_defconfig$ bloat-o-meter vmlinux.old > > vmlinux.lockless_ringbuffer > > add/remove: 39/16 grow/shrink: 9/15 up/down: 214075/-4362 (209713) > > Function old new delta > > _printk_rb_static_infos - 180224 +180224 > > _printk_rb_static_descs - 24576 +24576 > > [...] > > > > Seriously?!? Or am I being misled by the tools? > > > > linux-m68k-atari_defconfig$ size vmlinux.old vmlinux.lockless_ringbuffer > > text data bss dec hex filename > > 3559108 941716 177772 4678596 4763c4 vmlinux.old > > 3563922 1152496 175276 4891694 4aa42e vmlinux.lockless_ringbuffer > > > > Apparently not... > > Hm, that's quite a lot. And the only reason the buffers don't live > entirely in .bss is because a few of their entries have non-zero > initializers. > > Perhaps one could add a .init.text.initialize_static_data section of > function pointers, with the _DEFINE_PRINTKRB macro growing something like > > static void __init __initialize_printkrb_##name(void) { \ > _##name##_descs[_DESCS_COUNT(descbits) - 1] = ...; \ > _##name##_infos[0] = ...; \ > _##name##_infos[_DESCS_COUNT(descbits) - 1] = ...; \ > } \ > static_data_initializer(__initialize_printkrb_##name); > > with static_data_initalizer being the obvious yoga for putting a > function pointer in the .init.text.initialize_static_data section. Then > very early in start_kernel(), probably first thing, iterate that section > and call all the functions. But maybe that's not even early enough? A solution might be to initialize the buffer during the first printk() call. We could make sure that it is done in setup_log_buf() at latest. It is called when only one CPU is running so it should be safe. The only problem might be NMI. Best Regards, Petr