Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp293763imm; Tue, 19 Jun 2018 21:29:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKq5CrAROyYt9XRlWZNVymp83ItrGB8p8h6TMhRbI60Xushn/ozap0yCjrxPOiCgo76DZxK X-Received: by 2002:a65:644a:: with SMTP id s10-v6mr17079072pgv.360.1529468994107; Tue, 19 Jun 2018 21:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529468994; cv=none; d=google.com; s=arc-20160816; b=V9H6+tVGeKoS5dV3wHMhjD0Q2aL9u4lgnYnwZFZDD+sps0ylRcA4bkbsChEweJpw2Y P3swngxkZML+rfAVk/GNQvNL46ncXs7x5LlhDgkFCC8Q5HQq5avCAMjo//4lqMaSHMjU KnwK7hvSM6GC3dloKCIwEUm/cFE9fUoe1K5Fw5CNA4Vq3uqEXCezVo3QgVBLBhLehc7v ymUDRlp7rfwmUcI6R5f+iVwkX8OLl3pFcKX+aaToaoc301nBk4Gdw41s6CimrXjIo9ga molXj9weMHRarCq8pMxe7U7fVE0oYtD7F1D7IpNIPK4s6bHZqXsJjctovYzA1VGQiBmV XrZg== 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:dkim-signature:arc-authentication-results; bh=5XxPFcbufTiQQMxTgixuo/u0WlgPO3UZSe1lymGHCaA=; b=eQA40ivZaP9rkdX7Tw4G/hJLC0mLIlS1Etfrc8nXa9LvWR1La1qXwV626/A66l9RR6 b7NASlzWQ8WlR9zmJc8mcY02SNF/eeKmedb70piXbkfAd+l1Tw40mJWMnwuBEh7ejDSS XweBLqBnYBOW+9hQfg/MHGixpe9GEy8oQd1CYik9E3C1An8juHpVDtJAlhT3newHkhFm 9jbuOopI5zu629LlZPnBTp/hCaJd63JblOzQM40Bcf/xTz+xOU/DNpgGtW7d0AMyNSp3 VTb2P9JyOVKbtCnMrzJZhb9s9nVeE/HTg3NUXbDcHHSGvK/Id2bP8xLx4FE6gcOjiZ0E vaMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oGvFpzRh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17-v6si1443513pfg.305.2018.06.19.21.29.38; Tue, 19 Jun 2018 21:29:54 -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=pass header.i=@gmail.com header.s=20161025 header.b=oGvFpzRh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751436AbeFTE2z (ORCPT + 99 others); Wed, 20 Jun 2018 00:28:55 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:39306 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750842AbeFTE2x (ORCPT ); Wed, 20 Jun 2018 00:28:53 -0400 Received: by mail-pg0-f68.google.com with SMTP id w12-v6so860915pgc.6; Tue, 19 Jun 2018 21:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5XxPFcbufTiQQMxTgixuo/u0WlgPO3UZSe1lymGHCaA=; b=oGvFpzRh1JbWVsTYQXSzZ4TCjdRhu+8eXi7SiiMVIthWcJvCYEY+wRHpx1BXEO9KPr pKwzlM4Ocj/70YJUrkpKLOeXuI2YCz/tR+5hd6+XpGzEMpOnM0sMUPOQNkq4955It8Vi bZOykvqsk0Fk9rez6HN7fhXkmDM5R+AoDW7A29D8w5T2XCh6P90Lf8kISg+U6KWGMceB rRELcGZ1KkkEfehGERrfnLc+irrUKW8W6QqZOzSZSjLyBF8IdM6ffp7d1FlHSDc2cIxg 4aWdXr9jdBbwpzZckqKko1bK/c2j18/2mthvKih4sQkCpzeVCn20j5Eu2DcDY0F/o7wN hVXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5XxPFcbufTiQQMxTgixuo/u0WlgPO3UZSe1lymGHCaA=; b=UhyEF9DWU6vTsWCu85+g+AK9KRu7KVOIvWba9PdsRAjC8oSEu+dAqjesAQXgBPlnC+ K/7t+cWz0oycoSAQic1bKco/+aOpqArVHtOVTlloPZ+PE2fiqXyjaYu+w7MdbVqdsML5 EkWl509Gb4XrS93jeHVT/hKXcnVjPABaHGrqtEJ2ZuRDtMMYWwJb3JYc7rZax0a9Y6Oh LY98gl3MHKX8MOpQD7/fuS0TKg3ussj03SOy5Jp9pCn/aXfzspg1F0kgz7uVdi1PRL/C wwTJ3fAGzXnDGz1JEp4uMFLNgHP63OcxZ/OKSsgBDcy4Oy2WLiTm2cv6mtLMNDF5GcRK q0Sg== X-Gm-Message-State: APt69E2AkXCBiMZdoMQdrqw4M3EBoNRa9hlLyTshdUbw1G4ORv5jEezE czVU+ewssbrpTxNqP6+qMqc= X-Received: by 2002:aa7:83d1:: with SMTP id j17-v6mr21198679pfn.236.1529468932853; Tue, 19 Jun 2018 21:28:52 -0700 (PDT) Received: from localhost ([110.70.59.159]) by smtp.gmail.com with ESMTPSA id a10-v6sm1867725pfg.107.2018.06.19.21.28.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jun 2018 21:28:51 -0700 (PDT) Date: Wed, 20 Jun 2018 13:28:47 +0900 From: Sergey Senozhatsky To: Linus Torvalds Cc: Sergey Senozhatsky , Petr Mladek , One Thousand Gnomes , Steven Rostedt , Greg Kroah-Hartman , Jiri Slaby , Peter Zijlstra , Andrew Morton , Dmitry Vyukov , Linux Kernel Mailing List , linux-serial , SergeySenozhatsky Subject: Re: [RFC][PATCH 0/6] Use printk_safe context for TTY and UART port locks Message-ID: <20180620042847.GH650@jagdpanzerIV> References: <20180615093919.559-1-sergey.senozhatsky@gmail.com> <20180618143818.50b2f2f9@alans-desktop> <20180619005308.GA405@jagdpanzerIV> <20180619083021.4avsgvcqjrpkat6s@pathway.suse.cz> <20180620025050.GE650@jagdpanzerIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (06/20/18 12:38), Linus Torvalds wrote: > On Wed, Jun 20, 2018 at 11:50 AM Sergey Senozhatsky > wrote: > > > > It's not UART on its own that immediately calls into printk(), that would > > be trivial to fix, it's all those subsystems that serial console driver > > can call into. > > We already have the whole PRINTK_SAFE_CONTEXT_MASK model that only > adds it to a secondary buffer if you get recursion. Why isn't that > triggering? That's the whole point of it. This is exactly what I'm doing in my patch set. PRINTK_SAFE_CONTEXT_MASK so far worked *one* way only: when we start from printk.c IOW: printk -> printk_safe_mask -> vsprinf -> printk But we also can have printk-related deadlocks the *other* way around. For instance: uart -> printk -> uart printk_safe_mask is not triggering there because we don't use printk_safe in uart / tty yet. And this is what I do in my patch set - extend printk_safe usage. The patch set does not add any _new_ locks or locking rules. It just replaces the existing spin_lock(a) with prinkt_safe_enter(); spin_lock(a) and spin_unlock(a) with spin_unlock(a) printk_safe_exit(); and that's it. So now we use printk_safe mechanism to avoid another bunch of deadlock scenarious: which don't start from printk, but from parts of the kernel which printk eventually calls. -ss