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=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 7AD48C43381 for ; Fri, 22 Feb 2019 22:16:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37EE420675 for ; Fri, 22 Feb 2019 22:16:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HVgmlun+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725937AbfBVWQm (ORCPT ); Fri, 22 Feb 2019 17:16:42 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35523 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbfBVWQl (ORCPT ); Fri, 22 Feb 2019 17:16:41 -0500 Received: by mail-pf1-f195.google.com with SMTP id j5so1717892pfa.2 for ; Fri, 22 Feb 2019 14:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=nn6DWv8/yY8mJTbj3sI8HLB2sfSgk7XHW7dWd0gcHhw=; b=HVgmlun+DPV4w+Ta0grYjkEX63SGi+USnHwgDv0qzYYoz20vNTHKVLsilXvkVATmsJ PooPuuBo3wwQbw3Ntb8j/4nFnk1B27LJ3aCzT3jc1bQPAIQfYdIjKUyCX8w4SHlacTMS 3zp3+bQfvyQC6nDb1xkXEi4xNnx4xGDKeyHC2Yueiw4dIJfVqd6QJaXv8YE9gQq9yRXF X00Ych8bjbnKROojv09zqiw+qBeL5kv5dMXhNhYOgxPeKBUB37yL9GjcfeoUEozjFjp/ iQr2TnuSUznr709JIIiomrxLuqdV93GirjP1ezDPLWnkPRg+m7gJ+NIwgkTP4iCjdb7y CQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nn6DWv8/yY8mJTbj3sI8HLB2sfSgk7XHW7dWd0gcHhw=; b=CUT0yF9C3FoBlhJUArjzVo67EE3qx+pcx3cJ0DdFBPSXA0HtYvqKu9x2osnm8NMeXT JMvSe6KfZg07++5+Ve1mUzUcgn8cbj56uRmWy8+sf3QzxDCUTdCohzPPMA3rw4585Tv/ zaA3Wte/TQuM/YYXAjRBffsc6SoZSEDEsFQ0/E50CtY0El7lZ/EzDMT8uPxKK00XF0yH xBVsYbZ1wiMVZGE0LSRKayOlqyx9YEAxvYgouZacCdOq2sxsu9xoQlZk2sr/nKBG+VIl KniyrCutqRaMN//i3OlZNe7jM9lceKxkIUh0+T/nojTQpeDe7aSHAPwn0Ym3OdTitcPU VmPg== X-Gm-Message-State: AHQUAubpxbeB6EwivQOS9FTwHBLDGa9svtFQvGTOUA2YrOJYevneew5Y KxU1ZXOOyQDFnBAJgIObFNZb1Nxa X-Google-Smtp-Source: AHgI3IYxY/yzvVpvtUqJxZjDMo/Q6tgnzOMUg6mr6AtTWc8GIAovyHhKHL27p68U9XSFCV3ILK2INw== X-Received: by 2002:a63:e309:: with SMTP id f9mr6074713pgh.280.1550873800719; Fri, 22 Feb 2019 14:16:40 -0800 (PST) Received: from [172.27.227.214] ([216.129.126.118]) by smtp.googlemail.com with ESMTPSA id n6sm3826215pfa.3.2019.02.22.14.16.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 14:16:39 -0800 (PST) Subject: Re: [PATCH net-next v2] ip_tunnel: Add dst_cache management lwtunnel_state of ip tunnel To: wenxu , 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> <8b96ffcb-fe29-1c49-a266-3e9d20b60d89@ucloud.cn> From: David Ahern Message-ID: <76715d1b-00a9-8da2-2af5-7a2198de9b8a@gmail.com> Date: Fri, 22 Feb 2019 17:16:37 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <8b96ffcb-fe29-1c49-a266-3e9d20b60d89@ucloud.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2/22/19 10:21 AM, wenxu wrote: > 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) > If 'try_module_get(ops->owner)' succeeds then a reference is held so the ops will not go away.