Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4877785pxj; Wed, 12 May 2021 15:28:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/OoacCwp/zC0UZaQuqNABWq8LIfvlbDHJnSp8WfBuIYqkA9LTDcAuMtN3bmWoGbuzuOw3 X-Received: by 2002:a17:906:2bd0:: with SMTP id n16mr40157623ejg.110.1620858489515; Wed, 12 May 2021 15:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620858489; cv=none; d=google.com; s=arc-20160816; b=jgAOukLGK8wu9vpRPgDeSNHH3p3f5geIJC7aM5WJbbYJmzoWSwn0EqzFPXkUcQNxpa o/A1HJp+iucp17gCUcYE6qdpHhmSZ68AJU1f3lOfaNLBxCpw/2hgncTxXErLq4nVQ1jp HjH3FAI5zLmA8Vy2Zp48nrFh9rLcGdRQV0vM5tFsVpju6gt0nY3HfQVK3xQyNBFO8dZo oD2nYZ8yx85fUQFR27vZXKuq9TJZKlAUKWGnOy11tpNrwM1BlZ8C9zYgk4/27p3kdgJM qT3bT62/XZ+aRy0CXShFBa02Y49IftpJqe+U2OWM49w11irooGXaxf8u75ljojbRc3ZM 81wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=HSbdv1GDdPztZw5zTb9KslOGTnh1tRDArL4XhKvz/ec=; b=z9Em7ai18muAsnSPQUc5InAQTo/v6Ml7RIDneYng3/FAAQ+EcSDxqfqIbPV5I5JZOH 0/IvX413vKBzYW1UaFQLYoDqZCOWkDepTTTNg7gBORvpr4jQmPAPPMfAjeT2O+L3tEY8 R2DcfgcEzZ1qDhDi43GUa/LDLdOi2QzGuAyMNQdjAivR9llVX87GJv6nSDFReC6eXyVr 27Fkdy2JyTQyleMjPOraIINgy0y01mLxXXOFL9o4wQeS0ieGw9iMBoAXFwtD6tiQ+cvJ OO44KqVfMzwCEGzm2asWZapn3Lt3oHyT6mHLF2Rn4skRjznmM5JuoBykAfrwO0yqgxnr F2iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PtKwVVKf; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs11si1452192ejc.319.2021.05.12.15.27.46; Wed, 12 May 2021 15:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PtKwVVKf; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443208AbhELWRC (ORCPT + 99 others); Wed, 12 May 2021 18:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387867AbhELVtN (ORCPT ); Wed, 12 May 2021 17:49:13 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33DE1C061246; Wed, 12 May 2021 14:43:28 -0700 (PDT) Date: Wed, 12 May 2021 23:43:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1620855806; 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: in-reply-to:in-reply-to:references:references; bh=HSbdv1GDdPztZw5zTb9KslOGTnh1tRDArL4XhKvz/ec=; b=PtKwVVKfzJNbyEOwpyCTxHTECuCU4MVf8kxZQYDpX592nPOY9pV/ABQi6nwSn2y9M4dyDd HOTjVjWjjr5SbCP6udeCfm/y45nmeoDKiSbD/fMFh9JQJjH8JXI4agH8pK2vkhVEmLoa1Y KXmI1AwmCcPk0wgfm0iEnXRCkeSzciQYmEd4jdhzSHoELRAbUwMVPq83dbruzvYhwCHbg6 o+cKcLdccweyn2gh5VIoKxz5xlRa5zhg71we4ssfFWMdv1Ed4ROwWSPuHQYwrqIvHRS3zC VhtqH2QtlcFATgZAIXzuslczgnHYWj2CrueR9JHdz2GlNY+XcjRKj5+ii/3j+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1620855806; 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: in-reply-to:in-reply-to:references:references; bh=HSbdv1GDdPztZw5zTb9KslOGTnh1tRDArL4XhKvz/ec=; b=A4Gb/KNED+5M7zpJuUewsiFOs0wkU5hVfNlRS0Ocv7tLHf1xjZZkpwQviqVyQWpRQ8isNM hPIGcW+d+o1cetAQ== From: Sebastian Andrzej Siewior To: netdev@vger.kernel.org Cc: Juri Lelli , Thomas Gleixner , linux-rt-users , Steven Rostedt , LKML , sassmann@redhat.com, "David S. Miller" , Jakub Kicinski Subject: [PATCH net-next] net: Treat __napi_schedule_irqoff() as __napi_schedule() on PREEMPT_RT Message-ID: <20210512214324.hiaiw3e2tzmsygcz@linutronix.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __napi_schedule_irqoff() is an optimized version of __napi_schedule() which can be used where it is known that interrupts are disabled, e.g. in interrupt-handlers, spin_lock_irq() sections or hrtimer callbacks. On PREEMPT_RT enabled kernels this assumptions is not true. Force- threaded interrupt handlers and spinlocks are not disabling interrupts and the NAPI hrtimer callback is forced into softirq context which runs with interrupts enabled as well. Chasing all usage sites of __napi_schedule_irqoff() is a whack-a-mole game so make __napi_schedule_irqoff() invoke __napi_schedule() for PREEMPT_RT kernels. The callers of ____napi_schedule() in the networking core have been audited and are correct on PREEMPT_RT kernels as well. Reported-by: Juri Lelli Signed-off-by: Sebastian Andrzej Siewior --- Alternatively __napi_schedule_irqoff() could be #ifdef'ed out on RT and an inline provided which invokes __napi_schedule(). This was not chosen as it creates #ifdeffery all over the place and with the proposed solution the code reflects the documentation consistently and in one obvious place. net/core/dev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 222b1d322c969..febb23708184e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6501,11 +6501,18 @@ EXPORT_SYMBOL(napi_schedule_prep); * __napi_schedule_irqoff - schedule for receive * @n: entry to schedule * - * Variant of __napi_schedule() assuming hard irqs are masked + * Variant of __napi_schedule() assuming hard irqs are masked. + * + * On PREEMPT_RT enabled kernels this maps to __napi_schedule() + * because the interrupt disabled assumption might not be true + * due to force-threaded interrupts and spinlock substitution. */ void __napi_schedule_irqoff(struct napi_struct *n) { - ____napi_schedule(this_cpu_ptr(&softnet_data), n); + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + ____napi_schedule(this_cpu_ptr(&softnet_data), n); + else + __napi_schedule(n); } EXPORT_SYMBOL(__napi_schedule_irqoff); -- 2.31.1