From patchwork Fri Oct 23 16:36:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucian Adrian Grijincu X-Patchwork-Id: 36793 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.176.167]) by ozlabs.org (Postfix) with ESMTP id F1C7AB7BDD for ; Sat, 24 Oct 2009 03:36:52 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752708AbZJWQgT (ORCPT ); Fri, 23 Oct 2009 12:36:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752705AbZJWQgR (ORCPT ); Fri, 23 Oct 2009 12:36:17 -0400 Received: from ixro-out-rtc.ixiacom.com ([92.87.192.98]:5727 "EHLO ixro-ex1.ixiacom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752672AbZJWQgQ (ORCPT ); Fri, 23 Oct 2009 12:36:16 -0400 Received: from ixro-lgrijincu.localnet ([10.205.9.89]) by ixro-ex1.ixiacom.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 23 Oct 2009 19:36:18 +0300 From: Lucian Adrian Grijincu Organization: IXIACOM To: Eric Dumazet Subject: udp: break from the lookup when hitting the maximum score value Date: Fri, 23 Oct 2009 19:36:15 +0300 User-Agent: KMail/1.12.2 (Linux/2.6.31-14-generic; KDE/4.3.2; i686; ; ) Cc: opurdila@ixiacom.com, netdev@vger.kernel.org MIME-Version: 1.0 Message-Id: <200910231936.16022.lgrijincu@ixiacom.com> X-OriginalArrivalTime: 23 Oct 2009 16:36:18.0751 (UTC) FILETIME=[F26D04F0:01CA53FE] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Before udp hashes were converted to rcu in udp: introduce struct udp_table and multiple spinlocks 645ca708f936b2fbeb79e52d7823e3eb2c0905f8 we stopped searching in list upon hitting the maximum score value (which is 9). This got removed in the conversion to rcu. I'm not sure whether this was intentional or it just slipped by. As far as I understand it this does not interfere with the lockless rcu: there is another score check the result will have to pass and if it doesn't have a score of 9 (which will be the value of badness) we'll just restart the lookup. Even if the node was deleted from the chain and reclaimed at a later time, if at the second score test we have value 9 again, we can still return with this result. Am I missing something? diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index d0d436d..69464b9 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -294,6 +294,11 @@ begin: sk_nulls_for_each_rcu(sk, node, &hslot->head) { score = compute_score(sk, net, saddr, hnum, sport, daddr, dport, dif); + if (score == 9) { + result = sk; + badness = score; + goto skip_end_of_nulls_check; + } if (score > badness) { result = sk; badness = score; @@ -307,6 +312,7 @@ begin: if (get_nulls_value(node) != hash) goto begin; +skip_end_of_nulls_check: if (result) { if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) result = NULL;