From patchwork Tue May 24 09:07:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 97136 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9D3C9B6F93 for ; Tue, 24 May 2011 19:07:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755106Ab1EXJHh (ORCPT ); Tue, 24 May 2011 05:07:37 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:39454 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753287Ab1EXJHg (ORCPT ); Tue, 24 May 2011 05:07:36 -0400 Received: by wwa36 with SMTP id 36so7086131wwa.1 for ; Tue, 24 May 2011 02:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:cc:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding; bh=AHTrOk8XVrca2P1fHFHMH5bwNYDDjRWQ+sN+wDNSX+0=; b=xsRNMXwUyfz7CNLPwlrvHkwQypQQEY2ezE5UugJbqjxTAQplYSM4KQL1qQSBC9hxZ6 auiK83CNwZ6vNXVwXOpNEsipqgahzmZYaxu4ze8rm48K5Hn1WYz13++Q6/xEeutfiZoi YRsrj5t5XnN8mdhRWt3X56opKVW7jbx6waOwE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=b6c8ecHGZUw4gTDavCgZGg2XJwHv62ecDZlMs2K3qGfAvurbcNlduZ0gdS7u4smSvj Q1tA5L3MmZQVScNZXDeMy2E/J8iVf3/d1V9NLx0FKsQSgsYGFhOvUeTmxXZuACv0NRA4 17qAmJ+xNvEw9/iURlqxElM9cOJxDmXYLXvjo= Received: by 10.216.221.103 with SMTP id q81mr3025432wep.83.1306228054824; Tue, 24 May 2011 02:07:34 -0700 (PDT) Received: from [10.150.51.215] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id y35sm3700929weq.15.2011.05.24.02.07.33 (version=SSLv3 cipher=OTHER); Tue, 24 May 2011 02:07:34 -0700 (PDT) Subject: [PATCH] net: use synchronize_rcu_expedited() From: Eric Dumazet To: David Miller Cc: netdev , "Paul E. McKenney" Date: Tue, 24 May 2011 11:07:32 +0200 Message-ID: <1306228052.3026.16.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org synchronize_rcu() is very slow in various situations (HZ=100, CONFIG_NO_HZ=y, CONFIG_PREEMPT=n) Extract from my (mostly idle) 8 core machine : synchronize_rcu() in 99985 us synchronize_rcu() in 79982 us synchronize_rcu() in 87612 us synchronize_rcu() in 79827 us synchronize_rcu() in 109860 us synchronize_rcu() in 98039 us synchronize_rcu() in 89841 us synchronize_rcu() in 79842 us synchronize_rcu() in 80151 us synchronize_rcu() in 119833 us synchronize_rcu() in 99858 us synchronize_rcu() in 73999 us synchronize_rcu() in 79855 us synchronize_rcu() in 79853 us When we hold RTNL mutex, we would like to spend some cpu cycles but not block too long other processes waiting for this mutex. We also want to setup/dismantle network features as fast as possible at boot/shutdown time. This patch makes synchronize_net() call the expedited version if RTNL is locked. synchronize_rcu_expedited() typical delay is about 20 us on my machine. synchronize_rcu_expedited() in 18 us synchronize_rcu_expedited() in 18 us synchronize_rcu_expedited() in 18 us synchronize_rcu_expedited() in 18 us synchronize_rcu_expedited() in 20 us synchronize_rcu_expedited() in 16 us synchronize_rcu_expedited() in 20 us synchronize_rcu_expedited() in 18 us synchronize_rcu_expedited() in 18 us Signed-off-by: Eric Dumazet CC: Paul E. McKenney CC: Ben Greear Reviewed-by: Paul E. McKenney --- net/core/dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/dev.c b/net/core/dev.c index bcb05cb..ec11d75 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5954,7 +5954,10 @@ EXPORT_SYMBOL(free_netdev); void synchronize_net(void) { might_sleep(); - synchronize_rcu(); + if (rtnl_is_locked()) + synchronize_rcu_expedited(); + else + synchronize_rcu(); } EXPORT_SYMBOL(synchronize_net);