Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3655868yba; Tue, 7 May 2019 05:05:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMmyv3SjzlUEr2pGcu5SH77UbQH1pH58JjNz/BMn/NzzkbT/iKV4WyociMC6bnx5VbRTEP X-Received: by 2002:a63:4621:: with SMTP id t33mr36510666pga.246.1557230729062; Tue, 07 May 2019 05:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557230729; cv=none; d=google.com; s=arc-20160816; b=gDjOtY0JAaI6ijoRSxfq+S+ZpMv0DYXODD974gPV4H49MOStJO3SrWOjB49wKYtBYx 56aWT035FPtKKMaSqRC0aT/vCjonDgGIyM/c0tdV6eLZx0hZvzZX9okC4VnaqTEgrnE7 2LM1F9Wrt1/hvn/xndS2Higj+cAIZbtVazdggafXJdewvtc3n7gq8dJwjCH38T3bjLQG p4EHf/7qUDUkUkL4zdrMGrJKoO8KqZgD82EyyUzABeG59IcXGWHLtLGvkvf9znz48LhZ qs6Uie1Cr8MB8cWraiIYrivA3ajVok8cmp1ZYrxn1Gr2T7eGbebdQVX2MItO6Eqd0EnH glpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/oTvTlP94pWWIjSwl1dlNPDeJonG8mFiBmM41iH9/Ys=; b=GXLfAKoxy3wMBFXMqGTYHs7lbv0up1lDnpz0ew+QBFKlrDofY0aVrcN1oIB5jDO3sV H6o2NBrj6g/GUsODybuK7p6Eo966ZnJtLeMo+K1yFPzsOmeIfrzg0X85chrYbMyzxUOK bTuruIwnV9Q6pP2f4KE3T9wkO+2o0WnplvGemv1irxWKieVUqEiDaWz97Z3Dt6VhLwxK Fi3W1rfGi0QCJPKG/mum+hbyTrSNOJX7qkddjNIwr7/Z7p2FrqZf7b3eL+i3hXG285UM 6AXqm7o+qXaP+H16iSnhxu3o+vhVmItRE4CaJ1BW23hi4WviVOF/lRQvqUZiC4I6C3tr vemA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z33si18599529pgl.537.2019.05.07.05.05.12; Tue, 07 May 2019 05:05:29 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726742AbfEGMEB (ORCPT + 99 others); Tue, 7 May 2019 08:04:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50454 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbfEGMEB (ORCPT ); Tue, 7 May 2019 08:04:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C57FA81F19; Tue, 7 May 2019 12:03:56 +0000 (UTC) Received: from treble (ovpn-123-166.rdu2.redhat.com [10.10.123.166]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74F631A7D9; Tue, 7 May 2019 12:03:52 +0000 (UTC) Date: Tue, 7 May 2019 07:03:50 -0500 From: Josh Poimboeuf To: Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Joe Lawrence , Kamalesh Babulal , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] livepatch: Remove duplicate warning about missing reliable stacktrace support Message-ID: <20190507120350.gpazr6xivzwvd3az@treble> References: <20190430091049.30413-1-pmladek@suse.com> <20190430091049.30413-2-pmladek@suse.com> <20190507004032.2fgddlsycyypqdsn@treble> <20190507014332.l5pmvjyfropaiui2@treble> <20190507112950.wejw6nmfwzmm3vaf@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190507112950.wejw6nmfwzmm3vaf@pathway.suse.cz> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 07 May 2019 12:04:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 07, 2019 at 01:29:50PM +0200, Petr Mladek wrote: > On Mon 2019-05-06 20:43:32, Josh Poimboeuf wrote: > > On Mon, May 06, 2019 at 07:40:32PM -0500, Josh Poimboeuf wrote: > > > On Tue, Apr 30, 2019 at 11:10:48AM +0200, Petr Mladek wrote: > > > > WARN_ON_ONCE() could not be called safely under rq lock because > > > > of console deadlock issues. Fortunately, there is another check > > > > for the reliable stacktrace support in klp_enable_patch(). > > > > > > > > Signed-off-by: Petr Mladek > > > > --- > > > > kernel/livepatch/transition.c | 9 ++++++++- > > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c > > > > index 9c89ae8b337a..8e0274075e75 100644 > > > > --- a/kernel/livepatch/transition.c > > > > +++ b/kernel/livepatch/transition.c > > > > @@ -263,8 +263,15 @@ static int klp_check_stack(struct task_struct *task, char *err_buf) > > > > trace.nr_entries = 0; > > > > trace.max_entries = MAX_STACK_ENTRIES; > > > > trace.entries = entries; > > > > + > > > > ret = save_stack_trace_tsk_reliable(task, &trace); > > > > - WARN_ON_ONCE(ret == -ENOSYS); > > > > + /* > > > > + * pr_warn() under task rq lock might cause a deadlock. > > > > + * Fortunately, missing reliable stacktrace support has > > > > + * already been handled when the livepatch was enabled. > > > > + */ > > > > + if (ret == -ENOSYS) > > > > + return ret; > > > > > > I find the comment to be a bit wordy and confusing (and vague). > > Then please provide a better one. I have no idea what might make > you happy and am not interested into an endless disputing. Something like this would be clearer: if (ret == -ENOSYS) { /* * This arch doesn't support reliable stack tracing. No * need to print a warning; that has already been done * by klp_enable_patch(). */ return ret; } But my next point was that changing the code would be even better than fixing the comment. > > > Also this check is effectively the same as the klp_have_reliable_stack() > > > check which is done in kernel/livepatch/core.c. So I think it would be > > > clearer and more consistent if the same check is done here: > > > > > > if (!klp_have_reliable_stack()) > > > return -ENOSYS; > > Huh, it smells with over engineering to me. How so? It makes the code more readable and the generated code should be much better because it becomes a build-time check. But I think Miroslav's suggestion to revert 1d98a69e5cef would be even better. > > > ret = save_stack_trace_tsk_reliable(task, &trace); > > > > > > [ no need to check ret for ENOSYS here ] > > > > > > Then, IMO, no comment is needed. > > > > BTW, if you agree with this approach then we can leave the > > WARN_ON_ONCE() in save_stack_trace_tsk_reliable() after all. > > I really like the removal of the WARN_ON_ONCE(). I consider > it an old fashioned way used when people are lazy to handle > errors. It might make sense when the backtrace helps to locate > the context but the context is well known here. Finally, > WARN() should be used with care. It might cause reboot > with panic_on_warn. The warning makes the function consistent with the other weak functions in stacktrace.c and clarifies that it should never be called unless an arch has misconfigured something. And if we aren't even checking the specific ENOSYS error as I proposed then this warning would make the error more obvious. -- Josh