Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751439AbcLEF6n (ORCPT ); Mon, 5 Dec 2016 00:58:43 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34604 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbcLEF6k (ORCPT ); Mon, 5 Dec 2016 00:58:40 -0500 Message-ID: <1480916739.18162.516.camel@edumazet-glaptop3.roam.corp.google.com> Subject: Re: [PATCH V2 net 10/20] net/ena: remove redundant logic in napi callback for busy poll mode From: Eric Dumazet To: Netanel Belgazal Cc: linux-kernel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, dwmw@amazon.com, zorik@annapurnalabs.com, alex@annapurnalabs.com, saeed@annapurnalabs.com, msw@amazon.com, aliguori@amazon.com, nafea@annapurnalabs.com Date: Sun, 04 Dec 2016 21:45:39 -0800 In-Reply-To: <1480857578-5065-11-git-send-email-netanel@annapurnalabs.com> References: <1480857578-5065-1-git-send-email-netanel@annapurnalabs.com> <1480857578-5065-11-git-send-email-netanel@annapurnalabs.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2056 Lines: 60 On Sun, 2016-12-04 at 15:19 +0200, Netanel Belgazal wrote: > sk_busy_loop can call the napi callback few million times a sec. > For each call there is unmask interrupt. > We want to reduce the number of unmasks. > > Add an atomic variable that will tell the napi handler if > it was called from irq context or not. > Unmask the interrupt only from irq context. > > A schenario where the driver left with missed unmask isn't feasible. > when ena_intr_msix_io is called the driver have 2 options: > 1)Before napi completes and call napi_complete_done > 2)After calling napi_complete_done > > In the former case the napi will unmask the interrupt as needed. > In the latter case napi_complete_done will remove napi from the schedule > list so napi will be rescheduled (by ena_intr_msix_io) and interrupt > will be unmasked as desire in the 2nd napi call. > > Signed-off-by: Netanel Belgazal > --- This looks very complicated to me. I guess you missed the recent patches that happened on net-next ? 2e713283751f494596655d9125c168aeb913f71d net/mlx4_en: use napi_complete_done() return value 364b6055738b4c752c30ccaaf25c624e69d76195 net: busy-poll: return busypolling status to drivers 21cb84c48ca0619181106f0f44f3802a989de024 net: busy-poll: remove need_resched() from sk_can_busy_loop() 217f6974368188fd8bd7804bf5a036aa5762c5e4 net: busy-poll: allow preemption in sk_busy_loop() napi_complete_done() return code can be used by a driver, no need to add yet another atomic operation in fast path. Anyway, this looks wrong : @@ -1186,6 +1201,7 @@ static irqreturn_t ena_intr_msix_io(int irq, void *data) { struct ena_napi *ena_napi = data; + atomic_set(&ena_napi->unmask_interrupt, 1); napi_schedule(&ena_napi->napi); You probably wanted : if (napi_schedule_prep(n)) { atomic_set(&ena_napi->unmask_interrupt, 1); __napi_schedule(n); } Please rework this napi poll using core infrastructure. busypoll logic should be centralized, not reimplemented in different ways in a driver. Thanks.