Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3938287imm; Mon, 18 Jun 2018 06:40:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCkdk9gAlCkXXOUHG0oUIVAcEkS20LsW4FX7zXXktWgXQKaMqrJ4DXt2eUnVwNBmGZY2Bz X-Received: by 2002:a17:902:8a4:: with SMTP id 33-v6mr13960704pll.343.1529329213945; Mon, 18 Jun 2018 06:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529329213; cv=none; d=google.com; s=arc-20160816; b=LK0xVziQg0zKxFWUEyn7/muVuKDT0ged7pOk9VVId9Su/6lOfT0Fi8LkctrPKXNbFo Ii1RoUoZf9nHq8273DBc245q2EP4LXxfRc9cnaxtfknVMIpkOc/RZjZiOa0GCUO88PKp 01xrZBGo8uwAS5lhrRg22wmazUI2j0uKFpAfe8DPQJNHSvK3rhd55dPXfRrOuPyNlINy Z3oO7al6bAbDb40GPVrcfv1kILGmHIzzxjc1zI/5kjKe4OZwcUSsRa6KH71cHc+blH/0 eaZxVHSv7JXb7WvsLK984ZTLzV9lm4TKLqtCReB7jT+UHUSlF3w3HXu8oMAbJ6RL8Y1x qTXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=3qwusu98xqnuu6vQcpufiplv00FxQvUC8KnkygxoMJM=; b=glHkQFpF2pu63CgnYTNkv+UY8Prl3WpLfKPPJfeo31owTR/Dt74WLRZCH+j2QD88X/ 8tU0trQbdOMeMaDoVztUWJi1wzY21UqoKtVrflIQe11hyCUHcWdF8e62b3rp9+DMEUwr keTaeEYlKGAokd8NQHZvPOaG7e6cZwd/mEOn1/R1ne/NEbimjehgV2C1tzzoRr8UQe1s P+Yeu6UTrfkP2UJhkRD9wXahBnwZDQRwvqAQU8G8+gxbgZF5ifE4jvAF4oaa7YxqXioS hErzki2qmxByetNHr4k0augp8/R9c8LSMoZWcEl/tq/llXLDnXxWspE66j5sjjWB/ELZ 4Bwg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m63-v6si14299840pld.429.2018.06.18.06.40.00; Mon, 18 Jun 2018 06:40:13 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934748AbeFRNiy (ORCPT + 99 others); Mon, 18 Jun 2018 09:38:54 -0400 Received: from www.llwyncelyn.cymru ([82.70.14.225]:33268 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934267AbeFRNiw (ORCPT ); Mon, 18 Jun 2018 09:38:52 -0400 Received: from alans-desktop (82-70-14-226.dsl.in-addr.zen.co.uk [82.70.14.226]) by fuzix.org (8.15.2/8.15.2) with ESMTP id w5IDcJE5007311; Mon, 18 Jun 2018 14:38:19 +0100 Date: Mon, 18 Jun 2018 14:38:18 +0100 From: Alan Cox To: Sergey Senozhatsky Cc: Petr Mladek , Steven Rostedt , Greg Kroah-Hartman , Jiri Slaby , Linus Torvalds , Peter Zijlstra , Andrew Morton , Dmitry Vyukov , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCH 0/6] Use printk_safe context for TTY and UART port locks Message-ID: <20180618143818.50b2f2f9@alans-desktop> In-Reply-To: <20180615093919.559-1-sergey.senozhatsky@gmail.com> References: <20180615093919.559-1-sergey.senozhatsky@gmail.com> Organization: Intel Corporation X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > It doesn't come as a surprise that recursive printk() calls are not the > only way for us to deadlock in printk() and we still have a whole bunch > of other printk() deadlock scenarios. For instance, those that involve > TTY port->lock spin_lock and UART port->lock spin_lock. The tty layer code there is not re-entrant. Nor is it supposed to be > So the idea of this patch set is to take tty_port->lock and > uart_port->lock from printk_safe context and to eliminate some > of non-recursive printk() deadlocks - the ones that don't start > in printk(), but involve console related locks and thus eventually > deadlock us in printk(). For this purpose the patch set introduces > several helper macros: I don't see how this helps - if you recurse into the uart code you are still hitting the paths that are unsafe when re-entered. All you've done is messed up a pile of locking code on critical performance paths. As it stands I think it's a bad idea. > Of course, TTY and UART port spin_locks are not the only locks that > we can deadlock on. So this patch set does not address all deadlock > scenarios, it just makes a small step forward. > > Any opinions? The cure is worse than the disease. The only case that's worth looking at is the direct polled console code paths. The moment you touch the other layers you add essentially never needed code to hot paths. Given printk nowdays is already somewhat unreliable with all the perf related changes, and we have other good debug tools I think it would be far cleaner to have some kind of if (spin_trylock(...)) { console_defer(buffer); return; } helper layer in the printk/console logic, at least for the non panic/oops cases. Alan