From patchwork Fri Nov 13 14:02:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11903677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59266C61DD8 for ; Fri, 13 Nov 2020 14:28:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E370222226 for ; Fri, 13 Nov 2020 14:28:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HjDFLdqL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="URSw8F8q"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Fz21tLWb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E370222226 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:Subject:To:From:Date: Message-Id:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Owner; bh=EHS5eFmEkILt13dYwPcAf+Ve0ixqHlc6yeIHAxjQRW8=; b=HjDFLdqLwYTjThlMvHAawOyTl Bixu/JTD2xdxwn3XdtmgTi54F0PPcz2HmX2zfzyVnngXQHRm8gIZRuaKrSbBjyxsQ1V93CAwSz/51 8ygY3vQPtPA3QKZNq/jn401pqbKoG5njV/Q9FURzzTl08+RyavdZj/uYMp18fwwjW0Z55t8lBYNN6 e+CX1P4cko/Pfq9MISur7Jmk8kWYnAxlIkMtaiWimP1vvTCAclg3tiK5mxO1m4blF8io9/zSsBjIQ 9H5qpUcGuoFbsHJA+aKsHR2G1M7z5R4yxjG/ulT6BpfYSIMp06hGPsbMBn68GUl13z9V0oaymOrzw 7L1W9TfGw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kda2G-0007GC-SF; Fri, 13 Nov 2020 14:26:44 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kda07-0006Lh-Ey; Fri, 13 Nov 2020 14:24:39 +0000 Message-Id: <20201113141734.207605126@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1605277470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=hOeV4Uk7rTRj8OzrhfpKRZ7P0pi7lfMrsyiB2KyVEto=; b=URSw8F8qCzxPeiiiqFqLJq9vgbvQvNB5bDnNWfPE+JIpuybZnnqa6IY2ofJgdJEzeECG1k nhxbzeTOcEEvoxg1p1gpTnBtwmuhcli6AM1SNnRvxqaWxfgHNpCparobE9ZTa6h2KAAa+v MBrwhlBSGWEvD5ZpHidwQC8lXS2eus6R0/70ep00jQRw4a9jRrgh1//4WmUXUh58ZUnCFL xPUZYjZdaJI+U0Hp3OvS3r/2BITHOzsrQgk94F3mhIhmRjdcJz/nKaMQBzJN4VqrZeDiF+ dQnYFmwrcpE8ZJZTEriBYAiF9Sk4DG/6XxukcDyuOXKxIX9aB5EE6QSD48kitQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1605277470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=hOeV4Uk7rTRj8OzrhfpKRZ7P0pi7lfMrsyiB2KyVEto=; b=Fz21tLWb3UVdRRr7AeS4qYH3y/k/kNtsttrdQl7tgpxPBCYlIGzhDVQ+drwgixYSrTaLVV n5yXU+FH5qMvt3Dw== Date: Fri, 13 Nov 2020 15:02:20 +0100 From: Thomas Gleixner To: LKML Subject: [patch 13/19] softirq: Move various protections into inline helpers References: <20201113140207.499353218@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_092431_679588_4C6D10B2 X-CRM114-Status: GOOD ( 12.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Rich Felker , Catalin Marinas , Paul McKenney , Arnd Bergmann , linux-sh@vger.kernel.org, Peter Zijlstra , Richard Weinberger , Frederic Weisbecker , Valentin Schneider , Jeff Dike , Russell King , Yoshinori Sato , "James E.J. Bottomley" , linux-parisc@vger.kernel.org, Helge Deller , linux-um@lists.infradead.org, Will Deacon , Sebastian Andrzej Siewior , linux-arm-kernel@lists.infradead.org, Anton Ivanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To allow reuse of the bulk of softirq processing code for RT and to avoid #ifdeffery all over the place, split protections for various code sections out into inline helpers so the RT variant can just replace them in one go. Signed-off-by: Thomas Gleixner --- kernel/softirq.c | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 9 deletions(-) --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -204,6 +204,42 @@ void __local_bh_enable_ip(unsigned long } EXPORT_SYMBOL(__local_bh_enable_ip); +static inline void local_bh_disable_irq_enter(void) +{ + local_bh_disable(); +} + +static inline void local_bh_enable_irq_enter(void) +{ + _local_bh_enable(); +} + +static inline void softirq_handle_begin(void) +{ + __local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET); +} + +static inline void softirq_handle_end(void) +{ + __local_bh_enable(SOFTIRQ_OFFSET); + WARN_ON_ONCE(in_interrupt()); +} + +static inline void ksoftirqd_run_begin(void) +{ + local_irq_disable(); +} + +static inline void ksoftirqd_run_end(void) +{ + local_irq_enable(); +} + +static inline bool should_wake_ksoftirqd(void) +{ + return true; +} + static inline void invoke_softirq(void) { if (ksoftirqd_running(local_softirq_pending())) @@ -317,7 +353,7 @@ asmlinkage __visible void __softirq_entr pending = local_softirq_pending(); account_irq_enter_time(current); - __local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET); + softirq_handle_begin(); in_hardirq = lockdep_softirq_start(); restart: @@ -367,8 +403,7 @@ asmlinkage __visible void __softirq_entr lockdep_softirq_end(in_hardirq); account_irq_exit_time(current); - __local_bh_enable(SOFTIRQ_OFFSET); - WARN_ON_ONCE(in_interrupt()); + softirq_handle_end(); current_restore_flags(old_flags, PF_MEMALLOC); } @@ -382,9 +417,9 @@ void irq_enter_rcu(void) * Prevent raise_softirq from needlessly waking up ksoftirqd * here, as softirq will be serviced on return from interrupt. */ - local_bh_disable(); + local_bh_disable_irq_enter(); tick_irq_enter(); - _local_bh_enable(); + local_bh_enable_irq_enter(); } __irq_enter(); } @@ -467,7 +502,7 @@ inline void raise_softirq_irqoff(unsigne * Otherwise we wake up ksoftirqd to make sure we * schedule the softirq soon. */ - if (!in_interrupt()) + if (!in_interrupt() && should_wake_ksoftirqd()) wakeup_softirqd(); } @@ -645,18 +680,18 @@ static int ksoftirqd_should_run(unsigned static void run_ksoftirqd(unsigned int cpu) { - local_irq_disable(); + ksoftirqd_run_begin(); if (local_softirq_pending()) { /* * We can safely run softirq on inline stack, as we are not deep * in the task stack here. */ __do_softirq(); - local_irq_enable(); + ksoftirqd_run_end(); cond_resched(); return; } - local_irq_enable(); + ksoftirqd_run_end(); } #ifdef CONFIG_HOTPLUG_CPU