Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp571233imm; Fri, 15 Jun 2018 02:41:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKhbWmVfrCHja4pgS/657h/buxjA5t+UK1/yHwSHMqzlx3aJHraRiz1gLthDR/Lgh6E6poP X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr1186996plb.42.1529055676972; Fri, 15 Jun 2018 02:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529055676; cv=none; d=google.com; s=arc-20160816; b=rsZE4x3UI6bObdyY2A10SuPW7gIUfGP8lsYYLkwuuDP/saZ3j6cLI01gNQP3qdwau+ Dcf1FHv9xKjJ/RZFXsETLqZ4NMjh6YR4hA3IVrO7QyUeM6cCJtWaDGvMB5p2WGxezgZc iA4fPa+njBV0/zM75+68vUSfh9qLj1E5OHs+cen1uzQUpr1Q7wP/whcV7au3Qv98k0xj GVtgF60v8d5VpR6mjW/hvPw3B/qUZ/28mEKsobR6nddn4I9yY7aQ/kdOyJdKT8PCv2oL odTN7iem9liHD7o1BjGFyqDtOuKMMQipC8ggpGLYl7yKu+cK1DItWezJ1v7g/t3Y2z5r r9dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7stQGUpLXvpT66R3542N2aU/vqQaiwK+zjcMnliT7o0=; b=P9S/bknmcmr5eSzbsh4NkmUYlNpItsxILTtjNLhrIZpZTJXcxAEmdeSz97dIxmYRJk BRTgkmiP31E4d+3yEwupF5kQyfYG1FK3ONGyz7jaf5ygMfS7Bbno38FwIev8Q+h+6l9/ 4VOOXKUN699PFnX0WdTEUdpcCTG0j/BZztRRr1t60oRGJ7C4+bbzL1lrlh2he3WEZM+8 29WcA+IEj3sHDDiuO/wzjzzIqMEJYap/ne6f8k0VpraYc50J9re/EFM6c8gLp41y1Tgt 4cYWAIwsPj3eGfUWP5PUtHSspmxe6U2blWus++9E/Mt2tdAY5sAQrhk1xAl+oXLIcn1v t0eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kfWv7W6l; 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 l21-v6si7708581pfk.321.2018.06.15.02.41.02; Fri, 15 Jun 2018 02:41:16 -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=kfWv7W6l; 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 S1755991AbeFOJka (ORCPT + 99 others); Fri, 15 Jun 2018 05:40:30 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40791 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755727AbeFOJk0 (ORCPT ); Fri, 15 Jun 2018 05:40:26 -0400 Received: by mail-pf0-f195.google.com with SMTP id z24-v6so4615231pfe.7; Fri, 15 Jun 2018 02:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7stQGUpLXvpT66R3542N2aU/vqQaiwK+zjcMnliT7o0=; b=kfWv7W6lnRGgb2xYBxrk5lvN8GbvuntIP0AgpmJRXWw5OXdr5ILxxQQhUI3e7au9Gt ouJRknSB1V/zovCgx0cbZYuTx+hoZbDEZm92XSn+QGrxqHgmAL/m82Jdqinn7vKzPG0D rELRR7fN+qvK+1bLwwSmcHXVzc749qpisDS/oxjIhbvZA7QmHLMXuirlZvjZkW0738Xu jJeYj3Ef+Oh6R5Ox7uNnEGmPwCEBGXCVDRGS7usolShBbAnfwZih9+Gct0gTgC9BUw9B GSVNvY4sfKSD+nt2k7K93M1RAMJHGOXiOMP9j0LZgpvs0eXPzYCafChbRRLx7TabTvhl pxHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7stQGUpLXvpT66R3542N2aU/vqQaiwK+zjcMnliT7o0=; b=jhbSBodqpNHxIwdP6X62gG/rKcGWMgsTboDyiN9BffjBGpAt37+UIDG4pVomOXufbu Hb+/4JweHm0XcwjCVn1zhI5G3z/qdz7Bimx8OobdOfYeqzT1Pvr6ZoayLaxYA0W94mf1 3qEjp2/cz9rIW275IdZul9s93WNZIn83VoAA4JYCefHjFo4tx8oIhPs3rp97DwUQSLMX QSWupEYIHc7l9M3ZgSn8cu4NvQ/Ne4u5JoSo0eX/ug/gDyMTUfvhZH24u8UBO3pf7EJh sk0ij4zFbGHEK+IFjZG6dg+YaHK9S8ZeRcEYjqBdtxheI1IOBHRJgt7l+jsSNCofXrJj B4hQ== X-Gm-Message-State: APt69E02MyfGyID8keRcMVtupReFQrS+N6I14D9FioQpyAL6sF570/7J 2+cFjrpVnHUepwShIEarUoA= X-Received: by 2002:a62:4c04:: with SMTP id z4-v6mr1050644pfa.205.1529055625177; Fri, 15 Jun 2018 02:40:25 -0700 (PDT) Received: from localhost.localdomain ([175.223.48.179]) by smtp.gmail.com with ESMTPSA id p1-v6sm11628551pfh.58.2018.06.15.02.40.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 02:40:23 -0700 (PDT) From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky To: Petr Mladek , Steven Rostedt , Greg Kroah-Hartman , Jiri Slaby Cc: Linus Torvalds , Peter Zijlstra , Andrew Morton , Dmitry Vyukov , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: [RFC][PATCH 1/6] printk: move printk_safe macros to printk header Date: Fri, 15 Jun 2018 18:39:14 +0900 Message-Id: <20180615093919.559-2-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615093919.559-1-sergey.senozhatsky@gmail.com> References: <20180615093919.559-1-sergey.senozhatsky@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make printk_safe_enter_irqsave()/etc macros available to the rest of the kernel, so we can use them in TTY and UART code. Signed-off-by: Sergey Senozhatsky --- include/linux/printk.h | 40 ++++++++++++++++++++++++++++++++++++++++ kernel/printk/internal.h | 37 ------------------------------------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 6d7e800affd8..8b4e1e667919 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -153,6 +153,46 @@ static inline void printk_nmi_enter(void) { } static inline void printk_nmi_exit(void) { } #endif /* PRINTK_NMI */ +#ifdef CONFIG_PRINTK +extern void __printk_safe_enter(void); +extern void __printk_safe_exit(void); + +#define printk_safe_enter_irqsave(flags) \ + do { \ + local_irq_save(flags); \ + __printk_safe_enter(); \ + } while (0) + +#define printk_safe_exit_irqrestore(flags) \ + do { \ + __printk_safe_exit(); \ + local_irq_restore(flags); \ + } while (0) + +#define printk_safe_enter_irq() \ + do { \ + local_irq_disable(); \ + __printk_safe_enter(); \ + } while (0) + +#define printk_safe_exit_irq() \ + do { \ + __printk_safe_exit(); \ + local_irq_enable(); \ + } while (0) +#else +/* + * On !PRINTK builds we still export console output related locks + * and some functions (console_unlock()/tty/etc.), so printk-safe + * must preserve the existing local IRQ guarantees. + */ +#define printk_safe_enter_irqsave(flags) local_irq_save(flags) +#define printk_safe_exit_irqrestore(flags) local_irq_restore(flags) + +#define printk_safe_enter_irq() local_irq_disable() +#define printk_safe_exit_irq() local_irq_enable() +#endif + #ifdef CONFIG_PRINTK asmlinkage __printf(5, 0) int vprintk_emit(int facility, int level, diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 2a7d04049af4..cf4f85e53cc2 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -27,46 +27,9 @@ extern raw_spinlock_t logbuf_lock; __printf(1, 0) int vprintk_default(const char *fmt, va_list args); __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args); __printf(1, 0) int vprintk_func(const char *fmt, va_list args); -void __printk_safe_enter(void); -void __printk_safe_exit(void); - -#define printk_safe_enter_irqsave(flags) \ - do { \ - local_irq_save(flags); \ - __printk_safe_enter(); \ - } while (0) - -#define printk_safe_exit_irqrestore(flags) \ - do { \ - __printk_safe_exit(); \ - local_irq_restore(flags); \ - } while (0) - -#define printk_safe_enter_irq() \ - do { \ - local_irq_disable(); \ - __printk_safe_enter(); \ - } while (0) - -#define printk_safe_exit_irq() \ - do { \ - __printk_safe_exit(); \ - local_irq_enable(); \ - } while (0) #else __printf(1, 0) int vprintk_func(const char *fmt, va_list args) { return 0; } -/* - * In !PRINTK builds we still export logbuf_lock spin_lock, console_sem - * semaphore and some of console functions (console_unlock()/etc.), so - * printk-safe must preserve the existing local IRQ guarantees. - */ -#define printk_safe_enter_irqsave(flags) local_irq_save(flags) -#define printk_safe_exit_irqrestore(flags) local_irq_restore(flags) - -#define printk_safe_enter_irq() local_irq_disable() -#define printk_safe_exit_irq() local_irq_enable() - #endif /* CONFIG_PRINTK */ -- 2.17.1