From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBE62C433DB for ; Thu, 14 Jan 2021 00:06:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 19A7822B2B for ; Thu, 14 Jan 2021 00:06:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19A7822B2B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2077A8D00A4; Wed, 13 Jan 2021 19:06:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B8858D008E; Wed, 13 Jan 2021 19:06:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 080038D00A4; Wed, 13 Jan 2021 19:06:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id E71968D008E for ; Wed, 13 Jan 2021 19:06:15 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B47F71EE6 for ; Thu, 14 Jan 2021 00:06:15 +0000 (UTC) X-FDA: 77702438310.17.cake61_6013be927522 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 94368180D0185 for ; Thu, 14 Jan 2021 00:06:15 +0000 (UTC) X-HE-Tag: cake61_6013be927522 X-Filterd-Recvd-Size: 4684 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 00:06:14 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 826A522A83; Thu, 14 Jan 2021 00:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1610582773; bh=Aiw3hocSNpc8d9OKmlwQqHpnJKjeH4oS+tO9UNk2TzU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EgnOpW22kfWBxWqD1DOqx1hCoc4GMerWJ5chcd4kxykizcxOJXYYII0BnKZyBiKWn 21cZnuCqb9QCDJ6rffWdwpnOcKLKmJYIvk8Z/KOtn4oIhuZFJcWT1cMsdgWhbYKHth tJtJyCKyIyURYJ3e1+uuoMJ/cMAiQnI4En2jLpic= Date: Wed, 13 Jan 2021 16:06:12 -0800 From: Andrew Morton To: Alexander Potapenko Cc: linux-kernel@vger.kernel.org, Marco Elver , Andrey Konovalov , Dmitry Vyukov , Ingo Molnar , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , linux-mm@kvack.org Subject: Re: [PATCH 2/4] lib: add error_report_notify to collect debugging tools' reports Message-Id: <20210113160612.32f8b67494521ce23cc9cba5@linux-foundation.org> In-Reply-To: <20210113091657.1456216-3-glider@google.com> References: <20210113091657.1456216-1-glider@google.com> <20210113091657.1456216-3-glider@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 13 Jan 2021 10:16:55 +0100 Alexander Potapenko wrote: > With the introduction of various production error-detection tools, such as > MTE-based KASAN and KFENCE, the need arises to efficiently notify the > userspace OS components about kernel errors. Currently, no facility exists > to notify userspace about a kernel error from such bug-detection tools. > The problem is obviously not restricted to the above bug detection tools, > and applies to any error reporting mechanism that does not panic the > kernel; this series, however, will only add support for KASAN and KFENCE > reporting. > > All such error reports appear in the kernel log. But, when such errors > occur, userspace would normally need to read the entire kernel log and > parse the relevant errors. This is error prone and inefficient, as > userspace needs to continuously monitor the kernel log for error messages. > On certain devices, this is unfortunately not acceptable. Therefore, we > need to revisit how reports are propagated to userspace. > > The library added, error_report_notify (CONFIG_ERROR_REPORT_NOTIFY), > solves the above by using the error_report_start/error_report_end tracing > events and exposing the last report and the total report count to the > userspace via /sys/kernel/error_report/last_report and > /sys/kernel/error_report/report_count. > > Userspace apps can call poll(POLLPRI) on those files to get notified about > the new reports without having to watch dmesg in a loop. It would be nice to see some user-facing documentation for this, under Documentation/. How to use it, what the shortcomings are, etc. For instance... what happens when userspace is slow reading /sys/kernel/error_report/last_report? Does that file buffer multiple reports? Does the previous one get overwritten? etc. Words on how this obvious issue is handled... > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -209,6 +209,20 @@ config DEBUG_BUGVERBOSE > of the BUG call as well as the EIP and oops trace. This aids > debugging but costs about 70-100K of memory. > > +config ERROR_REPORT_NOTIFY > + bool "Expose memory error reports to the userspace" There's really nothing "memory" specific about this? Any kernel subsystem could use it? > + depends on TRACING > + help > + When enabled, captures error reports from debugging tools (such as > + KFENCE or KASAN) using console tracing, and exposes reports in > + /sys/kernel/error_report/: the file last_report contains the last > + report (with maximum report length of PAGE_SIZE), and report_count, > + the total report count. > + > + Userspace programs can call poll(POLLPRI) on those files to get > + notified about the new reports without having to watch dmesg in a > + loop. So we have a whole new way of getting debug info out of the kernel. I fear this will become a monster. And anticipating that, we should make darn sure that the interface is right, and is extensible.