Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp16694pxk; Wed, 2 Sep 2020 13:04:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXQfEHD5MWR+K2ZHQUA4fLhmpDvgl9HNdW5LTGMz937kB0iZCvMivN+ckJ1+rWITt/HIGg X-Received: by 2002:aa7:cfc7:: with SMTP id r7mr1878476edy.24.1599077087478; Wed, 02 Sep 2020 13:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599077087; cv=none; d=google.com; s=arc-20160816; b=uqShkeKhTt9awtqwWHRGbohn2zcg8xmxZjMuDsPv++PJRaDeXX720aO7WnnjADk1BK O1JflSPdgWIBIWpoEVHkiqSzdO2fBkJtzIRpaWzxQqnt2nXSwr4Sv/wzb3VQk8olHo+y cuWJXOvq+Ha6/2oKaI27f3Zu5Dq5pVLOQhOItsUKOUPf1LJo4a7tpNT7N6e1rjK35A13 zfRIRBp3g6oDwuaO3xkIBtNbN8e2EdgOfWfylMd99Vu14lDuqWszcTT7zgdGCVq30sYt 4BZvx+H5FjprCv3Oi3CirYLAa1z7zxCQsfPjNAUtwni00V5/eYMWH7DkYF0moRuLvgeb knkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9JdQwkuLYEyAFaAMN7JnHeEmf9KqMuiS3LAxUb4gzvY=; b=fcz1elHK7bT7Iu0VDXrd9FM1S/OhJiyx2lQCKRqYRhr85l90/c6sa6wASzWOm7d9Ax MmegX25QbRbzP51RKVW8mDdCPi5rWohLyqjHyY4+RebIQ0o6Y6syGzYgqjdodw/3bZTJ NjX2chA36iIBtI3byAkQKXYd77IDB+puqLv9hNAlnosHC93np77VyVYHL2LrR1B8GWml XjC9HHz/keJDMNvGQlhcg9rhg54eMmj4pTwmhnDdH6+fE+u86YLeTPPk3X45CWzBzy9j d1cRQj3HymnOmP4lLaD3DRvbZzGlqz+Ujn0QgmSJCRvxuJYOCffPBAPUVpCLlJXCtlDn ziTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZSoTHvoq; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e15si394294ejz.137.2020.09.02.13.04.24; Wed, 02 Sep 2020 13:04:47 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=ZSoTHvoq; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726323AbgIBUBX (ORCPT + 99 others); Wed, 2 Sep 2020 16:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgIBUBU (ORCPT ); Wed, 2 Sep 2020 16:01:20 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8AAFC061244 for ; Wed, 2 Sep 2020 13:01:19 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id o5so883955qke.12 for ; Wed, 02 Sep 2020 13:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9JdQwkuLYEyAFaAMN7JnHeEmf9KqMuiS3LAxUb4gzvY=; b=ZSoTHvoqM3YQj7xkHNSUHZeV/ZS5A7V2pD16ARz2BXKyep1ueJXJ7bosq7XSbS0H03 8XU302L6I5ojWh9L9fE4QZbESVY4pkA7SFMIp7FnD3xaPvMJcvvT+L2nwRtzG54yvgfI bVwa1xP65NA1oY7cfRigZnchJfOXPinaNniCCoXfILVIWezMpWzd9iqO3pFgv1dPgHjP 4yL6GcYIOIXPDDXiWoIF+qRpMczg22kY+sgaIvfCYay1Y757pueoD5HcOHYbMMGjVFU4 kvnhUZ03sXhqL0jPY87zwtmsF7+OJz6mEo2RFQchBPc43XFJx/L8Xi3lRAXlStAYsqUr lhbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9JdQwkuLYEyAFaAMN7JnHeEmf9KqMuiS3LAxUb4gzvY=; b=BfL59D7uWcPQo9RU/a8Wnzxt8Jb/J+1j31pGqYII2zHUMU8cWkIZ3d/unqegqZIgep wXSp7e3tgUMHvel2WoEIxmNuBQKqBpbU249JIWBHVH65eCvn3tvxiK85wF9TDbLNH1ot ehQBeFQUmBXmVR4x6oEn7gliGj+lPW7L1WBldBaA7lZ1m9XIp+OMw47Qv885Y/Aj9C4S EvMJC6XCKKsbroyrod/Xct1DEBKgxBIwVKoDFUa7c9W5hvn7YEByOdjlS1GzrOsriN5H IlHFACLlnUEwZo0aCxY8dc0pn99/pSgSyNNRaHCSTYGQ38iJ47CHB5gizDCWjbpcU2CC ssMg== X-Gm-Message-State: AOAM531NuwQmZum4G2E6ThUoHQHubamaHt70Sws302Qp5XT3c/scUcPm V03nP/RCTU8CBv/25R8uOqo= X-Received: by 2002:a05:620a:a52:: with SMTP id j18mr8060706qka.445.1599076878970; Wed, 02 Sep 2020 13:01:18 -0700 (PDT) Received: from ubuntu (69-220-158-6.lightspeed.rlghnc.sbcglobal.net. [69.220.158.6]) by smtp.gmail.com with ESMTPSA id d12sm472481qka.34.2020.09.02.13.01.18 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 02 Sep 2020 13:01:18 -0700 (PDT) From: Nachammai Karuppiah To: Steven Rostedt , Ingo Molnar , Rob Herring , Frank Rowand , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck Cc: joel@joelfernandes.org, linux-kernel@vger.kernel.org, Nachammai Karuppiah Subject: [RFC PATCH 0/7] Trace events to pstore Date: Wed, 2 Sep 2020 13:00:15 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch series adds support to store trace events in pstore. Storing trace entries in persistent RAM would help in understanding what happened just before the system went down. The trace events that led to the crash can be retrieved from the pstore after a warm reboot. This will help debug what happened before machine’s last breath. This has to be done in a scalable way so that tracing a live system does not impact the performance of the system. This requires a new backend - ramtrace that allocates pages from persistent storage for the tracing utility. This feature can be enabled using TRACE_EVENTS_TO_PSTORE. In this feature, the new backend is used only as a page allocator and once the users chooses to use pstore to record trace entries, the ring buffer pages are freed and allocated in pstore. Once this switch is done, ring_buffer continues to operate just as before without much overhead. Since the ring buffer uses the persistent RAM buffer directly to record trace entries, all tracers would also persist across reboot. To test this feature, I used a simple module that would call panic during a write operation to file in tracefs directory. Before writing to the file, the ring buffer is moved to persistent RAM buffer through command line as shown below, $echo 1 > /sys/kernel/tracing/options/persist Writing to the file, $echo 1 > /sys/kernel/tracing/crash/panic_on_write The above write operation results in system crash. After reboot, once the pstore is mounted, the trace entries from previous boot are available in file, /sys/fs/pstore/trace-ramtrace-0 Looking through this file, gives us the stack trace that led to the crash. <...>-1 [001] .... 49.083909: __vfs_write <-vfs_write <...>-1 [001] .... 49.083933: panic <-panic_on_write <...>-1 [001] d... 49.084195: printk <-panic <...>-1 [001] d... 49.084201: vprintk_func <-printk <...>-1 [001] d... 49.084207: vprintk_default <-printk <...>-1 [001] d... 49.084211: vprintk_emit <-printk <...>-1 [001] d... 49.084216: __printk_safe_enter <-vprintk_emit <...>-1 [001] d... 49.084219: _raw_spin_lock <-vprintk_emit <...>-1 [001] d... 49.084223: vprintk_store <-vprintk_emit Patchwise oneline description is given below: Patch 1 adds support to allocate ring buffer pages from persistent RAM buffer. Patch 2 introduces a new backend, ramtrace. Patch 3 adds methods to read previous boot pages from pstore. Patch 4 adds the functionality to allocate page-sized memory from pstore. Patch 5 adds the seq_operation methods to iterate through trace entries. Patch 6 modifies ring_buffer to allocate from ramtrace when pstore is used. Patch 7 adds ramtrace DT node as child-node of /reserved-memory. Nachammai Karuppiah (7): tracing: Add support to allocate pages from persistent memory pstore: Support a new backend, ramtrace pstore: Read and iterate through trace entries in PSTORE pstore: Allocate and free page-sized memory in persistent RAM buffer tracing: Add support to iterate through pages retrieved from pstore tracing: Use ramtrace alloc and free methods while using persistent RAM dt-bindings: ramtrace: Add ramtrace DT node .../bindings/reserved-memory/ramtrace.txt | 13 + drivers/of/platform.c | 1 + fs/pstore/Makefile | 2 + fs/pstore/inode.c | 46 +- fs/pstore/platform.c | 1 + fs/pstore/ramtrace.c | 821 +++++++++++++++++++++ include/linux/pstore.h | 3 + include/linux/ramtrace.h | 28 + include/linux/ring_buffer.h | 19 + include/linux/trace.h | 13 + kernel/trace/Kconfig | 10 + kernel/trace/ring_buffer.c | 663 ++++++++++++++++- kernel/trace/trace.c | 312 +++++++- kernel/trace/trace.h | 5 +- 14 files changed, 1924 insertions(+), 13 deletions(-) create mode 100644 Documentation/devicetree/bindings/reserved-memory/ramtrace.txt create mode 100644 fs/pstore/ramtrace.c create mode 100644 include/linux/ramtrace.h -- 2.7.4