Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp890588ybb; Wed, 25 Mar 2020 11:33:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtcyrE4iq4COhvzN8/pNV5LI1e+SLs//nra2p+pFYuxkFbehJ8Q1qzwXNBXYwqHxcaeNOGe X-Received: by 2002:a9d:720a:: with SMTP id u10mr3154100otj.177.1585161185383; Wed, 25 Mar 2020 11:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585161185; cv=none; d=google.com; s=arc-20160816; b=E5aTrOckPG0WsJXKgPjmQ6pBzWMp3RnCsBlFvt9yOlTF2spXiX/LnFq2HZ0ev7hU/f E1UgZs5eXyU5FfpBalknSP1RBTOm6Dn/Sx7RMHf7H0LVSSoFk4TwSUeXyKUFECZ0ymY/ d1wFNly0ce6n880pWTDFaiUN5xRpBOU8BB9IPLwXP8Re06N4yANEFX8QrXKaU7zbeYjU NGVHnJwXmdJ8psiy7ErmAQVqymbOu2om8ZZU8XPfCVCFPPm51zvq0eQEp1+KAegPu/Uc b6NcVVaQbAIL+Qdg3uLGLPeW+d2AJueA8byfyWhhBuM3OI/QFxv5qGCSy5LGP3doOcX4 ZVxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=M66oudythcBmFzgaHHj4NT8FrhMNeWSRLde1HiyDOR8=; b=BLhBuDPeAswbdRMB30ZTuuKDJ/mZKts7aaeqKbs1idEFNNlHA1jQOzDHZPZJr0l7CQ u692Z3lALFUMPqhLwz1Cr1mrMRCejy7U7aOzjurzjq8CzCIedrsEu5DogNgEAQuh/wj3 Gpo78vzRp+zyWx0KoZkS5U4d+SP9G5sUA9VnrNHN8tYSmz/aVez2rLbSHJ2mAVOukvxx gys89GIkPdn7TT+/JU/zQnvOIPfk6I3nTrK+yXPQlsSXind0/e3cTFDL9YECKXRlRHE8 j7VBtZQspG7lhxGiumXIVHrQZc2/+mVob5W1MpB1nyj/fTax1UFp9HXJaFB9adHqULIq Krxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HdIw1VMt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r29si11968490oth.324.2020.03.25.11.32.43; Wed, 25 Mar 2020 11:33:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HdIw1VMt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbgCYSbb (ORCPT + 99 others); Wed, 25 Mar 2020 14:31:31 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41970 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbgCYSbb (ORCPT ); Wed, 25 Mar 2020 14:31:31 -0400 Received: by mail-pl1-f194.google.com with SMTP id t16so1128767plr.8; Wed, 25 Mar 2020 11:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=M66oudythcBmFzgaHHj4NT8FrhMNeWSRLde1HiyDOR8=; b=HdIw1VMtWl2/2v1yXgAGAvreoa07Z20PO0djS3sVwAtLM+I7s5xRzIEe35oeHcvOrG cwFVGXVUQOJJqneRGY67rC3nCMlhstYrxOCNk0weqkxLAfMWJIviyvLxqy0I/2HLvESk 44NlcSXlhfC7jowxQIX3LQowQDc9nZyNP4risf6//MlSbccq3ynTm7352WA9eUVpDATC VNVcFYALK9g0a+YKJshkj2j6qvZZMMcbQEZn8FyGqUGQJqxMEjOOMWR2ZVKhmKo2jB/+ nBbJJba1GA0gzI0fFguMwUaZAwc7vQJZYUsuEJUD4ugU390rpOwLqqR97Dwl5LVzGmFv SAUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=M66oudythcBmFzgaHHj4NT8FrhMNeWSRLde1HiyDOR8=; b=Oh5nx/KlzV1eGnZowLrn192fpIYPgAq8k2NIkd04Sdu93DN8hMewDnMNK4GdoLIFpm xWLm0IFr7KxWVeTuCMeFRq8gVpwNAEM2mILlAgOCtlF8BhGRlqgSofy1Gj+kn/rety/e erSPKynoGySVkSOef1YH/2+3pi2uIdhji9JXNnkZoPiHX80mtWI/HTOi/V473yDBFroP oHaRTCno8Q6ibcVoj1fp/DwP7EJzKH2DHaAfR0iZdoU+Ay9a8NHJFDkifPx1x59LcN1n VntGTqXcskMmkUx0QCgOKn1PPtvqmUwQnDovaGFVFZ7rLD0Pzs1Q0BaAW59B9IkNAdz9 khqA== X-Gm-Message-State: ANhLgQ1sPMWVed55N7+M9SN0qI4+TmZ0jpW323lshkamdlm/cOEpH2fa lSvsCHCpNkAFyT3nHyKypRXiRt2r X-Received: by 2002:a17:902:a9cc:: with SMTP id b12mr4365819plr.177.1585161089735; Wed, 25 Mar 2020 11:31:29 -0700 (PDT) Received: from [192.168.86.235] (c-73-241-150-58.hsd1.ca.comcast.net. [73.241.150.58]) by smtp.gmail.com with ESMTPSA id c15sm17083869pgk.66.2020.03.25.11.31.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Mar 2020 11:31:28 -0700 (PDT) Subject: Re: [PATCH] ipv4: fix a RCU-list lock in fib_triestat_seq_show To: Qian Cai , Eric Dumazet 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 References: <5e2ed86a-23bc-d3e5-05ad-4e7ed147539c@gmail.com> <92C7474D-4592-44BF-B0ED-26253196511E@lca.pw> From: Eric Dumazet Message-ID: <8ae16be2-9c64-245e-0997-805f48078432@gmail.com> Date: Wed, 25 Mar 2020 11:31:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <92C7474D-4592-44BF-B0ED-26253196511E@lca.pw> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/25/20 10:34 AM, Qian Cai wrote: > > >> On Mar 25, 2020, at 12:13 PM, Eric Dumazet 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()