From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932897AbdEVKVv (ORCPT ); Mon, 22 May 2017 06:21:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43468 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751138AbdEVKVq (ORCPT ); Mon, 22 May 2017 06:21:46 -0400 From: Ankit Kumar To: keescook@chromium.org, anton@enomsg.org, ccross@android.com, tony.luck@intel.com Cc: linux-kernel@vger.kernel.org, mahesh@linux.vnet.ibm.com, hbathini@linux.vnet.ibm.com, hegdevasant@linux.vnet.ibm.com, ankit@linux.vnet.ibm.com Subject: [PATCH 2/2] Save current timestamp part of dmesg while writing oops message to pstore Date: Mon, 22 May 2017 15:50:37 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495448437-15398-1-git-send-email-ankit@linux.vnet.ibm.com> References: <1495448437-15398-1-git-send-email-ankit@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17052210-0012-0000-0000-0000023661C0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052210-0013-0000-0000-0000074DC327 Message-Id: <1495448437-15398-2-git-send-email-ankit@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-22_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705220055 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently on panic or Oops, kernel saves the last few bytes from dmesg buffer to nvram. Usually kdump does capture kernel memory and provide dmesg logs as well. But in some cases where kdump fails to capture vmcore, the dmesg buffer stored in nvram/pstore turns out to be very helpful in analyzing root cause. Present code creates pstore dump file(/sys/fs/pstore/dmesg-***) based on timestamp(retrieved from header). Current pstore code creates dump file (/sys/fs/pstore/dmesg-***) with that timestamp. Dump file can be analyzed based on file creation time and we can make out whether dump file has latest data or not. But when we transfer pstore dump file(/sys/fs/pstore/dmesg-***) to other machine or collect file using some utilities(sosreport/supportconfig) then file timestamp gets changed and hence by looking at device file (dmesg-***) we won't be able to identify whether dump has latest data or not. Above issue can be fixed if we also have timestamp(dump creation time) as initial few bytes while capturing dmesg buffer to pstore dump file (/sys/fs/pstore/dmesg-***). This patch enhances pstore write code to also write timestamp as part of data. Here is sample log of dump file:(/sys/fs/pstore/dmesg-***) Oops#1 Part1 [timestamp:1494939359.590463] Above timestamp can be converted to current zone using date command. #date -d @1494939359.590463 # Tue May 16 18:25:59 IST 2017 Signed-off-by: Ankit Kumar --- fs/pstore/platform.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 4fedf83..f65000e 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -501,6 +501,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, unsigned long flags = 0; int is_locked; int ret; + struct timespec timestamp; why = get_reason_str(reason); @@ -540,9 +541,11 @@ static void pstore_dump(struct kmsg_dumper *dumper, dst_size = psinfo->bufsize; } + pstore_get_timestamp(×tamp); /* Write dump header. */ - header_size = snprintf(dst, dst_size, "%s#%d Part%u\n", why, - oopscount, part); + header_size = snprintf(dst, dst_size, "%s#%d Part%u [timestamp:%lu.%lu]\n", + why, oopscount, part, (long)timestamp.tv_sec, + (long)(timestamp.tv_nsec / 1000)); dst_size -= header_size; /* Write dump contents. */ -- 2.7.4