From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable 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 76E17C433B4 for ; Thu, 13 May 2021 05:12:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B1346142C for ; Thu, 13 May 2021 05:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbhEMFNr (ORCPT ); Thu, 13 May 2021 01:13:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46422 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbhEMFNm (ORCPT ); Thu, 13 May 2021 01:13:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620882753; 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=TcOAwivDbtlARJpFLH0Y1M7raCC9tMpEn3jc2In1UFc=; b=G6OnDE8dk/ncnHW5Uju3p//FLcz0QlF60iqC8Io+VMo6R/teLZOaDgDFAodRT8GUDlUOq4 eTjDLhy3KFx/IcDv3a7yhzM6kvxvAjAwdknWpoYE09IC2lDrqTL3aKZBLHhPQo+HgfBrpk hBbaY8VPJSmmFPmlS7vGzzTM0fcbq4I= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-5Vy5Dw7JOsighCEIfwMbiw-1; Thu, 13 May 2021 01:12:20 -0400 X-MC-Unique: 5Vy5Dw7JOsighCEIfwMbiw-1 Received: by mail-wm1-f70.google.com with SMTP id g206-20020a1c39d70000b029016ac627fbe9so1183005wma.9 for ; Wed, 12 May 2021 22:12:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TcOAwivDbtlARJpFLH0Y1M7raCC9tMpEn3jc2In1UFc=; b=LDknAszNzeMNHPh7UHnAB7D4hU38g+CDkOvZEJtAxyP0vzgdPLpCwkpoV9o30DMKW2 ftYtmfgy1Q0A0zGMpfNtkKVNtj/WTeHU0fnJHB6mnN35Lz2X6A/FmvSRooQxCRMVNM2y swgNlCCZmNHUgTxlaunN3OefyuQtMgsQU1Q22JkNgml8zRkMAUqT83lXTmLXw75g4A5v M20VxKuCDXRIcLd/d2nCrOXvI9s4pNvdpr4fQhl8kOVcRSLMzHJBLvzex2byPh9LIopu gpEMip3sgLDt9g6o/scdmuaDcW1z4TkVtKreEINVNN9bWro8ZM7A3pl7t/5iQ6H99yRV q9EQ== X-Gm-Message-State: AOAM530x/5z2m2ZtVFE2aBFd84K2NEz+l7hVQtvseFRjlhdsaAD/nkjd X+1d6bdY3rga+2598/MWDGErEkOZ3BofMgbPXE7JhcWFJicE5AcBBv6+5jzILCDgnUZf7IjXezj 1nCBCqThZ8itWJ3esvZACnpIt X-Received: by 2002:a05:600c:19cd:: with SMTP id u13mr301610wmq.171.1620882738821; Wed, 12 May 2021 22:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz65HKJoTtlBrckxiBt2p5AvxqrwBotMCpCfUgNmO1jclonTBYcuH40MjWiQGDIMS8yJH2Sgw== X-Received: by 2002:a05:600c:19cd:: with SMTP id u13mr301592wmq.171.1620882738557; Wed, 12 May 2021 22:12:18 -0700 (PDT) Received: from localhost.localdomain ([151.29.91.215]) by smtp.gmail.com with ESMTPSA id c15sm1734122wro.21.2021.05.12.22.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 22:12:18 -0700 (PDT) Date: Thu, 13 May 2021 07:12:16 +0200 From: Juri Lelli To: Sebastian Andrzej Siewior Cc: netdev@vger.kernel.org, Thomas Gleixner , linux-rt-users , Steven Rostedt , LKML , sassmann@redhat.com, "David S. Miller" , Jakub Kicinski Subject: Re: [PATCH net-next] net: Treat __napi_schedule_irqoff() as __napi_schedule() on PREEMPT_RT Message-ID: References: <20210512214324.hiaiw3e2tzmsygcz@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210512214324.hiaiw3e2tzmsygcz@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/05/21 23:43, Sebastian Andrzej Siewior wrote: > __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); Thanks for the patch! Reviewed-by: Juri Lelli Best, Juri