From patchwork Sun Nov 11 20:20:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 10677827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1641214BD for ; Sun, 11 Nov 2018 20:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F34CE29AC7 for ; Sun, 11 Nov 2018 20:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E35252A1F7; Sun, 11 Nov 2018 20:20:52 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C54472A1EF for ; Sun, 11 Nov 2018 20:20:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A27376B0003; Sun, 11 Nov 2018 15:20:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF3E6B0005; Sun, 11 Nov 2018 15:20:50 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 876E26B0006; Sun, 11 Nov 2018 15:20:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by kanga.kvack.org (Postfix) with ESMTP id 2D09F6B0003 for ; Sun, 11 Nov 2018 15:20:50 -0500 (EST) Received: by mail-wm1-f69.google.com with SMTP id r200-v6so7219044wmg.1 for ; Sun, 11 Nov 2018 12:20:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=76ZAeLHzXWR1m0t0/LiXvcHEh/NLJD5IVgBQJYWmIkw=; b=nG3+AiK2BsrtNUYdLepT1dRMspUmhUtVikZQuAiqv+dKFr+Axe0jKYA6gaP2JpMKhS CdEqGnckiTB8pDukBzBBuVKnJYnfBF1727q+V07glNdeEvwVHHJwt1VLh/Z/Gasi2tkT rstRKb6/GEeoN6zLuSuHf0kApyrxPqZrWal4JXcDhIcAmlROhiSH693YkaJviBJ9LQyj IpCZQ3D/3njpZ92ldSLs7WMQj0Jc+CkiLKg8aqi+8gEAdC2tOmSi9Az0Q8vo1hehldqE 82A2a2czdEXQISEjf9X06ZN7r+ujSx4P8J50GG2JjSZCY5SluIVoPdHvvyAqCt2dBa1V 2tuw== X-Gm-Message-State: AGRZ1gLqdM5+seYRVjd2kgwr+BmRJfCUyOi2fj+CSwbPGLpndmIky184 8uVLeAU2rRXj8i/wBwpWaE3CkkGW5FPqZv4Soie0mfKAr1SyIi4AFJd9e+INYFXTS3F1v07+Uov UVh5kZ04OlBzE7jCiEP9cugXfMF4AsHxKw0uTkXuJIGaGtfYvmcFCd5prR12YhDm8FMT1hgPrMB DfdZqDW5zWsu9LXu7+inftRw1pj0M6RNkE6davu1SSEasE+H8qbjQn29MVHOmE5ZtXLlwGxIwnO GOcIkmoya1QJ2po1kG7HbeXR8UzB6qz7odeoI6yFNTVmm3o/9JiEQE2Qy9FCKZ/CBOs0Q5opnx6 Dvzm2fpduSVjLoyp3/vVTp6VyV5Ext5RkOypSysv6/Ww2w6yhZw4m4SZSA9rEHXveXih84bYrdF T X-Received: by 2002:a5d:47d2:: with SMTP id l18-v6mr16285250wrs.319.1541967649570; Sun, 11 Nov 2018 12:20:49 -0800 (PST) X-Received: by 2002:a5d:47d2:: with SMTP id l18-v6mr16285226wrs.319.1541967648860; Sun, 11 Nov 2018 12:20:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967648; cv=none; d=google.com; s=arc-20160816; b=JOQ0h2Nq+49kq6UlVV9FJ8R0j+YnZlo0Y9LWB6W6kQdKOUo2Cnm/n1nOOUi6iYlAJ6 e9odQqj0E2p2ynF2p9jrvIayCPfnqSHFF7rJTKvhjD7/TYnP/VSMMEreVroQ8G6wPXKX r2u/jqZV/KtIvonNUAnkoTNYjvaejLwlre7Zbqp2NnTz3LKjJYdUqpIJZvu98Y12zV1m dlF7bHdI+/QUfPe2Xy73sM09tBxQpe/TCPIeyLBBD86WUB9xEIdfm5senMhDtw6dt6Xy mejpaaIE65aJG/RwA0XECsLe0iWn/D7NPDrY7sfC3yfeBRoLAR5oTTSgANXzChAkF5Ei JAWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=76ZAeLHzXWR1m0t0/LiXvcHEh/NLJD5IVgBQJYWmIkw=; b=ftK9cPbaRtwTswN081WIvauvrOUg5BfwhP/JOU+0Vh38gwL7PJPm31YkhKQ45rlvEg CbVXWoL6TvTa/zh+X5jBR6sZlKK92rG5A+onDnUR6RSUVVDFvd7Q6P5ji/C3fbE4NwCp +Q/nRMhZvuBHFf4D7q4xqU76/o8sEypeyyMCYcx+YRbfx4qumiNF0YT04wrexFOBDadR qYbxF1xvzKbWw8T/+S4PnbU6DX8leDef1jzAGAeBzXQjMJM87+Rv6/4S7byPqu8CPtNF uDagCCooWvEn4quQ1doA9oniLQ64qKpjcaViOdYXD6jNVUKHG4km0HD6rRcc4f89Y8I1 0wBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vYVIbHAk; spf=pass (google.com: domain of sudipm.mukherjee@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=sudipm.mukherjee@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id o15-v6sor4294277wmg.17.2018.11.11.12.20.48 for (Google Transport Security); Sun, 11 Nov 2018 12:20:48 -0800 (PST) Received-SPF: pass (google.com: domain of sudipm.mukherjee@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vYVIbHAk; spf=pass (google.com: domain of sudipm.mukherjee@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=sudipm.mukherjee@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=76ZAeLHzXWR1m0t0/LiXvcHEh/NLJD5IVgBQJYWmIkw=; b=vYVIbHAkW8jQNNPTvqJEzkvXdOTcqzShSL6KmUaMzh+GLR20yiPg0JApm04RElAoSy e4aVl5l1y/RACqtY0siorpPBvZnii2QKCLHMOilSvMrgAAjp7KMx7/rc8RGzyd3duimC 5nVgIzFV1NdG74U9o1TdQkcoh3nnCFRBNT2b9NT92PXzuLrSgLzUcIHPcrYApKtoHB0M B16Hv5lFTXkgVmA2Ll1zAVFgrlmolWdBqqzRjuDMro6Tg8CXreKy8SdYkNnrNVC4L44E j0kiU7etrkABn2jlD4ZBqi7EhYs4gjQhnWfj/kqN4nHHRaJPRDeAzaGz90QTqunNGD3t J+Lg== X-Google-Smtp-Source: AJdET5fCE40EMwfniXnqMFZAO/78B7MlMbLrqqXVWE4SVxxhgJIiup0YdP2RTIOfxZnXtZKOVONcZw== X-Received: by 2002:a1c:63c2:: with SMTP id x185-v6mr5624784wmb.27.1541967648359; Sun, 11 Nov 2018 12:20:48 -0800 (PST) Received: from debian (cpc101300-bagu16-2-0-cust362.1-3.cable.virginm.net. [86.21.41.107]) by smtp.gmail.com with ESMTPSA id o15-v6sm11647066wrw.47.2018.11.11.12.20.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Nov 2018 12:20:47 -0800 (PST) Date: Sun, 11 Nov 2018 20:20:45 +0000 From: Sudip Mukherjee To: Greg Kroah-Hartman Cc: stable@vger.kernel.org, Tetsuo Handa , Sergey Senozhatsky , Tejun Heo , akpm@linux-foundation.org, linux-mm@kvack.org, Cong Wang , Dave Hansen , Johannes Weiner , Mel Gorman , Michal Hocko , Vlastimil Babka , Peter Zijlstra , Linus Torvalds , Jan Kara , Mathieu Desnoyers , Byungchul Park , Pavel Machek , Steven Rostedt , Petr Mladek Subject: request for 4.14-stable: fd5f7cde1b85 ("printk: Never set console_may_schedule in console_trylock()") Message-ID: <20181111202045.vocb3dthuquf7h2y@debian> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Hi Greg, This was not marked for stable but seems it should be in stable. Please apply to your queue of 4.14-stable. --- Regards Sudip From 2fee30107ea1c06f0b09f5ba4132ea4393454212 Mon Sep 17 00:00:00 2001 From: Sergey Senozhatsky Date: Tue, 16 Jan 2018 13:47:16 +0900 Subject: [PATCH] printk: Never set console_may_schedule in console_trylock() commit fd5f7cde1b85d4c8e09ca46ce948e008a2377f64 upstream This patch, basically, reverts commit 6b97a20d3a79 ("printk: set may_schedule for some of console_trylock() callers"). That commit was a mistake, it introduced a big dependency on the scheduler, by enabling preemption under console_sem in printk()->console_unlock() path, which is rather too critical. The patch did not significantly reduce the possibilities of printk() lockups, but made it possible to stall printk(), as has been reported by Tetsuo Handa [1]. Another issues is that preemption under console_sem also messes up with Steven Rostedt's hand off scheme, by making it possible to sleep with console_sem both in console_unlock() and in vprintk_emit(), after acquiring the console_sem ownership (anywhere between printk_safe_exit_irqrestore() in console_trylock_spinning() and printk_safe_enter_irqsave() in console_unlock()). This makes hand off less likely and, at the same time, may result in a significant amount of pending logbuf messages. Preempted console_sem owner makes it impossible for other CPUs to emit logbuf messages, but does not make it impossible for other CPUs to append new messages to the logbuf. Reinstate the old behavior and make printk() non-preemptible. Should any printk() lockup reports arrive they must be handled in a different way. [1] http://lkml.kernel.org/r/201603022101.CAH73907.OVOOMFHFFtQJSL%20()%20I-love%20!%20SAKURA%20!%20ne%20!%20jp Fixes: 6b97a20d3a79 ("printk: set may_schedule for some of console_trylock() callers") Link: http://lkml.kernel.org/r/20180116044716.GE6607@jagdpanzerIV To: Tetsuo Handa Cc: Sergey Senozhatsky Cc: Tejun Heo Cc: akpm@linux-foundation.org Cc: linux-mm@kvack.org Cc: Cong Wang Cc: Dave Hansen Cc: Johannes Weiner Cc: Mel Gorman Cc: Michal Hocko Cc: Vlastimil Babka Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Jan Kara Cc: Mathieu Desnoyers Cc: Byungchul Park Cc: Pavel Machek Cc: linux-kernel@vger.kernel.org Signed-off-by: Sergey Senozhatsky Reported-by: Tetsuo Handa Reviewed-by: Steven Rostedt (VMware) Signed-off-by: Petr Mladek Signed-off-by: Sudip Mukherjee --- kernel/printk/printk.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7161312593dd..a9cf2e15f6a3 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1763,12 +1763,19 @@ asmlinkage int vprintk_emit(int facility, int level, /* If called from the scheduler, we can not call up(). */ if (!in_sched) { /* + * Disable preemption to avoid being preempted while holding + * console_sem which would prevent anyone from printing to + * console + */ + preempt_disable(); + /* * Try to acquire and then immediately release the console * semaphore. The release will print out buffers and wake up * /dev/kmsg and syslog() users. */ if (console_trylock()) console_unlock(); + preempt_enable(); } return printed_len; @@ -2083,20 +2090,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); -- 2.11.0