Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2254547yba; Mon, 6 May 2019 02:39:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxssqXhYDzDTC5cvW44LkWTxWQZLzp2jm2scfw4f4H4sfsrmXzRjh5R68Z5mFbVcYnV8M+0 X-Received: by 2002:a17:902:a01:: with SMTP id 1mr30724324plo.36.1557135564713; Mon, 06 May 2019 02:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557135564; cv=none; d=google.com; s=arc-20160816; b=OzWlvB1yYGerq71tu1nx58AZ8we+8Nl3Rs5ORw3+t+PUFSVGsxHwKyy5D1GDLGgLJx mRVn3bbt7bLKmP2SyAT/Z3hhDm71M1YDoNuQ0KRzQaAKMAZrph85+Uxp7Su3LJFqcZht K8OUCpS/MnXEt1FiyWHfsXLvmqVGm/ylSxk+27GDjaws48dQ6OfYHfLwPP2MCiRPXY3p zr69PR7ezj6GSkXjRAW/NaSfWzHpwziblmQLXtIvVyIvkdvWrmIVV3mWhd1PZACnvv8/ gOYXl2fyhOOdQ20OyiOwtkiERiCdUcn0PKyUq0E+wzgplD+y2zf6RVSjAox7KF0hs4F7 8xIw== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=MUCBKoTdL7VxsTLho10xCSR8XMf/U+cya+mYQZsv5YA=; b=jNZtZpNSfu5MO3H0Fncm7W0be9Ys1hFT0kzYZ/pUSWVNWq6SjJJh3pOJG0fBW6m48z gFMhRhXzjItH3AAwLTebbnrkDJetI/FnWoLAHZDE00nj3X9nFZPVl3X+HsW9FKilxE9o pn6Y4tjv0Ji5zUara12zOEfz/AJ8UQZQnpWCqyrL97uZBBC91bJGTo4BfmZZH5hpgq3m GrN+PG6upYc2QFSroDJvGO+1U5rnBPRipXKkyIv3RDHrQj+iH6kJuyyrlqkxgwOuO2tA 611Nrn9DO8G351B6+xLykoyXX2zwYAlYixYiFcskVvdkwRkXtvetM6AchiMr7a7Wq3XQ vSmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=GrqoWz8i; 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 g132si14090005pfc.260.2019.05.06.02.39.08; Mon, 06 May 2019 02:39:24 -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; dkim=fail header.i=@ffwll.ch header.s=google header.b=GrqoWz8i; 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 S1726145AbfEFJiS (ORCPT + 99 others); Mon, 6 May 2019 05:38:18 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:40903 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfEFJiS (ORCPT ); Mon, 6 May 2019 05:38:18 -0400 Received: by mail-ed1-f65.google.com with SMTP id e56so14589056ede.7 for ; Mon, 06 May 2019 02:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MUCBKoTdL7VxsTLho10xCSR8XMf/U+cya+mYQZsv5YA=; b=GrqoWz8ic+tDcnjbjpjFtcOjd6NbN54Wyvv5rMJIdupSUBjBwo0/ROqMu7caGtGH06 lZiC9iXum79qeSwTMg5qAqzmJdIyIYMAQHMaeBPWRVkfeWFAQ3qQkV21tSPWc4JOWaoi g8cWXqYAaDYT9ZB5vyO8Cm30d3U03sJVI9Z5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=MUCBKoTdL7VxsTLho10xCSR8XMf/U+cya+mYQZsv5YA=; b=qfhN6/DvcgZjDne+btDGtbFIGwzeldQQLD+t0kYKNOIdxNRuuStd5GDALPg1xLVf/p Y3sW4gUJ/Hrncr8yMedncMKHOmLcS0WJU2/UJuH4YOQ9DQoGb+1Or9NhUwRLfq47SPQk ek5tYuIbdEIJTF/f0TcerZkOV5HWBd7Xu3uJMihwmZYBtwf+J8hOK0SfqFd4/4saoeiC okO32u2XISzdbGwxYJ2ADRscrmx84iG0XnIozdQDFCPSfN6q6zL+5S0YHTmNJC3hv67d Uzo+WoHIiUhdvwFT9aMFF154F7yBfHudi7aNpB1KSRgydOVK40KHavyA0p121ToEQBSz cwxA== X-Gm-Message-State: APjAAAW4Hn42G0T4Bgl8wz90u5IKoi8M9/8ipMa0VbJmwtT1wEnCv8Ly mz+I0ibWqloO9msSHVxZk2wvpA== X-Received: by 2002:a17:906:3403:: with SMTP id c3mr18303929ejb.177.1557135496310; Mon, 06 May 2019 02:38:16 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id g11sm157101eda.42.2019.05.06.02.38.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2019 02:38:15 -0700 (PDT) Date: Mon, 6 May 2019 11:38:13 +0200 From: Daniel Vetter To: Petr Mladek Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter , Peter Zijlstra , Ingo Molnar , Will Deacon , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org Subject: Re: [PATCH] RFC: console: hack up console_lock more v2 Message-ID: <20190506093812.GG17751@phenom.ffwll.local> Mail-Followup-To: Petr Mladek , Intel Graphics Development , Daniel Vetter , Peter Zijlstra , Ingo Molnar , Will Deacon , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org References: <20190502141643.21080-1-daniel.vetter@ffwll.ch> <20190506074553.21464-1-daniel.vetter@ffwll.ch> <20190506081614.b7b22k4prodskbiy@pathway.suse.cz> <20190506082628.wehkislebljxmk5d@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190506082628.wehkislebljxmk5d@pathway.suse.cz> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 06, 2019 at 10:26:28AM +0200, Petr Mladek wrote: > On Mon 2019-05-06 10:16:14, Petr Mladek wrote: > > On Mon 2019-05-06 09:45:53, Daniel Vetter wrote: > > > console_trylock, called from within printk, can be called from pretty > > > much anywhere. Including try_to_wake_up. Note that this isn't common, > > > usually the box is in pretty bad shape at that point already. But it > > > really doesn't help when then lockdep jumps in and spams the logs, > > > potentially obscuring the real backtrace we're really interested in. > > > One case I've seen (slightly simplified backtrace): > > > > > > Call Trace: > > > > > > console_trylock+0xe/0x60 > > > vprintk_emit+0xf1/0x320 > > > printk+0x4d/0x69 > > > __warn_printk+0x46/0x90 > > > native_smp_send_reschedule+0x2f/0x40 > > > check_preempt_curr+0x81/0xa0 > > > ttwu_do_wakeup+0x14/0x220 > > > try_to_wake_up+0x218/0x5f0 > > > > try_to_wake_up() takes p->pi_lock. It could deadlock because it > > can get called recursively from printk_safe_up(). > > > > And there are more locks taken from try_to_wake_up(), for example, > > __task_rq_lock() taken from ttwu_remote(). > > > > IMHO, the most reliable solution would be do call the entire > > up_console_sem() from printk deferred context. We could assign > > few bytes for this context in the per-CPU printk_deferred > > variable. > > Ah, I was too fast and did the same mistake. This won't help because > it would still call try_to_wake_up() recursively. Uh :-/ > We need to call all printk's that can be called under locks > taken in try_to_wake_up() path in printk deferred context. > Unfortunately it is whack a mole approach. Hm since it's whack-a-mole anyway, what about converting the WARN_ON into a prinkt_deferred, like all the other scheduler related code? Feels a notch more consistent to me than leaking the printk_context into areas it wasn't really meant built for. Scheduler code already fully subscribed to the whack-a-mole approach after all. This would mean we drop the backtrace from the native_smp_send_reschedule, or maybe we need a printk_deferred_backtrace()? -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch