All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Qian Cai <cai@lca.pw>, Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, kuznet@ms2.inr.ac.ru,
	yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipv4: fix a RCU-list lock in fib_triestat_seq_show
Date: Wed, 25 Mar 2020 11:31:27 -0700	[thread overview]
Message-ID: <8ae16be2-9c64-245e-0997-805f48078432@gmail.com> (raw)
In-Reply-To: <92C7474D-4592-44BF-B0ED-26253196511E@lca.pw>



On 3/25/20 10:34 AM, Qian Cai wrote:
> 
> 
>> On Mar 25, 2020, at 12:13 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>>
>> I would prefer :
>>
>> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
>> index ff0c24371e3309b3068980f46d1ed743337d2a3e..4b98ffb27136d3b43f179d6b1b42fe84586acc06 100644
>> --- a/net/ipv4/fib_trie.c
>> +++ b/net/ipv4/fib_trie.c
>> @@ -2581,6 +2581,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
>>                struct hlist_head *head = &net->ipv4.fib_table_hash[h];
>>                struct fib_table *tb;
>>
>> +               rcu_read_lock();
>>                hlist_for_each_entry_rcu(tb, head, tb_hlist) {
>>                        struct trie *t = (struct trie *) tb->tb_data;
>>                        struct trie_stat stat;
>> @@ -2596,6 +2597,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
>>                        trie_show_usage(seq, t->stats);
>> #endif
>>                }
>> +               rcu_read_unlock();
>>        }
>>
>>        return 0;
> 
> I have no strong opinion either way. My initial thought was to save 255 extra lock/unlock with a single lock/unlock, but I am not sure how time-consuming for each iteration of the outer loop could be. If it could take a bit too long, it does make a lot of sense to reduce the critical section.
> 


This file could be quite big in some setups.

Alternatively you could use cond_resched_rcu()


      reply	other threads:[~2020-03-25 18:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 15:55 [PATCH] ipv4: fix a RCU-list lock in fib_triestat_seq_show Qian Cai
2020-03-25 16:13 ` Eric Dumazet
2020-03-25 17:34   ` Qian Cai
2020-03-25 18:31     ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ae16be2-9c64-245e-0997-805f48078432@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=cai@lca.pw \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.