From patchwork Fri Feb 27 00:54:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 444105 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 A507314011D for ; Fri, 27 Feb 2015 11:55:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=iXcM2rhQ; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753900AbbB0Ay6 (ORCPT ); Thu, 26 Feb 2015 19:54:58 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:45765 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753862AbbB0Ay5 (ORCPT ); Thu, 26 Feb 2015 19:54:57 -0500 Received: by pdjz10 with SMTP id z10so16919665pdj.12 for ; Thu, 26 Feb 2015 16:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0rPV/g5XRuewr6jNmn15JwwYl86apwI6m85T3xXgVpk=; b=iXcM2rhQnYW9mVldtI98onrqBJPd5xPjmW/2ECxWctE/PzoC/IERrEZNVBOrMkOJZu wkbVdDv0B9vq4XXJn9R+c9a9CJsZUPzUxIwTwBpTZHJdSnlzLXy5UBOvH0QQcAsap03E aBH3dHX/QC/wEAZCIkwI3SskSilOA5ZJsGJira8QiCNf4f8hb7bwJcpGlnLGv1+c9yqj Og5J+pcgWD5gxdMPfpZSwk2zf3ZYxRGt4AfICDWEuyBvXDhpFja+TORoecH3Puoh/9XY jhE8GBgrRH0QxDDp6bW6PfhNh0OVuhoUH3DnZ2/K4rPYCg758UlaV8V6fBiFrwikNa7H vjiA== X-Received: by 10.70.52.8 with SMTP id p8mr19277890pdo.27.1424998496975; Thu, 26 Feb 2015 16:54:56 -0800 (PST) Received: from localhost.net ([8.25.197.27]) by mx.google.com with ESMTPSA id ep2sm2070591pbc.78.2015.02.26.16.54.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 16:54:56 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: Nicolas Dichtel , Cong Wang Subject: [Patch net] netns: correct gfp flags for alloc_netid() Date: Thu, 26 Feb 2015 16:54:50 -0800 Message-Id: <1424998490-9565-1-git-send-email-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This fixes the following kernel warning: =============================== [ INFO: suspicious RCU usage. ] 3.19.0+ #805 Tainted: G W ------------------------------- include/linux/rcupdate.h:538 Illegal context switch in RCU read-side critical section! other info that might help us debug this: rcu_scheduler_active = 1, debug_locks = 0 2 locks held by ip/771: #0: (rtnl_mutex){+.+.+.}, at: [] netlink_dump+0x21/0x26c #1: (rcu_read_lock){......}, at: [] rcu_read_lock+0x0/0x6e stack backtrace: CPU: 3 PID: 771 Comm: ip Tainted: G W 3.19.0+ #805 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 0000000000000001 ffff8800d51e7718 ffffffff81a27457 0000000029e729e6 ffff8800d6108000 ffff8800d51e7748 ffffffff810b539b ffffffff820013dd 00000000000001c8 0000000000000000 ffff8800d7448088 ffff8800d51e7758 Call Trace: [] dump_stack+0x4c/0x65 [] lockdep_rcu_suspicious+0x107/0x110 [] rcu_preempt_sleep_check+0x45/0x47 [] ___might_sleep+0x1d/0x1cb [] __might_sleep+0x78/0x80 [] idr_alloc+0x45/0xd1 [] ? rcu_read_lock_held+0x3b/0x3d [] ? idr_for_each+0x53/0x101 [] alloc_netid+0x61/0x69 [] __peernet2id+0x79/0x8d [] peernet2id+0x13/0x1f [] rtnl_fill_ifinfo+0xa8d/0xc20 [] ? __lock_is_held+0x39/0x52 [] rtnl_dump_ifinfo+0x149/0x213 [] netlink_dump+0xef/0x26c [] netlink_recvmsg+0x17b/0x2c5 [] __sock_recvmsg+0x4e/0x59 [] sock_recvmsg+0x3f/0x51 [] ___sys_recvmsg+0xf6/0x1d9 [] ? handle_pte_fault+0x6e1/0xd3d [] ? native_sched_clock+0x35/0x37 [] ? sched_clock_local+0x12/0x72 [] ? sched_clock_cpu+0x9e/0xb7 [] ? rcu_read_lock_held+0x3b/0x3d [] ? __fcheck_files+0x4c/0x58 [] ? __fget_light+0x2d/0x52 [] __sys_recvmsg+0x42/0x60 [] SyS_recvmsg+0x12/0x1c Fixes: commit 0c7aecd4bde4b7302 ("netns: add rtnl cmd to add and get peer netns ids") Cc: Nicolas Dichtel Signed-off-by: Cong Wang --- -- 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/net_namespace.c b/net/core/net_namespace.c index cb5290b..ecf8e70 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -148,7 +148,8 @@ static void ops_free_list(const struct pernet_operations *ops, } } -static int alloc_netid(struct net *net, struct net *peer, int reqid) +static int alloc_netid(struct net *net, struct net *peer, int reqid, + gfp_t flags) { int min = 0, max = 0; @@ -159,7 +160,7 @@ static int alloc_netid(struct net *net, struct net *peer, int reqid) max = reqid + 1; } - return idr_alloc(&net->netns_ids, peer, min, max, GFP_KERNEL); + return idr_alloc(&net->netns_ids, peer, min, max, flags); } /* This function is used by idr_for_each(). If net is equal to peer, the @@ -188,7 +189,7 @@ static int __peernet2id(struct net *net, struct net *peer, bool alloc) return id; if (alloc) - return alloc_netid(net, peer, -1); + return alloc_netid(net, peer, -1, GFP_ATOMIC); return -ENOENT; } @@ -524,7 +525,7 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh) goto out; } - err = alloc_netid(net, peer, nsid); + err = alloc_netid(net, peer, nsid, GFP_KERNEL); if (err > 0) err = 0; out: