From patchwork Wed Mar 27 13:18:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 231685 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 B02DA2C00A6 for ; Thu, 28 Mar 2013 00:19:05 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753630Ab3C0NS3 (ORCPT ); Wed, 27 Mar 2013 09:18:29 -0400 Received: from mail-oa0-f49.google.com ([209.85.219.49]:57606 "EHLO mail-oa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753519Ab3C0NSZ (ORCPT ); Wed, 27 Mar 2013 09:18:25 -0400 Received: by mail-oa0-f49.google.com with SMTP id j6so8836392oag.36 for ; Wed, 27 Mar 2013 06:18:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=1+rb4EXHOhO0SDX1v/fZjlA9mAJWe187pKHn/AIZP+s=; b=e1Mvxo9Vq2o3HNs5JO23atc/atcC9/F+KTJOLqB9g4WvFAzcIt1FKFZlDigrozK+e9 pM502xf/066++hn6jKTbtKeOTpSnMIkz/FmtrHWLHsvL/yWoAlIid9LhUx+MlPxRJsik zqF83jJl4Lq0w7doRQ5GNcYKz/BqfnvEWTF0ERDohtUkaEg9hXjUTs+1xJpUmguTAi/n wa872WiAkln2vgH9/zflo4rMLsAiCsNZy/34yARmpqWWlIGFQpmm7Adx5keHzTi6Wp9h X2+IC3qOskO1xXeDLZqztIj/xNYdwnuCLGtcLTbzZE65L7EjMK4sc9s+E1f2gRTs7R+i HqMA== X-Received: by 10.182.118.1 with SMTP id ki1mr3865519obb.2.1364390305123; Wed, 27 Mar 2013 06:18:25 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id zc8sm14103721obc.8.2013.03.27.06.18.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 27 Mar 2013 06:18:24 -0700 (PDT) From: Jeff Layton To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, tj@kernel.org, Vlad Yasevich , Sridhar Samudrala , Neil Horman , "David S. Miller" , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 6/6] sctp: convert sctp_assoc_set_id to use idr_alloc_cyclic Date: Wed, 27 Mar 2013 09:18:08 -0400 Message-Id: <1364390288-30968-7-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1364390288-30968-1-git-send-email-jlayton@redhat.com> References: <1364390288-30968-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQkJHnlQjV/7EKisg9v2LR2RPxCSpzx3UrjIgoUKq1I0FG1NoyviBDRMnfiHmsvN2XOVctJL Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org (Note: compile-tested only) Signed-off-by: Jeff Layton Cc: Vlad Yasevich Cc: Sridhar Samudrala Cc: Neil Horman Cc: "David S. Miller" Cc: linux-sctp@vger.kernel.org Cc: netdev@vger.kernel.org --- net/sctp/associola.c | 15 +-------------- net/sctp/protocol.c | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/net/sctp/associola.c b/net/sctp/associola.c index d2709e2..8b21563 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -66,13 +66,6 @@ static void sctp_assoc_bh_rcv(struct work_struct *work); static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc); static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc); -/* Keep track of the new idr low so that we don't re-use association id - * numbers too fast. It is protected by they idr spin lock is in the - * range of 1 - INT_MAX. - */ -static u32 idr_low = 1; - - /* 1st Level Abstractions. */ /* Initialize a new association from provided memory. */ @@ -1601,13 +1594,7 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp) if (preload) idr_preload(gfp); spin_lock_bh(&sctp_assocs_id_lock); - /* 0 is not a valid id, idr_low is always >= 1 */ - ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT); - if (ret >= 0) { - idr_low = ret + 1; - if (idr_low == INT_MAX) - idr_low = 1; - } + ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT); spin_unlock_bh(&sctp_assocs_id_lock); if (preload) idr_preload_end(); diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1c2e46c..bc7b069 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1352,7 +1352,7 @@ SCTP_STATIC __init int sctp_init(void) sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS; /* Initialize handle used for association ids. */ - idr_init(&sctp_assocs_id); + idr_init_cyclic(&sctp_assocs_id, 1); limit = nr_free_buffer_pages() / 8; limit = max(limit, 128UL);