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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS 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 07B5DC43381 for ; Fri, 22 Feb 2019 15:21:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D640B207E0 for ; Fri, 22 Feb 2019 15:21:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726587AbfBVPVS (ORCPT ); Fri, 22 Feb 2019 10:21:18 -0500 Received: from m97179.mail.qiye.163.com ([220.181.97.179]:1428 "EHLO m97179.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbfBVPVS (ORCPT ); Fri, 22 Feb 2019 10:21:18 -0500 Received: from [192.168.0.107] (unknown [180.157.111.121]) by m97179.mail.qiye.163.com (Hmail) with ESMTPA id 7C9FBE01111; Fri, 22 Feb 2019 23:21:15 +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> <26082211-7038-f26e-a8cf-ef5767c7cd77@ucloud.cn> <9277b934-63f6-2f16-bd46-948bc64cc46e@gmail.com> From: wenxu Message-ID: <8b96ffcb-fe29-1c49-a266-3e9d20b60d89@ucloud.cn> Date: Fri, 22 Feb 2019 23:21:14 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <9277b934-63f6-2f16-bd46-948bc64cc46e@gmail.com> 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: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OiI6Igw6KTlWTg8iMgwZPSwz Qw5PCTVVSlVKTk5LQ09DQ0xOTUxJVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpDS1VK TkxVSkpKVUpJSllXWQgBWUFJSElJNwY+ X-HM-Tid: 0a6915cbdc5c20bdkuqy7c9fbe01111 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2019/2/22 下午11:03, David Ahern wrote: > On 2/21/19 11:14 PM, wenxu wrote: >> 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(); >> > Missed that. > > Once a reference is taken the rcu_read_lock can be dropped before > calling build_state allowing the allocations to be GFP_KERNEL. > I don't think the rcu_read_lock can be dropped. The whole operation of the reference should be protect in the rcu_read_lock that ensure the ops will not be destroy (if it will be)