Received: by 10.192.165.148 with SMTP id m20csp1289568imm; Sat, 5 May 2018 08:41:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKbnoiEJ8MUF9IkjxdTdaY32SZ71LuCq0bujIpnnNBeoY/A5iRHMNiJP1Rc4kFprdPcSY0 X-Received: by 2002:a63:a54f:: with SMTP id r15-v6mr26351862pgu.236.1525534887862; Sat, 05 May 2018 08:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525534887; cv=none; d=google.com; s=arc-20160816; b=uw2Xtr5mEYpFWFJM2z7+Nldj61JpiB9DCoLFws4M35uQguSn9EsMI//16S3cL0B7oM nuBePEmPnjy4XIzq2jy2JhlR6k+p0i/T5ExigRPKHn5cq7g9BjBj7TQb6/7A8da7blwI bR1eFKrc4Q+bS9v+Hb6UkhVd01X0j+XEwGuwU/B0pAg+lZOpFSpIoFDNAuKUE+sdqiD2 KKok714o/670mZZqsN31H+cqBlNiAqPs/qUdlNrTN1/8EH0rK+OyDqwTSBIeg8bkHIts 5xhF5v1waJQ3irXSJEXMlUJo+GlukNZXVl5XCuG93ifpQ79L+kHVMvgt1juzAwgqthA5 H+9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=K06nB3UoIDUXFl/Xk04QWE49GO6FKnHoaNO8hQJaHZg=; b=IO7DO58tg1WJmD0/hfb+G5Jt77u+SHL9/J5vWqA6ofjt7vS1IGg/pveGEfITw6tQMN Wrn3hzOLARp25TPYNuLhkc7mr3/lyXjPkf2yl3UT/EUY7PwGTWx2w+45UkLE4OPMwPdg 1Ads3RgbjCynd+8BFzWX5/h4q2xQuA8CEWu2CgwaOCwUIskegC1EvIUAWuGko0Bp26MO zx8z3/46QPJYQUjom5SZeQz/HCjyl2+WjkZv1D7Kj8kxdbJY+5Yn9zqflRwh+CGxaFTp tyBdiAS53sUKUuOHLYMZbgwMU9sgA7gtUdb08sjcrOKGLXzEk/FwQVtIfXXTxW0crYlN 9zMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quantonium-net.20150623.gappssmtp.com header.s=20150623 header.b=wdpMf6zz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj1-v6si11883400plb.395.2018.05.05.08.41.13; Sat, 05 May 2018 08:41:27 -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=@quantonium-net.20150623.gappssmtp.com header.s=20150623 header.b=wdpMf6zz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751848AbeEEPkj (ORCPT + 99 others); Sat, 5 May 2018 11:40:39 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35842 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751211AbeEEPkh (ORCPT ); Sat, 5 May 2018 11:40:37 -0400 Received: by mail-wr0-f194.google.com with SMTP id f2-v6so12024956wrm.3 for ; Sat, 05 May 2018 08:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=K06nB3UoIDUXFl/Xk04QWE49GO6FKnHoaNO8hQJaHZg=; b=wdpMf6zz2yujR5RPtP1hsiTPZGIhyHPtZp53PRAROlik+udZkRbp7iygUlWsuH/Kvh 4lHQBxPSvHVZecuTXaZSCiLoBTUoI6qCmk3zhknVDFs5ELrkpPELwQj/IUvB1NjXCUnC RpD3mtLvA/aKbbB84ptXXJ6dsLTljMeSFk9FtsRtMdGo4jZmne29xqdLmj7B6hyElKVo akMfC1DcSrQLaJGaByD2kLsHAgx2UU6qFhCQpW+UffBvDvaEj8QxTa77ZRTqghJZj+Ix +baiqP1+ZQnD9niCSKVz+7hlrOWrcHZr8hOFpj33YdP2gAtFPGZVpSKUvezwds4mQVd0 Tk9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=K06nB3UoIDUXFl/Xk04QWE49GO6FKnHoaNO8hQJaHZg=; b=a4dfhifLlMz8TAWRFapBfBfmy2aHyDCck1pH8NzFU/sTroKkPjPz92h70tRy97R8Sd 30Fi388wYNRcL5hGJA99L4c3lvSJfr8iii2tTtpewcq3excuK1MMKxEwB4pYaQ/3YXfd mhky0TsQADK5EK/gr5URyIQrnn+7An18PU2SezGrXn7uX/NklX65LYkf6LQ00VnATUj4 DW7GsUnbxXMgK4r+b+kl8i/LIpFPbFNDpX2hg+bmH3PGVPv0FrqejVge+x+TCfPzOzxM ivqEvkuZUFXoCC0klnWq6Wm3pCNopeMN7ZOgFWCynoiSDvtNYHpL1hpu64F+FsrFI1em 6gyw== X-Gm-Message-State: ALQs6tBiyBe9Rrp05LsxNGhGrM+zWk5z2wjC0OGfqyl94Q7ceJAYC9eG mVMjHiyqXJXPWmlcoz63VsSW2WIvsrQK2iQuMcf5FUfZ X-Received: by 2002:adf:e181:: with SMTP id k1-v6mr25644659wri.111.1525534835869; Sat, 05 May 2018 08:40:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.128.227 with HTTP; Sat, 5 May 2018 08:40:35 -0700 (PDT) In-Reply-To: <20180505094324.wwjtl76oofgrtpg4@gondor.apana.org.au> References: <152540595840.18473.11298241115621799037.stgit@noble> <152540605441.18473.4087381584733882012.stgit@noble> <20180505094324.wwjtl76oofgrtpg4@gondor.apana.org.au> From: Tom Herbert Date: Sat, 5 May 2018 08:40:35 -0700 Message-ID: Subject: Re: [PATCH 7/8] rhashtable: add rhashtable_walk_prev() To: Herbert Xu Cc: NeilBrown , Thomas Graf , Linux Kernel Network Developers , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 5, 2018 at 2:43 AM, Herbert Xu wrote: > On Fri, May 04, 2018 at 01:54:14PM +1000, NeilBrown wrote: >> rhashtable_walk_prev() returns the object returned by >> the previous rhashtable_walk_next(), providing it is still in the >> table (or was during this grace period). >> This works even if rhashtable_walk_stop() and rhashtable_talk_start() >> have been called since the last rhashtable_walk_next(). >> >> If there have been no calls to rhashtable_walk_next(), or if the >> object is gone from the table, then NULL is returned. >> >> This can usefully be used in a seq_file ->start() function. >> If the pos is the same as was returned by the last ->next() call, >> then rhashtable_walk_prev() can be used to re-establish the >> current location in the table. If it returns NULL, then >> rhashtable_walk_next() should be used. >> >> Signed-off-by: NeilBrown > > I will ack this if Tom is OK with replacing peek with it. > I'm not following why this is any better than peek. The point of having rhashtable_walk_peek is to to allow the caller to get then current element not the next one. This is needed when table is read in multiple parts and we need to pick up with what was returned from the last call to rhashtable_walk_next (which apparently is what this patch is also trying to do). There is one significant difference in that peek will return the element in the table regardless of where the iterator is at (this is why peek can move the iterator) and only returns NULL at end of table. As mentioned above rhashtable_walk_prev can return NULL so then caller needs and so rhashtable_walk_next "should be used" to get the previous element. Doing a peek is a lot cleaner and more straightforward API in this regard. Tom > Cheers, > -- > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt