From patchwork Fri Apr 23 10:26:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 50805 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 2A0B7B7D1E for ; Fri, 23 Apr 2010 20:26:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754737Ab0DWK0U (ORCPT ); Fri, 23 Apr 2010 06:26:20 -0400 Received: from mail-bw0-f219.google.com ([209.85.218.219]:59830 "EHLO mail-bw0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163Ab0DWK0T (ORCPT ); Fri, 23 Apr 2010 06:26:19 -0400 Received: by bwz19 with SMTP id 19so13078bwz.1 for ; Fri, 23 Apr 2010 03:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=ExzkeD0bZT713d7KUuLrELtx+b1PcUeIeFRE8MVdSaI=; b=e0B8LS6vrhgLJXSJ6vBGy1pPnqFbGlUhuQ/HsnxbWve48BGY2QpOsKtdCuBim1vXDc 0faNjc2w2qpzF1wX9Hbl5fRfpG8AjpW8egdXdi/t2f0J+ShquVZ7k8LCmY5H+20PVm6M QY0CB1I/mrZO+Lg5r2XDrmQcxNAALOmNZDcK4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=K4oHpYxFLZawLHGVaZoO3keIijY9uwp5kY5B2xpTTMVspVsIdt9gECP75h58A4UNw4 u9zRhfPdgqPx5NF5a0fG+LGQU7h6WmN7g9zSU9LpQOpO24m1YpcBLc3B6O533IvUtuNi xR2xNLFGpOvrcHOuBLxrCLJDdkyHKtbnwUG2I= Received: by 10.204.139.68 with SMTP id d4mr4580169bku.66.1272018377745; Fri, 23 Apr 2010 03:26:17 -0700 (PDT) Received: from [127.0.0.1] (gw1.cosmosbay.com [212.99.114.194]) by mx.google.com with ESMTPS id 14sm486103bwz.10.2010.04.23.03.26.15 (version=SSLv3 cipher=RC4-MD5); Fri, 23 Apr 2010 03:26:16 -0700 (PDT) Subject: Re: [PATCH v6] net: batch skb dequeueing from softnet input_pkt_queue From: Eric Dumazet To: Changli Gao Cc: "David S. Miller" , jamal , Tom Herbert , Stephen Hemminger , netdev@vger.kernel.org In-Reply-To: <1272010378-2955-1-git-send-email-xiaosuo@gmail.com> References: <1272010378-2955-1-git-send-email-xiaosuo@gmail.com> Date: Fri, 23 Apr 2010 12:26:06 +0200 Message-ID: <1272018366.7895.7930.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Le vendredi 23 avril 2010 à 16:12 +0800, Changli Gao a écrit : > batch skb dequeueing from softnet input_pkt_queue. > > batch skb dequeueing from softnet input_pkt_queue to reduce potential lock > contention when RPS is enabled. > > Note: in the worst case, the number of packets in a softnet_data may be double > of netdev_max_backlog. > > Signed-off-by: Changli Gao > ---- Oops, reading it again, I found process_backlog() was still taking the lock twice, if only one packet is waiting in input_pkt_queue. Possible fix, on top of your patch : --- 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 0eddd23..0569be7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3296,8 +3296,9 @@ static int process_backlog(struct napi_struct *napi, int quota) #endif napi->weight = weight_p; local_irq_disable(); - while (1) { + while (work < quota) { struct sk_buff *skb; + unsigned int qlen; while ((skb = __skb_dequeue(&sd->process_queue))) { local_irq_enable(); @@ -3308,13 +3309,15 @@ static int process_backlog(struct napi_struct *napi, int quota) } rps_lock(sd); - input_queue_head_add(sd, skb_queue_len(&sd->input_pkt_queue)); - skb_queue_splice_tail_init(&sd->input_pkt_queue, - &sd->process_queue); - if (skb_queue_empty(&sd->process_queue)) { + qlen = skb_queue_len(&sd->input_pkt_queue); + if (qlen) { + input_queue_head_add(sd, qlen); + skb_queue_splice_tail_init(&sd->input_pkt_queue, + &sd->process_queue); + } + if (qlen < quota - work) { __napi_complete(napi); - rps_unlock(sd); - break; + quota = work + qlen; } rps_unlock(sd); }