From patchwork Tue Apr 25 13:56:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cai Huoqing X-Patchwork-Id: 87423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3441642vqo; Tue, 25 Apr 2023 07:21:19 -0700 (PDT) X-Google-Smtp-Source: AKy350bD4lGkrScai7XWl3ybHiZ4TBZQW3iJD7Y6wUmTTBxAeUtAgRIW76SRGoCT2J3kHsLEynqm X-Received: by 2002:a17:90a:788c:b0:247:a22d:2a41 with SMTP id x12-20020a17090a788c00b00247a22d2a41mr16727317pjk.13.1682432478822; Tue, 25 Apr 2023 07:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682432478; cv=none; d=google.com; s=arc-20160816; b=LQgxcQqDkHyaKIp/w1lJEIxgXxOP+zE3fE0gGWfxAOSxjEyBo9RYW5kFh6xt/Vkyzg LaOvrmFFWZxT0kLizBbD2gP1BSjL+1KJTpdCFD6gfJspXa6R8rSoek6vdSGkg1YbSce+ +zpLQv21+JypefFVDZvxbVxYE5Qr4OaUr9s2NW4A62I/jaC7k3rIyKjSqsw3zs6c9id5 ouAI9BjaDNV79Yct/IbXRXR/wsFcfhygNUUT6SvHG5YKmPvvKM22Ttj0a0tlkDE2IPtD 6aKczGyluAOj9qxCgr6n1769XM7eown0BURzz7Th+dg+tOjADNx7k+fD4YMvzFd3eG4x biqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MXXnD2d1ao8j3z+jt3We3HNASn17nNtDEHjg8zEIU58=; b=EGbRoa5l/E8huKGFZWv3wy8sVWj98N/tPKmHQTEYtAqimomhXfWcD+re+ow0JoFovZ xMpGT5YqH0CEkxiYvRhG8XYVuJ+KDzxXI0uWF4CH0JNd2o09AvI2q1T96u1GDHe5falF V33yezHg/RPRwgXHybEoyXZnw7K6g0OijislbduV0xPeOPRP7sliNRTyGoi4mjwA8pqt /u5FL3d9jnDc9OvtR1sAQCK4v+6+6Qw0an39TzcM0+Mn4i5o9hnUT3WpLIga+3Czcd6n Xj60MVzK+mffB/9USBxZQ8pGivfKhaYF71Xswt2CyTjiMyBdSV0De6E/aN7PHrb097Mw nfJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VIYntA31; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe2-20020a17090b4f8200b00246d179dc81si15027394pjb.126.2023.04.25.07.21.06; Tue, 25 Apr 2023 07:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VIYntA31; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233834AbjDYN40 (ORCPT + 99 others); Tue, 25 Apr 2023 09:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234295AbjDYN4Z (ORCPT ); Tue, 25 Apr 2023 09:56:25 -0400 Received: from out-12.mta0.migadu.com (out-12.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83AFC184 for ; Tue, 25 Apr 2023 06:56:23 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1682430981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MXXnD2d1ao8j3z+jt3We3HNASn17nNtDEHjg8zEIU58=; b=VIYntA31qStvzu9yKLkptRR+NPY9JoT20ZO5Af0QoE3zOuPy+7U1PVPE148kSUV5ydeUyF pJzkPFBg/je4cjE3oIGnB1rDrpUqDJmXNsERc7nrTPLfsEUfPXCF+4bcVy6S+otpSR7Lg7 Tx6ynPPmuNtg0YY1f+UiSvKbQxNjjKc= From: Cai Huoqing To: cai.huoqing@linux.dev Cc: Thomas Graf , Herbert Xu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rhashtable-test: Make use of rhashtable_walk_peek Date: Tue, 25 Apr 2023 21:56:17 +0800 Message-Id: <20230425135617.77907-1-cai.huoqing@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, TO_EQ_FM_DIRECT_MX,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764158319297637276?= X-GMAIL-MSGID: =?utf-8?q?1764158319297637276?= Add an example usage of rhashtable_walk_peek to test_bucket_stats. Signed-off-by: Cai Huoqing --- lib/test_rhashtable.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c index c20f6cb4bf55..b1c3316b9bde 100644 --- a/lib/test_rhashtable.c +++ b/lib/test_rhashtable.c @@ -177,6 +177,7 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries) unsigned int total = 0, chain_len = 0; struct rhashtable_iter hti; struct rhash_head *pos; + struct test_obj *obj; rhashtable_walk_enter(ht, &hti); rhashtable_walk_start(&hti); @@ -192,6 +193,13 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries) break; } + /* Here's an example usage of rhashtable_walk_peek */ + obj = rhashtable_walk_peek(&hti); + if (!obj) { + pr_warn("Test failed: rhashtable_walk_peek() error\n"); + break; + } + total++; }