Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1992932imu; Fri, 14 Dec 2018 04:11:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vyb74pDloH7gaVX5MOeXD7QhfRmFoluwKB1f8l1iUKYmQFnRCEcyxtDYbC2ejJA9pMTAAl X-Received: by 2002:a62:15c3:: with SMTP id 186mr2689721pfv.240.1544789519341; Fri, 14 Dec 2018 04:11:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789519; cv=none; d=google.com; s=arc-20160816; b=vWCGcrtXUWsPZT1AvY87R8u1aWRvf6U1e/nyIfG5sdJsyJg2sNNDS/khk5nNEATHOF 55RscMJUopyi4uf7F4xHbB6SQPqyeCLZsfD2UhQREQUzxxEBoPj7gYVGXslJInrlgFyy pN828mur5iaZJZpdhLowcUnuWzRFo/bSpUGKU4DTfvy8b1q939BE9GX9RjUhUDywXS25 dPdp/58LFu8KZh849W97DYYg3AgmCdtFGc1aP4gQloyn54//IekrvW2c7SW+Ej1joHFt xxlQT6fT0MoaEoXRjSTp8YXpJ1clYl9OiEg6/c9m33pKk0anLNQa7uFaszbhT0Qj8o9C kAmQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZF2ztK5057+us/k6vSErCneVFkdgDcXkd2Q9J3QM/sM=; b=z4ItiO2VJIOIuqB9qnjR6F/KP5xmHqB8QozTEA/zqpzD3Sj8FjT8xu4smovB4rbekD pL4+dr1rABTomAKhG1HoGtoej7I/sWXz3104UO6Id+nZJds6JNCKGWMvjGCSV89PhrsQ f/sSCp6upvl3L+/eWfyrv1qX+33pwcQhTTug3Dnyb8D4YAtf5adwzJ9Riwxfpnt5fcFF vRahIr2K+xobmlVOYbrdE+p/u6kdTOTDxChAzK4usYlDCL7pbPeW6ftmqwIfcTeLCNwX PtZ/T02t7iu9USkwkquFyrJuSaLKSmcOkX2qHvBv0lo0aa6C+msr+dJ7uYN5+/525q5V Y+Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KdN2J8Wv; 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 59si3997748ple.291.2018.12.14.04.11.44; Fri, 14 Dec 2018 04:11:59 -0800 (PST) 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=@kernel.org header.s=default header.b=KdN2J8Wv; 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 S1731115AbeLNMKc (ORCPT + 99 others); Fri, 14 Dec 2018 07:10:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:56416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731610AbeLNMK3 (ORCPT ); Fri, 14 Dec 2018 07:10:29 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 994502133F; Fri, 14 Dec 2018 12:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789429; bh=H5Wxyz92SFTDvvKbKcK3/atOP/sXOPfLcws+6nQqJ3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KdN2J8Wvockt4Rk0NTYUAOXOa1cMcWOJ6rU5PrqWjKQHNEnfaQ8tTwtUXblBR6A2D BXfLjt/VSurqD/uetKNII+5i90HBYDgrQmU/x/GT2lKptO0NbzCjUk4QDMFZjNRrlL 3vgIaCm0RthoHFhpz+fXEmxiDlwey5msEaE9RblY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org Subject: [PATCH 4.14 79/89] Revert "printk: Never set console_may_schedule in console_trylock()" Date: Fri, 14 Dec 2018 13:00:32 +0100 Message-Id: <20181214115733.594242985@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ This reverts commit c9b8d580b3fb0ab65d37c372aef19a318fda3199. This is just a technical revert to make the printk fix apply cleanly, this patch will be re-picked in about 3 commits. --- kernel/printk/printk.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index a9cf2e15f6a3..7161312593dd 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1762,12 +1762,6 @@ 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 @@ -1775,7 +1769,6 @@ asmlinkage int vprintk_emit(int facility, int level, */ if (console_trylock()) console_unlock(); - preempt_enable(); } return printed_len; @@ -2090,7 +2083,20 @@ int console_trylock(void) return 0; } console_locked = 1; - console_may_schedule = 0; + /* + * 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(); return 1; } EXPORT_SYMBOL(console_trylock); -- 2.19.1