Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1080640pxb; Fri, 27 Aug 2021 00:18:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyB2N9bq/2d/KtrAcRiiMWDNoZfiFMAiM3DRakalq2boAJQzlyFX4v0QUntaFBWyz+1tsD/ X-Received: by 2002:a17:906:76c1:: with SMTP id q1mr8607962ejn.156.1630048701010; Fri, 27 Aug 2021 00:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630048701; cv=none; d=google.com; s=arc-20160816; b=mhpUze73xe2o7xu4Z9ib/uL+9XR+89fUJQVBPeWI0Q1GVsJKnaKeBGAqSh2G/Z3O5w 5a3TmfmFOSl0h3ie8FencKXIyjn2g2uYG+MhYgTMFkbfcTNOLa0k8/BfVjAxwWDwPkRW A68dSvZ+hqt4CtuqkwhJwBrdO6WUueKE7Ymol9gHL34ARWnin7WvTxuk1l8F4ap8Gxy5 H/wPT+vVmru4xpGs9asKy5CuHp6hsM70k5l0BOpR3XcEgXhWQdDdqlUIimt+v/eVtzic 9C5DxoXNypj+ofUi3UHnOHsiM485Uw1/d/XfJg042iXV0pcFUiniSKGeXQ/HzWAa9O3E 2oYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2zKeivqky9oZqlPq2CIdiGy48kqzuuJCdg6I4pzh1P0=; b=HhSGqj+nLoihEP88Jq7GnmbFh7Urrv6KJ7UtwplRzsnCnviUS/Yby8ISw9ODYTkjGT 8rZPyKvm+Yv2mKnzi335JxfkOC0iW4o+FVE6Oko3BP+Nn6QrvNW+QdvaQOapzHr+dOsO MCxmtAP77mgfBMkvQQ628bzMakAkKygcNlQ7Ap/o8iKHbk4TEbbP4P1r6YX+R+4FsmdQ o2gfuCb6ba+6Fgaz3MruyIw+QCHW0mS+J8BEdUopI3rtMjb0wCueR89On4fBwK/9gs1/ RzIeva7c9UUFMVMror8PKhgV40Kih76h2onYRGiXG2jaXuLBvVoxl1m2tnANd3Xz87LK 0yKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pAY7vaQO; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si5787139edd.393.2021.08.27.00.17.57; Fri, 27 Aug 2021 00:18:20 -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=@linuxfoundation.org header.s=korg header.b=pAY7vaQO; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244313AbhH0HPG (ORCPT + 99 others); Fri, 27 Aug 2021 03:15:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:57692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231739AbhH0HPG (ORCPT ); Fri, 27 Aug 2021 03:15:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78AB660F5B; Fri, 27 Aug 2021 07:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630048457; bh=qrcqu6khz/oNNrbbJLXzcXuNnrVMH3an5CYyCW5I5VM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pAY7vaQObbsrxzuqp+RX7zgEHWa9M2/prE7QR06rBCqG+LNlUgFUA0E/HLLTnDGmS C1uLmyCHnChE15+z/zws6kqEZEnvwf11N/gimWRDDRubbuTsg8wwD0CLa1rrcOMQSs zgWXf37wMqBggZ61zZXc/kk0P/UJsiLJEsDxsLik= Date: Fri, 27 Aug 2021 09:14:12 +0200 From: Greg Kroah-Hartman To: Woody Lin Cc: Todd Kjos , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , Suren Baghdasaryan , linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH] ANDROID: staging: add userpanic-dev driver Message-ID: References: <20210826092854.58694-1-woodylin@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 11:51:03AM +0800, Woody Lin wrote: > On Thu, Aug 26, 2021 at 6:54 PM Greg Kroah-Hartman > wrote: > > > > On Thu, Aug 26, 2021 at 06:23:53PM +0800, Woody Lin wrote: > > > On Thu, Aug 26, 2021 at 5:48 PM Greg Kroah-Hartman > > > wrote: > > > > > > > > On Thu, Aug 26, 2021 at 05:28:54PM +0800, Woody Lin wrote: > > > > > Add char device driver 'userpanic-dev' that exposes an interface to > > > > > userspace processes to request a system panic with customized panic > > > > > message. > > > > > > > > > > Signed-off-by: Woody Lin > > > > > --- > > > > > drivers/staging/android/Kconfig | 12 +++ > > > > > drivers/staging/android/Makefile | 1 + > > > > > drivers/staging/android/userpanic-dev.c | 110 ++++++++++++++++++++++++ > > > > > > > > Why is this in staging? What is wrong with it that it can not just go > > > > into the real part of the kernel? A TODO file is needed explaining what > > > > needs to be done here in order for it to be accepted. > > > > > > Got it. No more TODO for this driver and I will move it to drivers/android/. > > > > > > > > > > > But why is this really needed at all? Why would userspace want to panic > > > > the kernel in yet-another-way? > > > > > > The idea is to panic the kernel with a panic message specified by the userspace > > > process requesting the panic. Without this the panic handler can only collect > > > panic message "sysrq triggered crash" for a panic triggered by user processes. > > > Using this driver, user processes can put an informative description - > > > process name, > > > reason ...etc. - to the panic message. > > > > What custom userspace tool is going to use this new user/kernel api and > > again, why is it needed? Who needs to panic the kernel with a custom > > message and where is that used? > > It's for Android's services. Currently there are usages like these: > > * init requests panic in InitFatalReboot (abort handler). > https://android.googlesource.com/platform/system/core/+/master/init/reboot_utils.cpp#170 > android::base::WriteStringToFile("c", PROC_SYSRQ); > > * llkd requests panic to recover kernel live-lock. > https://android.googlesource.com/platform/system/core/+/master/llkd/libllkd.cpp#564 > android::base::WriteStringToFd("c", sysrqTriggerFd); > > * Watchdog requests panic to recover timeout-loop. > https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/Watchdog.java#847 > doSysRq('c'); > > So to improve the panic message from "sysrq triggered crash" to a more > informative one (e.g.: "Watchdog break timeout-loop", "llkd panic > live-lock"), we'd like to add this driver to expose a dedicated > interface for userspace to panic the kernel with a custom message. Later > the panic handler implemented per platform can collect the message and > use it to build the crash report. A crash report with a more readable > title (compared to the generic "sysrq triggered crash") will be easier > to categorize, triage, etc. But you can do that today from userspace, just write to the kernel log before doing the sysrq call. That way your tools can pick up what you need later on, no kernel changes should be needed at all. > And the reason to submit this to upstream, instead of making it a vendor > module, is that we'd like to enable it for the early stage of "init", where > none of the kernel module has been mounted. Helps if it would actually build :( thanks, greg k-h