From patchwork Tue Apr 23 01:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 1088996 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="jVh9tjEx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44p5c55qNYz9s55 for ; Tue, 23 Apr 2019 11:35:17 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbfDWBfR (ORCPT ); Mon, 22 Apr 2019 21:35:17 -0400 Received: from mail-vs1-f74.google.com ([209.85.217.74]:42189 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbfDWBfQ (ORCPT ); Mon, 22 Apr 2019 21:35:16 -0400 Received: by mail-vs1-f74.google.com with SMTP id w69so2686256vsc.9 for ; Mon, 22 Apr 2019 18:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jdGj5Dugqwsjnp9K/H8uzCY+Um/zduVatUD5hRzWtVc=; b=jVh9tjExHGtUeWgeoCR8FVWJHTaJjnfCVUNjaUtnNfH1FNgpVXFySSz2+zIV+McMf+ t0GfRQmjT1jlTduqoWIdZD95MxUbTu5O/eWwQ2bjbzoSNFK/HehIJUY5Uy8AeQKQYbS/ hn3N8rz65S4mpaxB/sIiZj5NLzN5Jk7tjLGtS9P9mVr52MRKnbwBHtdu2f3PsdDBtzrH r/61EZ71DABKgQjHznK0iy+O8l4W8bunC5E++lcUBMjRoQFtJ65UDN7lbaNV5TON79Tu FA17dz99J4boS4rxFnLxXtGgDqbLFrDrzyNCz5qPdCX4GcG8e/90qaMJ4bT+EjmUsMCt NcCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jdGj5Dugqwsjnp9K/H8uzCY+Um/zduVatUD5hRzWtVc=; b=WKhkoMsXg16I6Y0e31t12S/5VPGV2csUbiFDoeb/xhFUg7F8JQSSRfohhp9ZITHqZN JNTeGt7qmNw8WGh+gKwj/EOBLDsRO0mrkLyu6Rj08HhMcJgWOG9K4cCr0rT5eVFw2VKa auTWhPECDaD7ijT5S/A3M7H946gaHUByNV6+thS75j+fsTp2KOpjMEAC/ewBD9BuHKT9 jxqT3d0bgVMk3F3clIrakhZKiFuIBwPI3LhQuUcJGuMkoHcRxPUnxqNpI9yEnOEvoRik 19PIY23ducpqQei2H4qjp8CH61Nw0zzGtpc6vVChF0O4ZxFN85UcAFbqMeWp3rfx7seJ sgNQ== X-Gm-Message-State: APjAAAWdTXevIU/LUKzKeyivf6udmGNlXO7CjPz9W7Cfs3/GfV7vTX42 PH/Ilz8lyW5Nat8uZLVJopx1+Yu5DvXIog== X-Google-Smtp-Source: APXvYqyB4MdOl813dNtT06X9+jnVSyl3nA8qVQtUhUrNWa1BV9SJOw6cS+0Ul9ykCoxqnyV63UNbNnohgqUfdQ== X-Received: by 2002:a67:f6c8:: with SMTP id v8mr977645vso.73.1555983315028; Mon, 22 Apr 2019 18:35:15 -0700 (PDT) Date: Mon, 22 Apr 2019 18:35:02 -0700 In-Reply-To: <20190423013503.217729-1-edumazet@google.com> Message-Id: <20190423013503.217729-3-edumazet@google.com> Mime-Version: 1.0 References: <20190423013503.217729-1-edumazet@google.com> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog Subject: [PATCH net-next 2/3] ipv6: broadly use fib6_info_hold() helper From: Eric Dumazet To: "David S . Miller" Cc: netdev , Eric Dumazet , Eric Dumazet , Wei Wang Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Instead of using atomic_inc(), prefer fib6_info_hold() so that upcoming refcount_t conversion is simpler. Only fib6_info_alloc() is using atomic_set() since we just allocated a new object. Signed-off-by: Eric Dumazet Cc: Wei Wang Acked-by: Wei Wang Reviewed-by: David Ahern --- net/ipv6/ip6_fib.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 55193859152969794dab3df02637217a7f21016f..a5e83593e0e45c2762eca85d04757f9d8e118e0f 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -162,7 +162,7 @@ struct fib6_info *fib6_info_alloc(gfp_t gfp_flags) } INIT_LIST_HEAD(&f6i->fib6_siblings); - atomic_inc(&f6i->fib6_ref); + atomic_set(&f6i->fib6_ref, 1); return f6i; } @@ -846,8 +846,8 @@ static struct fib6_node *fib6_add_1(struct net *net, RCU_INIT_POINTER(in->parent, pn); in->leaf = fn->leaf; - atomic_inc(&rcu_dereference_protected(in->leaf, - lockdep_is_held(&table->tb6_lock))->fib6_ref); + fib6_info_hold(rcu_dereference_protected(in->leaf, + lockdep_is_held(&table->tb6_lock))); /* update parent pointer */ if (dir) @@ -942,7 +942,7 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn, struct fib6_info *new_leaf; if (!(fn->fn_flags & RTN_RTINFO) && leaf == rt) { new_leaf = fib6_find_prefix(net, table, fn); - atomic_inc(&new_leaf->fib6_ref); + fib6_info_hold(new_leaf); rcu_assign_pointer(fn->leaf, new_leaf); fib6_info_release(rt); @@ -1108,7 +1108,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, return err; rcu_assign_pointer(rt->fib6_next, iter); - atomic_inc(&rt->fib6_ref); + fib6_info_hold(rt); rcu_assign_pointer(rt->fib6_node, fn); rcu_assign_pointer(*ins, rt); if (!info->skip_notify) @@ -1136,7 +1136,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, if (err) return err; - atomic_inc(&rt->fib6_ref); + fib6_info_hold(rt); rcu_assign_pointer(rt->fib6_node, fn); rt->fib6_next = iter->fib6_next; rcu_assign_pointer(*ins, rt); @@ -1278,7 +1278,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt, if (!sfn) goto failure; - atomic_inc(&info->nl_net->ipv6.fib6_null_entry->fib6_ref); + fib6_info_hold(info->nl_net->ipv6.fib6_null_entry); rcu_assign_pointer(sfn->leaf, info->nl_net->ipv6.fib6_null_entry); sfn->fn_flags = RTN_ROOT; @@ -1321,7 +1321,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt, rcu_assign_pointer(fn->leaf, info->nl_net->ipv6.fib6_null_entry); } else { - atomic_inc(&rt->fib6_ref); + fib6_info_hold(rt); rcu_assign_pointer(fn->leaf, rt); } }