Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1605207imm; Fri, 6 Jul 2018 03:14:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVht/nKg3seB4LI8YscGUpjMgHO0sSezsd4J6J9am1MSgWuS79fSaJng9wN9ojgskD68IL X-Received: by 2002:a63:1350:: with SMTP id 16-v6mr3009329pgt.214.1530872043735; Fri, 06 Jul 2018 03:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530872043; cv=none; d=google.com; s=arc-20160816; b=mMCXSxF0SUt/Ry7nRHt81z6cBLmSfqojaW43MdEiwdcUissjkwle9otdqhzrL0Q2vg zc2APyIo1eIP9beAcqR+Lwfl0R72TVapJ2lelHP/K4TgJXncr3Rbs3azPSh5g9HSyrtV Ht2uhO0FWDa2mmRF1pxMCTiWkfyf+tlqyXLWzaS4hEwnjX/quifefhAZUrZp32gY2T2e diwvEI4Jdt15GtE95uR2R0ItX4fEoMMZzj8v7YIWEsdldgH01TFuT/jhyfMYMi2NB20Z q8QSJ0hCEFA4MDE4lkHJh3XnebEi1cbB5wQZaGlxJHesPISxIcUe8FnhgfPUMtOz66hM Yf2Q== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=w6DPdV+X4mpgeZQVv3LyVwLJrXQ13OmilgFEWwZY2RM=; b=KeEuHqKVGt6VNa2VVxYlRGVoEhszl51/LRWl2ONIQc7xR4hC/niOWKbT9/kZic/LdP TVZJVNbF7KTPI8uYQakWO6xcqyqBdIxygf2VSUy+T0C6zm7KjgqJQI6xSxaf11xWOY91 +MEKlP+8nkXx1usP2wlgIZ117OQ7PQUq8sx1+DBv8sMBdCoeg7EPsjXoCG+yKsufb/4B k54c8PR95xcmKYVwzWhBrncd/SzjNIIe8zIUE1MJ+n/k4tRCBm+AFYKayk8sVnHcnQ+p 3ZRc6Q5WmfyB2vaHNhkDFUSu89H7N+4Xk99BuadRzfsPKUELtAguErhPABdJhDGjZVtz dpzg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d14-v6si7688779plr.244.2018.07.06.03.13.48; Fri, 06 Jul 2018 03:14:03 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932239AbeGFKMY (ORCPT + 99 others); Fri, 6 Jul 2018 06:12:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55668 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751659AbeGFKMX (ORCPT ); Fri, 6 Jul 2018 06:12:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70BF6401EF2A; Fri, 6 Jul 2018 10:12:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.32.181.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 375CA7C44; Fri, 6 Jul 2018 10:12:21 +0000 (UTC) Message-ID: Subject: Re: [PATCH 1/3] rhashtable: further improve stability of rhashtable_walk From: Paolo Abeni To: NeilBrown , Thomas Graf , Herbert Xu , Tom Herbert Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 06 Jul 2018 12:12:20 +0200 In-Reply-To: <87d0w0y9gg.fsf@notabene.neil.brown.name> References: <153086101070.2825.6850140624411927465.stgit@noble> <153086109256.2825.15329014177598382684.stgit@noble> <0a44916eacea6c3899152a07321ff69d96ed8c52.camel@redhat.com> <87d0w0y9gg.fsf@notabene.neil.brown.name> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 06 Jul 2018 10:12:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 06 Jul 2018 10:12:22 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pabeni@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-07-06 at 19:55 +1000, NeilBrown wrote: > On Fri, Jul 06 2018, Paolo Abeni wrote: > > > Note: the code under test is a pending new patch I'm holding due to the > > above issue, I can send it as RFC to share the code if you think it may > > help. > > I'd suggest post it. I may not get a chance to look at it, but if you > don't post it, then I definitely won't :-) Oks, thanks, I just spammed the list (and you ;) > > > @@ -867,15 +866,39 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter) > > > bool rhlist = ht->rhlist; > > > > > > if (p) { > > > - if (!rhlist || !(list = rcu_dereference(list->next))) { > > > - p = rcu_dereference(p->next); > > > - list = container_of(p, struct rhlist_head, rhead); > > > - } > > > - if (!rht_is_a_nulls(p)) { > > > - iter->skip++; > > > - iter->p = p; > > > - iter->list = list; > > > - return rht_obj(ht, rhlist ? &list->rhead : p); > > > + if (!rhlist && iter->p_is_unsafe) { > > > + /* > > > + * First time next() was called after start(). > > > + * Need to find location of 'p' in the list. > > > + */ > > > + struct rhash_head *p; > > > + > > > + iter->skip = 0; > > > + rht_for_each_rcu(p, iter->walker.tbl, iter->slot) { > > > + iter->skip++; > > > + if (p <= iter->p) > > > + continue; > > > > Out of sheer ignorance, I really don't understand the goal of the above > > conditional ?!? > > I hoped the patch description would cover that: > With this patch: > - a new object is always inserted after the last object with a > smaller address, or at the start. This preserves the property, > important when allowing objects to be removed and re-added, that > an object is never inserted *after* a position that it previously > held in the list. > > The items in each table slot are stored in order of the address of the > item. So to find the first item in a slot that was not before the > previously returned item (iter->p), we step forward while this item is > <= that one. > > Does that help at all? Yes, it's very clear. Before I dumbly skipped some slices of the patch. Thanks, Paolo