Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1454501pxb; Thu, 28 Jan 2021 17:48:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxow/1EJCDV2/CpxB437PdDSRsNLLxygl2UKCmDTQ/QheJKFv/QmLdGgIdQKmNxRhts/5UX X-Received: by 2002:a05:6402:13c8:: with SMTP id a8mr2632329edx.191.1611884927528; Thu, 28 Jan 2021 17:48:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611884927; cv=none; d=google.com; s=arc-20160816; b=ddiNiy30XdsUYqTuEtd6S/PY2xjAlYnjrLvvnqDa2OW6I5f/cOZec4JnDv3mOGPFrE YFn7wUurGOUn0Pidga+f49kT5iCAbKJl2Lz+e+7PjqNKFtYIaWyw2ZAALey1NyV2t1Cn 0H7OU0t8li9Q8RQ9nTBeocc2qWDJjgjteNP6C+uYQ4gLm2mDp9Kw8DrDsmvrnjxH84No wM2SFJ4AVl59BI1f10o6yK6grD/iYvfThaNr+IjfzvwgvvnvMzf5zj7PAnfz1f+177aQ TVeveBGj1EASTFsgkLvUeL/jCy1bbATr7Pzxwcz1Xp6hXlyjV5QMIoPp3yxw9SJTa+nS K1Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WJaQj8mG9CX4kUc/x7/N9X46utWcZpn5W7Qx0g4TWFc=; b=Y2DtCNDJQD1/FVX2Mn76HkyBC/BpGbqleMWRoeDxR88+K3IJUJ8qj/nc8Ei7NxYlYe sO142GZWlUInewgywtxodFIMqcuXsZ3R0mbehY20GgTip4O21nUCVxvhdHIJ+e9DVA39 eT7tclpUfBaSq55Ukh8Y90zFct8qoqMxrlFCcN2wQuee6GhGJseJD375ZC49RRdfinoG DwoZJXRtw1iffLbnXrbkKLFmpq9PQXdq2U4t1Qm+iv4nXzIlwsx2mVC1Z/bimJIUIj23 D9WstpqVOBqfveU3OPz+QXhknenkfqLNnBXESc6Tl/wEvoBw+g+pTorNJIdbsuKppV5p toqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PhBQ+5UQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n26si3656518ejh.363.2021.01.28.17.48.22; Thu, 28 Jan 2021 17:48:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PhBQ+5UQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229885AbhA2BrH (ORCPT + 99 others); Thu, 28 Jan 2021 20:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbhA2BrD (ORCPT ); Thu, 28 Jan 2021 20:47:03 -0500 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2810BC061574 for ; Thu, 28 Jan 2021 17:46:15 -0800 (PST) Received: by mail-qv1-xf30.google.com with SMTP id j4so3805788qvk.6 for ; Thu, 28 Jan 2021 17:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WJaQj8mG9CX4kUc/x7/N9X46utWcZpn5W7Qx0g4TWFc=; b=PhBQ+5UQxxq32pqppv8VUzq3XcZe498mjTGVbiiB/rf8ESF4evfDtyEnCNW/mntDbr f4pZI6/NE7xCFOJE1PWlR2c6mXlqdv66oOeeOav8m8tXiHqN3z9LCpynbTavP5D2EK9W J+CoSyqPIF+rec1D/nGQyyAxoLt7BHPYAmC6bKT/m6tiRX+BXgqKJ24DOXo6Vx6CbiO8 Da3gepe4+y2z6ffGV+XnAEPyVL7dAcm3ZGfnmYRvqDjXx/tZKDebakwV6HH9m/Ga2gdg agppg3qkgrtggz8k9JFS2GFb3hQaAyS2+NDDi7oCfrK07ISeQKSjAxpbwWDKpzmJ4UAV Moog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WJaQj8mG9CX4kUc/x7/N9X46utWcZpn5W7Qx0g4TWFc=; b=H9bmj3UN11n0c9oX3fCwpqY6/6ccNRjHwyq4qZu02ezP/9nGhMRKTHxyclSfLcRL3m Ljj76tJs+VqdGPu1v7pXsgG8W0TWktrW1OmSzxqn15ed6/pL5inG5QVs3+mgV5WN382n MIh2M7ZRM/5V5jrGH/5GjFUPUj79UuO6VdLyadrtq6rjqinvukrubP97LdZ6qhdKwOLm Septc83z07R0CtkcNka4tOvUuqOqcsTJes/GdisjETYu8H0+v3U6cM9lPjLg20DpSYE/ D5luILxR7oWoiEayuiuadmh5TaL9Wwh4uOeRK5msRYv9IXwelOG0JzKepVDMsUc7qvJ+ UlWA== X-Gm-Message-State: AOAM530iAphE8DuhAFnX7Lcwv9mctl4atyHzYaUsC/JIk8/068mn2M6v rJfPJ5Y0LSm81nixmDIvDwyzSx9eFRM5nqsNdk1DnA== X-Received: by 2002:a0c:f7d2:: with SMTP id f18mr2075531qvo.39.1611884774178; Thu, 28 Jan 2021 17:46:14 -0800 (PST) MIME-Version: 1.0 References: <20210122235238.655049-1-elavila@google.com> <87im7l2lcr.fsf@jogness.linutronix.de> In-Reply-To: From: "J. Avila" Date: Thu, 28 Jan 2021 17:46:03 -0800 Message-ID: Subject: Re: Issue in dmesg time with lockless ring buffer To: John Ogness Cc: Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Paul McKenney , Saravana Kannan , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello John, I=E2=80=99ve done some additional digging on my end. I tested using a 5.10.= 11 kernel and observed the following: 1) With the default of CONFIG_LOG_BUF_SHIFT=3D17, I was not able to reprodu= ce the issue. 2) With CONFIG_LOG_BUF_SHIFT=3D20, I was able to reproduce the behavior mentioned before. 3) With (2) + reverting up to and including 896fbe20b4e2 (printk: use the lockless ringbuffer), I saw short dmesg times again. It seems that this issue may only exist with a sufficiently big log buffer size. Despite 1MB being a relatively uncommon size for linux kernel log buffers, this still indicates a potential issue in the code; do you think it's worth investigation? Thanks, Avila On Mon, Jan 25, 2021 at 4:00 PM J. Avila wrote: > > Hello, > > This dmesg uses /dev/kmsg; we've verified that we don't see this long > dmesg time when reading from syslog (via dmesg -S). > > We've also tried testing this with logging daemons disabled as well as > within initrd - both result in similar behavior. > > If it's relevant, this was done on a toybox shell. > > Thanks, > > Avila > > On Mon, Jan 25, 2021 at 5:32 AM John Ogness w= rote: > > > > On 2021-01-22, "J. Avila" wrote: > > > When doing some internal testing on a 5.10.4 kernel, we found that th= e > > > time taken for dmesg seemed to increase from the order of millisecond= s > > > to the order of seconds when the dmesg size approached the ~1.2MB > > > limit. After doing some digging, we found that by reverting all of th= e > > > patches in printk/ up to and including > > > 896fbe20b4e2333fb55cc9b9b783ebcc49eee7c7 ("use the lockless > > > ringbuffer"), we were able to once more see normal dmesg times. > > > > > > This kernel had no meaningful diffs in the printk/ dir when compared > > > to Linus' tree. This behavior was consistently reproducible using the > > > following steps: > > > > > > 1) In one shell, run "time dmesg > /dev/null" > > > 2) In another, constantly write to /dev/kmsg > > > > > > Within ~5 minutes, we saw that dmesg times increased to 1 second, onl= y > > > increasing further from there. Is this a known issue? > > > > The last couple days I have tried to reproduce this issue with no > > success. > > > > Is your dmesg using /dev/kmsg or syslog() to read the buffer? > > > > Are there any syslog daemons or systemd running? Perhaps you can run > > your test within an initrd to see if this effect is still visible? > > > > John Ogness