From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B8AEC43381 for ; Fri, 22 Feb 2019 04:14:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F27BC2086C for ; Fri, 22 Feb 2019 04:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726346AbfBVEOH (ORCPT ); Thu, 21 Feb 2019 23:14:07 -0500 Received: from m9785.mail.qiye.163.com ([220.181.97.85]:13712 "EHLO m9785.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfBVEOH (ORCPT ); Thu, 21 Feb 2019 23:14:07 -0500 Received: from [192.168.188.14] (unknown [120.132.1.226]) by m9785.mail.qiye.163.com (Hmail) with ESMTPA id 179015C18A0; Fri, 22 Feb 2019 12:14:04 +0800 (CST) Subject: Re: [PATCH net-next v2] ip_tunnel: Add dst_cache management lwtunnel_state of ip tunnel To: David Ahern , davem@davemloft.net, netdev@vger.kernel.org References: <1550804401-16232-1-git-send-email-wenxu@ucloud.cn> From: wenxu Message-ID: <26082211-7038-f26e-a8cf-ef5767c7cd77@ucloud.cn> Date: Fri, 22 Feb 2019 12:14:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-HM-Spam-Status: e1kIGBQJHllBS1VLV1koWUFJQjdXWS1ZQUlXWQkOFx4IWUFZMjUtOjcyP0 FLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Myo6Shw5LjlCPw83EBM4UTBO HBVPC09VSlVKTk5LQ0tDQ09PSUxOVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpJS1VK SElVSlVJSU1ZV1kIAVlBSE1IQjcG X-HM-Tid: 0a69136907a52087kuqy179015c18a0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2/22/2019 11:39 AM, David Ahern wrote: > On 2/21/19 10:00 PM, wenxu@ucloud.cn wrote: >> From: wenxu >> >> The lwtunnel_state is not init the dst_cache Which make the >> ip_md_tunnel_xmit can't use the dst_cache. It will lookup >> route table every packets. >> >> Signed-off-by: wenxu >> --- >> net/ipv4/ip_tunnel_core.c | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c >> index 9a0e67b..f91ef7a 100644 >> --- a/net/ipv4/ip_tunnel_core.c >> +++ b/net/ipv4/ip_tunnel_core.c >> @@ -252,6 +252,12 @@ static int ip_tun_build_state(struct nlattr *attr, >> >> tun_info = lwt_tun_info(new_state); >> >> + err = dst_cache_init(&tun_info->dst_cache, GFP_ATOMIC); > build_state is called with rtnl held. Unless I am missing something, you > don't need ATOMIC here. If set GFP_KERNEL shows following: Feb 22 07:07:03 A1_V5_02 kernel: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:1301 Feb 22 07:07:03 A1_V5_02 kernel: in_atomic(): 1, irqs_disabled(): 0, pid: 7950, name: ip Feb 22 07:07:03 A1_V5_02 kernel: CPU: 21 PID: 7950 Comm: ip Kdump: loaded Not tainted 5.0.0-rc6-next-20190215 #14 Feb 22 07:07:03 A1_V5_02 kernel: Hardware name: Inspur SA5112M5/YZMB-00870-101, BIOS 4.0.3 05/22/2018 Feb 22 07:07:03 A1_V5_02 kernel: Call Trace: Feb 22 07:07:03 A1_V5_02 kernel: dump_stack+0x5a/0x73 Feb 22 07:07:03 A1_V5_02 kernel: ___might_sleep+0xfc/0x120 Feb 22 07:07:03 A1_V5_02 kernel: mutex_lock_killable+0x1c/0x42 Feb 22 07:07:03 A1_V5_02 kernel: pcpu_alloc+0x390/0x6f0 Feb 22 07:07:03 A1_V5_02 kernel: ? __nla_parse+0xf8/0x160 Feb 22 07:07:03 A1_V5_02 kernel: dst_cache_init+0x1d/0x40 Feb 22 07:07:03 A1_V5_02 kernel: ip_tun_build_state+0x75/0x140 Feb 22 07:07:03 A1_V5_02 kernel: lwtunnel_build_state+0x92/0xf0 Feb 22 07:07:03 A1_V5_02 kernel: fib_create_info+0x74e/0x1020 build_state in the rcu_read_lock and disable the preempt  rcu_read_lock();     ops = rcu_dereference(lwtun_encaps[encap_type]);     if (likely(ops && ops->build_state && try_module_get(ops->owner))) {         found = true;         ret = ops->build_state(encap, family, cfg, lws, extack);         if (ret)             module_put(ops->owner);     }       rcu_read_unlock();