From patchwork Sat Jan 14 06:28:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 9516745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66605601DA for ; Sat, 14 Jan 2017 06:28:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5724C286A4 for ; Sat, 14 Jan 2017 06:28:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BD79286B7; Sat, 14 Jan 2017 06:28:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18597286A4 for ; Sat, 14 Jan 2017 06:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751312AbdANG2z (ORCPT ); Sat, 14 Jan 2017 01:28:55 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35323 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750901AbdANG2y (ORCPT ); Sat, 14 Jan 2017 01:28:54 -0500 Received: by mail-pf0-f195.google.com with SMTP id f144so10855560pfa.2; Fri, 13 Jan 2017 22:28:54 -0800 (PST) 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=gaGl1pfnCipoKj6FI0S1bpSZUgm3fQYoQfx6dDuskdk=; b=MzQzsGGlxzHeKcp4ygQphsXs8dF1hCRUOESKX+pHbJr3P+YbpGLv4yunHyghCEbvfI 4jdpgJeOSQpaXGw3tDkZ10Xps692ZdkTppu6NupRtZidekQgM9L/AWJbHpEEB6VIiH4Q PlV9Yb1qtldhZD/islZlVhnd1mGbgtdTSvKXA6LVrUQw/2/vn2EQil6GXvAZjprBvSUS 104a4VvS2o6inTrdxp3b0uFSPxLOZdlu5sfZApRgYW4IFoFiBf4mPEmMZVo3CoNgcknj MAVL6TQICwql+5eW4q+xJQsncebPi4ylmCiEuWM2DqagAvFJEKUz1iz2AIqXA7jN+3lC lKnQ== 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=gaGl1pfnCipoKj6FI0S1bpSZUgm3fQYoQfx6dDuskdk=; b=Eg10Nuvs0Pv8LSOxSf7fFpci2mozZFPoXvA5BVie9K+PEV+ZM0xtUbFY+R2dXZHICb CRgd2T63FeKS4jt/HDT2Xq4VReYSBuOF4tq/PYHUuDCJbIfSdsHcYJADZfXoKV7ClOmY CRrZkZ+ZvBEY4n8bsU6MhDLEDVbSrmWceEKYUXhlq07dl3xNZNJTB+1TyFxSss1M8yRr DxHLIIGraYU2xgvx5WWM3o61PugrAOTki/48Z9LNB/Rj8/PxVIX1b67TyXGGZBW+XLT5 Dqtib9Zr+F/212RI/NU2UKWibyjlMpieorP+Co5uy+jdomlruMR7oYOQurf6pAyNbwaC xK+g== X-Gm-Message-State: AIkVDXLf3U1lHR0UnPznJvS7ybg+8SIR8lyhT/RgRCZ8ivokbPvJoTlgWgYTPQ/H/oGggw== X-Received: by 10.84.176.131 with SMTP id v3mr34914394plb.20.1484375333909; Fri, 13 Jan 2017 22:28:53 -0800 (PST) Received: from localhost ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id 75sm19660099pfp.80.2017.01.13.22.28.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jan 2017 22:28:52 -0800 (PST) Date: Sat, 14 Jan 2017 15:28:25 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Tetsuo Handa , Steven Rostedt , Peter Zijlstra , Andrew Morton , Greg Kroah-Hartman , Jiri Slaby , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] printk: Correctly handle preemption in console_unlock() Message-ID: <20170114062825.GB699@tigerII.localdomain> References: <1484313321-17196-1-git-send-email-pmladek@suse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1484313321-17196-1-git-send-email-pmladek@suse.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On (01/13/17 14:15), Petr Mladek wrote: > Some console drivers code calls console_conditional_schedule() > that looks at @console_may_schedule. The value must be cleared > when the drivers are called from console_unlock() with > interrupts disabled. But rescheduling is fine when the same > code is called, for example, from tty operations where the > console semaphore is taken via console_lock(). > > This is why @console_may_schedule is cleared before calling console > drivers. The original value is stored to decide if we could sleep > between lines. > > Now, @console_may_schedule is not cleared when we call > console_trylock() and jump back to the "again" goto label. > This has become a problem, since the commit 6b97a20d3a7909daa066 > ("printk: set may_schedule for some of console_trylock() callers"). so I think I'd prefer to revert that commit. the reason I added the commit in question was to reduce the number of printk() soft lockups that I observed back then. however, it obviously didn't solve all of the printk() problems. now printk() is moving in a completely different direction in term of lockups and deadlocks. there will be no console_trylock() call in vprintk_emit() at all. we will either do console_lock() from scheduleable printk_kthread or console_trylock() from IRQ work. so 6b97a20d3a7909daa066 didn't buy us a lot, and it still doesn't (+ it introduced a bug). apart from that, Tetsuo wasn't really happy with the patch http://www.spinics.net/lists/linux-mm/msg103099.html so let's just return the old behavior back. --- -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7180088cbb23..ddfbd47398f8 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2078,20 +2078,7 @@ int console_trylock(void) return 0; } console_locked = 1; - /* - * When PREEMPT_COUNT disabled we can't reliably detect if it's - * safe to schedule (e.g. calling printk while holding a spin_lock), - * because preempt_disable()/preempt_enable() are just barriers there - * and preempt_count() is always 0. - * - * RCU read sections have a separate preemption counter when - * PREEMPT_RCU enabled thus we must take extra care and check - * rcu_preempt_depth(), otherwise RCU read sections modify - * preempt_count(). - */ - console_may_schedule = !oops_in_progress && - preemptible() && - !rcu_preempt_depth(); + console_may_schedule = 0; return 1; } EXPORT_SYMBOL(console_trylock);