Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7236048ybh; Thu, 8 Aug 2019 12:16:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8AA2k2Ps/dzHtilFdBhhksca/yftre2HeZlPqYJQ6hMPrK20+0ffDh28swdxJOY7QD0IF X-Received: by 2002:a63:4846:: with SMTP id x6mr14306586pgk.332.1565291783129; Thu, 08 Aug 2019 12:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291783; cv=none; d=google.com; s=arc-20160816; b=cTivJ1IYegrYll2zjYuHkn3NAE69zRdvCixr7n6dSECQ3/I/uGdo37DupEosMlIxUB 6ZMFjhZiIJnRg2HwwSyHAP1LMyf7I472Rc0+jpkEhkTogaTDG4M2noKruR+vMwpwOrtZ rq99/2A1eiJA8hfPQJzt925fw4YGVGMOLLCdk8ZIbWZnSzYQ9/tiF3rWmUDJ51Up3VTI f01i/sOJXHc4lrmOuGI+dACvH2RzoCbeZQFKEh5weDsGp+FDccWEITHzow6/rqp1VqhI RxVgAYDhEiJrLrkBMcMoK+UmB9vc30HN+HP088SHuzqpaCgaIal2d0+vzeYyqS2eSR0T jreA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=CRHlDhtUbcgIRAJD8WQ0b9Jyc4BU2Ni837QHoXwlDfw=; b=dehK29bLNaiYK9cvQ/iqFIcUkObprKNmHIjJsC7XYcm75YYK97b+z9VCjjhbvn3J9n f79kOHz0lo2HxjXrbxMZIf9/E37Y4N5Dlvqx41uRTyNdNKzuQ+IdJ+m7fJSq4AEoNl1M rXMYbMIpzrNQC9zJSfSMTBEEv0SmxqeF1Bodr+cn/ntV8G7d8ypCvxY6rjWHXaqAvI/H 1HVHKptQHpWG2PQegO8F39sCbW4rSv5sFCTOXAPbJUSr6HdGRzOPPSG6Rfs6kX3Ag+K6 UGLpuZ933L6quQreSIqpLO8rcFA5urnNwifqjrwMYVtPxBaXRVXaLQr0dzDDeJ4UOhwV Xvgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BW1E7M2b; 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 y63si51368132pgd.403.2019.08.08.12.16.07; Thu, 08 Aug 2019 12:16:23 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BW1E7M2b; 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 S2404759AbfHHTOv (ORCPT + 99 others); Thu, 8 Aug 2019 15:14:51 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33762 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404734AbfHHTHu (ORCPT ); Thu, 8 Aug 2019 15:07:50 -0400 Received: by mail-lj1-f195.google.com with SMTP id z17so1457839ljz.0 for ; Thu, 08 Aug 2019 12:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CRHlDhtUbcgIRAJD8WQ0b9Jyc4BU2Ni837QHoXwlDfw=; b=BW1E7M2bFIR9mDv7LibCNf8xRcZluqgnyTqZ1eQ909N/rvNlTBz0CNVmfPumcS3pf6 /tOFOill8a6yLerkedIcLjF5QL1wuLVqqScJivAhgNwMnRVnZjP07CD6VxUJ8POx97WT +1wn+v9x8izH26Bme0qSoBpoQCrmEG0haMrN4= 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; bh=CRHlDhtUbcgIRAJD8WQ0b9Jyc4BU2Ni837QHoXwlDfw=; b=XgK1n5+IMlxtcoRBqVMKyrLVWnSSAz9Bt2m7+LZFEclbhc9QlDIdB/DDyMDjsA996o wbzHKQMvtL8uS0zwjnpW88saqf++GCXhrllQoAqU6a6IXtDAipo7lB8Ha1zJWGMnrMMI PEudCVqr39QxWPWMJtSjclKD7zMuB4enNnm2VrsE+If2uAkGwwE+9hs8DGYU40hw6Dbr 6J2eYgi9wkPH4QlLGDhlxKRazcpAzbvLLJA/UPJU7xnmGkOWjqEHmidWqPKe6zfMm7p4 aT57FR3VG5Tp5DmDx+99ILyaBO/6EXPaMLl7m+D5H9dmYOG0TJseiMRhFdyZ3h6CCP69 6rJw== X-Gm-Message-State: APjAAAXQka2yz4ohoHH9SRFj0Kg7FrA5TScLjo9aWlH9AcwaCQJkj+Mz /aLVjsinqdLaOwnUKcOu6JhCqeTas14= X-Received: by 2002:a2e:9dca:: with SMTP id x10mr8956501ljj.17.1565291266597; Thu, 08 Aug 2019 12:07:46 -0700 (PDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id t25sm17057918lfg.7.2019.08.08.12.07.45 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 12:07:45 -0700 (PDT) Received: by mail-lj1-f180.google.com with SMTP id i21so10650666ljj.3 for ; Thu, 08 Aug 2019 12:07:45 -0700 (PDT) X-Received: by 2002:a2e:9a58:: with SMTP id k24mr9261055ljj.165.1565291264803; Thu, 08 Aug 2019 12:07:44 -0700 (PDT) MIME-Version: 1.0 References: <20190807222634.1723-1-john.ogness@linutronix.de> <20190807222634.1723-10-john.ogness@linutronix.de> In-Reply-To: <20190807222634.1723-10-john.ogness@linutronix.de> From: Linus Torvalds Date: Thu, 8 Aug 2019 12:07:28 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v4 9/9] printk: use a new ringbuffer implementation To: John Ogness Cc: Linux List Kernel Mailing , Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Sergey Senozhatsky , Brendan Higgins Content-Type: multipart/mixed; boundary="000000000000cf4977058f9fc5cf" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000cf4977058f9fc5cf Content-Type: text/plain; charset="UTF-8" On Wed, Aug 7, 2019 at 3:27 PM John Ogness wrote: > > 2. For the CONFIG_PPC_POWERNV powerpc platform, kernel log buffer > registration is no longer available because there is no longer > a single contigous block of memory to represent all of the > ringbuffer. So this is tangential, but I've actually been wishing for a special "raw dump" format that has absolutely *no* structure to it at all, and is as a result not necessarily strictly reliable, but is a lot more robust. The background for that is that we have a class of bugs that are really hard to debug "in the wild", because people don't have access to serial consoles or any kind of special hardware at all (ie forget things like nvram etc), and when the machine locks up you're happy to just have a reset button (but more likely you have to turn power off and on). End result: a DRAM buffer can work, but is not "reliable". Particularly if you turn power on and off, data retention of DRAM is iffy. But it's possible, at least in theory. So I have a patch that implements a "stupid ring buffer" for thisa case, with absolutely zero data structures (because in the presense of DRAM corruption, all you can get is "hopefully only slightly garbled ASCII". It actually does work. It's a complete hack, but I have used this on real hardware to see dumps that happened after the machine could no longer send them to any device. I actually suspect that this kind of "stupid non-structured secondary log" can often be much more useful than the existing nvram special cases - yes the output can be garbled for multi-cpu cases because it not only is lockless, it's lockess without even any data structures - but it also works somewhat reliably when the machine is _really_ borked. Which is exactly when you want a log that isn't just the normal "working machine syslog". NOTE! This is *not* a replacement for a lockless printk. This is very much an _additional_ "low overhead buffer in RAM" for post-mortem analysis when anything fancier doesn't work. So I'm throwing this patch out there in case people have interest in looking at that very special case. Also note how right now the example code just steals a random physical memory area at roughly physical location 12GB - this is a hack and would need to be configurable obviously in real life, but it worked for the machines I tested (which both happened to have 16GB of RAM). Those parts are marked with "// HACK HACK HACK" and just a hardcoded physical address (0x320000000). Linus --000000000000cf4977058f9fc5cf Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Trial-power-off-buffer-for-printk-data-retention.patch" Content-Disposition: attachment; filename="0001-Trial-power-off-buffer-for-printk-data-retention.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jz31zr4j0 RnJvbSAwNzRlYTY3YWZjYWJhMzc5OTZhNjE1YzQxNjg1Y2Q3MmIwODhmNTgzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IFRodSwgMzAgTWF5IDIwMTkgMTk6NTY6MTMgLTA3MDAKU3ViamVjdDog W1BBVENIXSBUcmlhbCAicG93ZXIgb2ZmIGJ1ZmZlciIgZm9yIHByaW50ayBkYXRhIHJldGVudGlv bgoKVGhpcyBjaXJjdW12ZW50cyBBQ1BJIGFuZCBqdXN0IGZvcmNlcyBhIHJhbmRvbSBwaHlzaWNh bCBhZGRyZXNzICh3aGljaApoYXBwZW5zIHRvIGJlIGF0IDB4MzIwMDAwMDAwKSB0byBjb250YWlu IGEgNjRrQiBidWZmZXIgdGhhdCB3ZSB0YWtlCm92ZXIuCgpOb3QteWV0LXNpZ25lZC1vZmYtYnk6 IExpbnVzIFRvcnZhbGRzIDx0b3J2YWxkc0BsaW51eC1mb3VuZGF0aW9uLm9yZz4KLS0tCiBhcmNo L3g4Ni9rZXJuZWwvc2V0dXAuYyAgICAgICAgIHwgICA3ICsrCiBpbmNsdWRlL2xpbnV4L3ByaW50 ay5oICAgICAgICAgIHwg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W5kIHRoZQorCS8vIG1lbWNweSByYWNlcy4KKwlwb3MgKz0gbGVuOwor CXNldF9lbmRfbWFya2VyKGJhc2UsIHBvcyk7CisJV1JJVEVfT05DRShidWZmZXIucG9zLCBwb3Mp OworfQorCisjZGVmaW5lIE1BWERNUExJTkUgODAKKy8vIER1bXAgdGhlIHBvc3NpYmx5IGNvcnJ1 cHRlZCB0ZXh0IGluIHRoZSBhcmVhLgorc3RhdGljIHZvaWQgZHVtcF9hcmVhKHVuc2lnbmVkIGNo YXIgKnAsIHNpemVfdCBzaXplKQoreworCXVuc2lnbmVkIGNoYXIgbGluZVtNQVhETVBMSU5FKzFd OworCWludCBsZW4gPSAwLCBpOworCisJZm9yIChpID0gMDsgaSA8IHNpemU7IGkrKykgeworCQkv LyBJZ25vcmUgaGlnaCBiaXQKKwkJdW5zaWduZWQgY2hhciBjID0gcFtpXSAmIDB4N2Y7CisJCS8v IElnbm9yZSBOVUwgb3IgYWxsIGJpdHMgc2V0IGJ5dGVzCisJCWlmICghYyB8fCBjID09IDB4N2Yp CisJCQljb250aW51ZTsKKwkJLy8gT3RoZXJ3aXNlIHRyeSB0byB0dXJuIGl0IHByaW50YWJsZQor CQlpZiAoYyA8IDMyKSB7CisJCQlpZiAoYyA9PSAnXG4nKSB7CisJCQkJaWYgKCFsZW4pCisJCQkJ CWNvbnRpbnVlOworCQkJCXByaW50aygiQkRNUDogJXNcbiIsIGxpbmUpOworCQkJCWxlbiA9IDA7 CisJCQkJY29udGludWU7CisJCQl9CisJCQlpZiAoYyAhPSAnXHQnKQorCQkJCWNvbnRpbnVlOwor CQl9CisJCWxpbmVbbGVuKytdID0gYzsKKwkJbGluZVtsZW5dID0gMDsKKwkJaWYgKGxlbiA8IE1B WERNUExJTkUpCisJCQljb250aW51ZTsKKwkJcHJpbnRrKCJCRE1QOiAlcytcbiIsIGxpbmUpOwor CQlsZW4gPSAwOworCX0KKwlpZiAobGVuKQorCQlwcmludGsoIkJETVA6ICVzXG4iLCBsaW5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