From patchwork Tue Aug 15 19:11:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 801723 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LfkY/zkx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xX2Bf3Zxsz9sRq for ; Wed, 16 Aug 2017 05:11:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752821AbdHOTLE (ORCPT ); Tue, 15 Aug 2017 15:11:04 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38470 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752247AbdHOTLD (ORCPT ); Tue, 15 Aug 2017 15:11:03 -0400 Received: by mail-pg0-f68.google.com with SMTP id 123so2726144pga.5 for ; Tue, 15 Aug 2017 12:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=nhJrCDImF23i25prx1eEYjl8BwLm7TBeg7M1saKAQ9s=; b=LfkY/zkxH3ggaqUPo4mpZ3ZOAC3uvCLnW+Vzvq4zz0O8mlLeLQnKSRu/BhzY2cpXqD 6L1PqsPy0JjcPpOOkM894WOSZFY7UwaKKng/Cjei19Sh7wbNqLNdWZYYUkErnWjVYNti wUhbyyuNIMycqb3dMeSfBldOpJZUBdjTwQYC/t0a/JJBHOOlNJ+HqA7UKldOxam1LXnB OEhwbZ8uQmcIyMg0dVeskeMs/rkO+r+JmrUgqbf1REqpgET2OVHCYx2jw29BTXf/bKBF zmsFnzGmBR8jdntyANdXVqpDh9FXjGNr4rNqL+2t5hgbTSDH5dD+H+qxrreQm0O5kUhS UMmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=nhJrCDImF23i25prx1eEYjl8BwLm7TBeg7M1saKAQ9s=; b=HSv5Eye/fJtvusmDgfCU9mHDEzFPVcn5Z5nUHZ9KaBskEmDWeGj7qWN/URLwIh1wPF nC+5nVsiJr/k/gne49W88COX/80FCCG47H73wlMojRjL7DK7bMIWyqBu9pvFBUd3igP8 ojSsNVwErmvl2N/1+KP5uNkenW0gN8jS9pW2IcmMHAzuZ7Yj6ohXporHTxrrm6YjFBnJ PPDVcjaJuCom7BBn6DrVn6w2Yt6LUaeO73TFnkcXfoRhromcUnwzlKq/xivqe4TT1xXM 7BhN7jQek1UBwIq1x0gi4cZBC+RTnCVLIOE0Wsp/EZ9R/L+SYfO9zfzDTZfhybAyVGHC Y0HQ== X-Gm-Message-State: AHYfb5hSoZirKIN+KZPy0clRLpfyVEa7b42hC/BiBpr/4GFHnpe+Cb7Z e2eRI9LMkYZZFz1O X-Received: by 10.98.204.22 with SMTP id a22mr28727463pfg.59.1502824262886; Tue, 15 Aug 2017 12:11:02 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:100:4021:b308:1b7d:9638? ([2620:15c:2c1:100:4021:b308:1b7d:9638]) by smtp.googlemail.com with ESMTPSA id w82sm21110986pfa.39.2017.08.15.12.11.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Aug 2017 12:11:01 -0700 (PDT) Message-ID: <1502824260.4936.86.camel@edumazet-glaptop3.roam.corp.google.com> Subject: Re: 100% CPU load when generating traffic to destination network that nexthop is not reachable From: Eric Dumazet To: =?UTF-8?Q?Pawe=C5=82?= Staszewski Cc: Linux Kernel Network Developers Date: Tue, 15 Aug 2017 12:11:00 -0700 In-Reply-To: References: <177465a0-aaba-4063-e451-ebbf46728b77@itcare.pl> <1502816253.4936.85.camel@edumazet-glaptop3.roam.corp.google.com> X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, 2017-08-15 at 19:42 +0200, Paweł Staszewski wrote: > # To display the perf.data header info, please use > --header/--header-only options. > # > # > # Total Lost Samples: 0 > # > # Samples: 2M of event 'cycles' > # Event count (approx.): 1585571545969 > # > # Children Self Command Shared Object Symbol > # ........ ........ .............. .................... > .............................................. > # > 1.82% 0.00% ksoftirqd/43 [kernel.vmlinux] [k] > __softirqentry_text_start > | > --1.82%--__softirqentry_text_start > | > --1.82%--net_rx_action > | > --1.82%--mlx5e_napi_poll > | > --1.81%--mlx5e_poll_rx_cq > | > --1.81%--mlx5e_handle_rx_cqe > | > --1.79%--napi_gro_receive > | > --1.78%--netif_receive_skb_internal > | > --1.78%--__netif_receive_skb > | > --1.78%--__netif_receive_skb_core > | > --1.78%--ip_rcv > | > --1.78%--ip_rcv_finish > | > --1.76%--ip_forward > | > --1.76%--ip_forward_finish > | > --1.76%--ip_output > | > --1.76%--ip_finish_output > | > --1.76%--ip_finish_output2 > | > --1.73%--neigh_resolve_output > | > --1.73%--neigh_event_send > | > --1.73%--__neigh_event_send > | > --1.70%--_raw_write_lock_bh > queued_write_lock > queued_write_lock_slowpath > | > --1.67%--queued_spin_lock_slowpath > > Please try this : diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 16a1a4c4eb57fa1147f230916e2e62e18ef89562..95e0d7702029b583de8229e3c3eb923f6395b072 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -991,14 +991,18 @@ static void neigh_timer_handler(unsigned long arg) int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) { - int rc; bool immediate_probe = false; + int rc; + + /* We _should_ test this under write_lock_bh(&neigh->lock), + * but this is too costly. + */ + if (READ_ONCE(neigh->nud_state) & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE)) + return 0; write_lock_bh(&neigh->lock); rc = 0; - if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE)) - goto out_unlock_bh; if (neigh->dead) goto out_dead;