Received: by 10.213.65.68 with SMTP id h4csp317688imn; Fri, 16 Mar 2018 04:14:27 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKn3/72J7RBuppOcqRmRUkvnrszkfov3MC4eqLPSsCVifBIu0e+EDTxcbLn2c8Fmo85uLb X-Received: by 10.101.99.205 with SMTP id n13mr1163296pgv.345.1521198867636; Fri, 16 Mar 2018 04:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521198867; cv=none; d=google.com; s=arc-20160816; b=QFFO/V3/B/lUlms+/mDAQoEuJ6gN0qf9DQgX+8blSvrOh1nYHIW5ZKv5SS6vz6rh5y 7Vr/JEs5vo3qg5aHy8EW3gzc9ayNPdPuSZ2IqE5x6s5YUVcsQ6aUleSa/EuD8LsNxG9b ZlPYYCn8ei7weDoECClZV991DDQu3tDgaZ5KgguRcRwbN+PybA5HMN4JAugh2dDdzIjp rsRD3H3WkBXPSQV/5FDT3/7w5S2YECZVmVUMBvVPDcVkMvxouCfWXf1AIV/tgfOVtZ3Z +KKeavaQtcbOXXLUZIJCT9wyhQ2RCZAI6L5zjjQ0ad+fNCyeY9cE8jCpkdj7i5jrk2aq v1sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=JfCCwqgF0QmMEmysJSQc/NxfYZXGZlxjWXz82kgNkIE=; b=XR/2fjx2959rriynumLym/R5r/Z10iwG7Mc1XSVCWPpa3963El6weD99h6/tMV2HLu Xs4CpIi+M4+kOnMG7CKJdxPmNFIuWR9MNtiAuoPOt1DvaNX8GSZUY8E5yS/ccrzPxwXn OUUvi5+eqPDPZ86uQw7hmU81JvEhfsXUPJk+itXMSLpXX1y09Jabi7v5bH2Q1jRIMihK phSAEaGizTazN1ERWJRawMKsszj6C7DQLZ4R4sttyu8bk6nENUQWKkDBSae03nIUxVdd FDw+DysWzRag1cx/Yvs8tPRiGKiQu4OxqQj6MZqvjPHX4A9VRhdv22YDNBm40fHhwGK8 yCOA== 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 126si1880881pgd.375.2018.03.16.04.14.13; Fri, 16 Mar 2018 04:14:27 -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; 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 S1753845AbeCPLNU (ORCPT + 99 others); Fri, 16 Mar 2018 07:13:20 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:35194 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753609AbeCPLNQ (ORCPT ); Fri, 16 Mar 2018 07:13:16 -0400 Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id w2GBCrIR004189; Fri, 16 Mar 2018 04:12:54 -0700 From: Rahul Lakkireddy To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kexec@lists.infradead.org Cc: davem@davemloft.net, ebiederm@xmission.com, akpm@linux-foundation.org, torvalds@linux-foundation.org, ganeshgr@chelsio.com, nirranjan@chelsio.com, indranil@chelsio.com, Rahul Lakkireddy Subject: [RFC v2 0/2] kernel: add support to collect hardware logs in crash recovery kernel Date: Fri, 16 Mar 2018 16:42:03 +0530 Message-Id: <1521198725-13463-1-git-send-email-rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On production servers running variety of workloads over time, kernel panic can happen sporadically after days or even months. It is important to collect as much debug logs as possible to root cause and fix the problem, that may not be easy to reproduce. Snapshot of underlying hardware/firmware state (like register dump, firmware logs, adapter memory, etc.), at the time of kernel panic will be very helpful while debugging the culprit device driver. This series of patches add new generic framework that enable device drivers to collect device specific snapshot of the hardware/firmware state of the underlying device in the crash recovery kernel. In crash recovery kernel, the collected logs are exposed via /proc/crashdd/ directory, which is copied by user space scripts for post-analysis. A kernel module crashdd is newly added. In crash recovery kernel, crashdd exposes /proc/crashdd/ directory containing device specific hardware/firmware logs. The sequence of actions done by device drivers to append their device specific hardware/firmware logs to /proc/crashdd/ directory are as follows: 1. During probe (before hardware is initialized), device drivers register to the crashdd module (via crashdd_add_dump()), with callback function, along with buffer size and log name needed for firmware/hardware log collection. 2. Crashdd creates a driver's directory under /proc/crashdd/. Then, it allocates the buffer with requested size and invokes the device driver's registered callback function. 3. Device driver collects all hardware/firmware logs into the buffer and returns control back to crashdd. 4. Crashdd exposes the buffer as a file via /proc/crashdd//. 5. User space script (/usr/lib/kdump/kdump-lib-initramfs.sh) copies the entire /proc/crashdd/ directory to /var/crash/ directory. Patch 1 adds crashdd module to allow drivers to register callback to collect the device specific hardware/firmware logs. The module also exports /proc/crashdd/ directory containing the hardware/firmware logs. Patch 2 shows a cxgb4 driver example using the API to collect hardware/firmware logs in crash recovery kernel, before hardware is initialized. The logs for the devices are made available under /proc/crashdd/cxgb4/ directory. Suggestions and feedback will be much appreciated. Thanks, Rahul RFC v1: https://www.spinics.net/lists/netdev/msg486562.html --- v2: - Added new crashdd module that exports /proc/crashdd/ containing driver's registered hardware/firmware logs in patch 1. - Replaced the API to allow drivers to register their hardware/firmware log collect routine in crash recovery kernel in patch 1. - Updated patch 2 to use the new API in patch 1. Rahul Lakkireddy (2): proc/crashdd: add API to collect hardware dump in second kernel cxgb4: collect hardware dump in second kernel drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 4 + drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c | 25 +++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.h | 3 + drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 12 ++ fs/proc/Kconfig | 11 + fs/proc/Makefile | 1 + fs/proc/crashdd.c | 263 +++++++++++++++++++++++ include/linux/crashdd.h | 43 ++++ 8 files changed, 362 insertions(+) create mode 100644 fs/proc/crashdd.c create mode 100644 include/linux/crashdd.h -- 2.14.1