From patchwork Thu Oct 27 04:38:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 11551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp27071wru; Wed, 26 Oct 2022 21:42:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7gXUyvjGwyfryLJ/Su10aKKLXht0/m51UxG5DPxkNMtar/oxhskpuJXD7Y3Oz/vTgEfQEl X-Received: by 2002:a17:90a:1690:b0:212:f865:4f0e with SMTP id o16-20020a17090a169000b00212f8654f0emr8213857pja.197.1666845774290; Wed, 26 Oct 2022 21:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666845774; cv=none; d=google.com; s=arc-20160816; b=tsVX/3LWkpEGH4stfqxinJEmhKH9TLnCEZWrg86yvcVsw2YodMlcmNaIkqnVBe4KjI QvO7m8td9kVzcSsM1eqtLwNi2gr4mvFJsJvtpix8XRzn5c9HttcrHu6rfZKWpjOpFlKR kQh/gmC3oZ6zJXmtAZAp9pZkswosKgt8P7nOmRIdAk34yzY1+6Bp/xMz5xf5FvHImTpB 2/71Jp3sYk5U8jEBwD9/R+2GTTsB/+ixpX+RZ8vBeS3Y4Et6e/A36C2TA7F5hHi5Ln4j axen8p1DS/8IB1DVg02KB/WzGJzLK3D8hHk4IRMywXPAiGLm5Lx7+KgNjoPQP7QQO1iR fMcw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oAVctpr4Foqzwmq/8lLQnNPWsibHQgV5zVJ+LmSnobA=; b=dTfM/OTSG63bJXr1xHL+MXWUcOuq8EmMTquxzKxZpZbqs2t6IonNeuuENm3QQl3xha 1XFjrt7PFBJcH35iYxTFV5+rhaDStNBpl+WNHcUPWuA9tZhRL0dY6/MjQvrue10jIAfh It6v6lPLG2ytW6BOYQ076lcRpvkZXhdMp35OHaCK0S1uQTFbk1YaPo2YKCQak8qrH1Ie xM9efo613O3mIKAE8+aFhOP+JQY8+21k+l6KW6ZKX3gL4EEJ5oks+BwcK7fqYFO3NoJk UCLe0Qo1u/gkt7aDsGp2Wug0MroH158qAodbj3CoO3QuicbJjP9WBPx6dg7i5Po3RXxM dRUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UuKCjQP8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr7-20020a17090b4b8700b002036f0a953esi638574pjb.88.2022.10.26.21.42.41; Wed, 26 Oct 2022 21:42:54 -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=@gmail.com header.s=20210112 header.b=UuKCjQP8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233974AbiJ0Eia (ORCPT + 99 others); Thu, 27 Oct 2022 00:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbiJ0EiS (ORCPT ); Thu, 27 Oct 2022 00:38:18 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFE714D1CE; Wed, 26 Oct 2022 21:38:18 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id i12so315710qvs.2; Wed, 26 Oct 2022 21:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oAVctpr4Foqzwmq/8lLQnNPWsibHQgV5zVJ+LmSnobA=; b=UuKCjQP8ZW2SctP3nvJFTdHPIXTKXnnE2JToPG+a2xe0a4lwOJgzOjMtrgtjey9okJ o6s21sWcrOnFCLGGiYX1Ud+t8lXJkemF9z2Mj1oAIppGpLhPBdENsIn/7wmu9Ik4Tdpj ZaGFg8S465UtnH7PQWbUfW4AkkSzBa2eWbSAjIzglg6a03Q6TaRv5aSPXX5fE0WHh2A/ +Uou7NuqMw4b2f9WcloBTWC+cyo8ELT2mXUl/YYDO04ihDGDsUHxJyZFLpwi8tvd3uI6 Ho1ui6UrnwdwKC4bV/ungur9LNFFvnLpphxhLxf5R1lQFfREE+i1LS7Y4QLk5oSWKxMz 2CvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oAVctpr4Foqzwmq/8lLQnNPWsibHQgV5zVJ+LmSnobA=; b=6JV8GOqxOHdUJzWh7v7FxoqVPFJpq+Ca6IZlgSz/SkXQ2BlmR23uB6a/E+3ckqEfnC 4D+7Bn5g2kUGiAayeApWOzIA4Tahj7WkKrUYQPrtAMYpVeNt0rySelb6nDiGdbMktRaH pqNdGbnkZQAiw9DbBDRYZ4/l8OlfKiDWr6l/eSlCOUWMeouZb170piibXdNq/fM33wEE JpYnRN6T5ug8zEFUNNQa77xBOnKnglLpPMwV3tS97LhashG9D9lkPr6VMZkSJMuCk92G z5UYzVSMiOW6cHy3g/7ukmcXhYzlEhn3MVk9mwh/1oiNMti1rF11sU5DcCxeYUDbOa84 q5YQ== X-Gm-Message-State: ACrzQf0lF+nMaOxLyQlQ7ieffIFItq59kMffObwiZzw8XhwaAIXm1euG D7H51EpBYBJnNgjl+IWTkH5Y11duJ7U= X-Received: by 2002:a05:6214:21ae:b0:4b4:3c9:71f6 with SMTP id t14-20020a05621421ae00b004b403c971f6mr39868870qvc.17.1666845496972; Wed, 26 Oct 2022 21:38:16 -0700 (PDT) Received: from localhost ([2601:589:4102:7400:ade5:9c32:44f6:bc7d]) by smtp.gmail.com with ESMTPSA id q68-20020a378e47000000b006b929a56a2bsm358504qkd.3.2022.10.26.21.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 21:38:16 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Arnd Bergmann , Andy Shevchenko , Rasmus Villemoes Cc: Yury Norov Subject: [PATCH 3/3] bitmap: add tests for find_next_bit() Date: Wed, 26 Oct 2022 21:38:10 -0700 Message-Id: <20221027043810.350460-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027043810.350460-1-yury.norov@gmail.com> References: <20221027043810.350460-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1747814474649472309?= X-GMAIL-MSGID: =?utf-8?q?1747814474649472309?= Test out-of-line and inline paths of find_next_bit(). Signed-off-by: Yury Norov --- lib/test_bitmap.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index a8005ad3bd58..becf9c7a95a1 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -221,7 +221,7 @@ static void __init test_zero_clear(void) expect_eq_pbl("", bmap, 1024); } -static void __init test_find_nth_bit(void) +static void __init test_find_bit(void) { unsigned long b, bit, cnt = 0; DECLARE_BITMAP(bmap, 64 * 3); @@ -236,6 +236,25 @@ static void __init test_find_nth_bit(void) __set_bit(80, bmap); __set_bit(123, bmap); + expect_eq_uint(10, find_next_bit(bmap, 64 * 3, 0)); + expect_eq_uint(20, find_next_bit(bmap, 64 * 3, 11)); + expect_eq_uint(30, find_next_bit(bmap, 64 * 3, 21)); + expect_eq_uint(40, find_next_bit(bmap, 64 * 3, 31)); + expect_eq_uint(50, find_next_bit(bmap, 64 * 3, 41)); + expect_eq_uint(60, find_next_bit(bmap, 64 * 3, 51)); + expect_eq_uint(80, find_next_bit(bmap, 64 * 3, 61)); + expect_eq_uint(123, find_next_bit(bmap, 64 * 3, 81)); + + /* Test small_const_nbits_off() optimization path */ + expect_eq_uint(10, find_next_bit(bmap, 20 + 0, 0)); + expect_eq_uint(20, find_next_bit(bmap, 20 + 11, 11)); + expect_eq_uint(30, find_next_bit(bmap, 20 + 21, 21)); + expect_eq_uint(40, find_next_bit(bmap, 20 + 31, 31)); + expect_eq_uint(50, find_next_bit(bmap, 20 + 41, 41)); + expect_eq_uint(60, find_next_bit(bmap, 20 + 51, 51)); + expect_eq_uint(80, find_next_bit(bmap, 20 + 61, 61)); + expect_eq_uint(90, find_next_bit(bmap, 20 + 70, 81)); + expect_eq_uint(10, find_nth_bit(bmap, 64 * 3, 0)); expect_eq_uint(20, find_nth_bit(bmap, 64 * 3, 1)); expect_eq_uint(30, find_nth_bit(bmap, 64 * 3, 2)); @@ -1226,7 +1245,7 @@ static void __init selftest(void) test_bitmap_print_buf(); test_bitmap_const_eval(); - test_find_nth_bit(); + test_find_bit(); test_for_each_set_bit(); test_for_each_set_bit_from(); test_for_each_clear_bit();