Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2771848rdh; Wed, 27 Sep 2023 12:10:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkvrjklBJv7CmAoPgJOqN5/pwLxWKh31QSYTD+FKmcXajXbaYmkV1nwwzJv+zi1IxfddtT X-Received: by 2002:a17:902:d902:b0:1c4:4c10:6ae3 with SMTP id c2-20020a170902d90200b001c44c106ae3mr2499845plz.23.1695841807154; Wed, 27 Sep 2023 12:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695841807; cv=none; d=google.com; s=arc-20160816; b=OeEiaM8Ts/pskp23DSKF2xXmRIzAMYYZ49wvQ+4PxlmG6azke7QMiDtMUhfBHbOjM3 +OApO8OrOCyBk+WlF3ldvyUgB+9WYkqtkzpmc33yzcTKN2WI7Xk1bFMW5cGQ/o6QzFw1 yXK5cYK3TMb43d7TDjNh3Ar3zBJlYcr/DFFcExVulEdynCAU8yAioH+KU2nbfkdt04uA hqskXt1g+Yr92+agfNozfpmfUMwRxZN34sb0st/ahgGUC6b9esRdgN8fFea3I8ChCHFQ 9v1CWYfLrpjNY/rr0yY82IoA3xYJU/fVG9GsspBpadCrLw619Bti0NR3uYg+a0a9YijQ TP4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0B1rH84Q0zQKtWn5iPGBgUbFVQHRp03937YMHNZVgSY=; fh=hE1TuyeYEb91gkx1cK7xzlN5BmHujzq+F+p7GP6SWlw=; b=WhVWm+tFos4J4Cqk2ddHmLKNpUHEoXFst7ig8Zh0DUP3xgeWzZd+gLcrsYezXieb1A MdS852ep1hXBOfEnm/OAL3F7T/C72N5E7Mbsdc3xvQWEjWQDjkqisMLS8BwNCXtjBLLf 1Cr1gE5Vyav1//i6oxhbLdjC/ePctfRkIIoMIqmVysUJMPzD7/jmyTbYXoxMcsMzxbDi eB3XwiRADHOHvuFMHzeOOBn0n870GVAKfXSJzu9yAbQoTQUeMFhtEdfJeU25PIn9sdC4 sY5OKdKW8AysPQg5/ylFn5m5IpIwmj5t4cB+nKsc8ZTRFQAvx4iLxC50HAMYWzkirmKF +sig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vMCoY3KR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id p17-20020a170902e75100b001c32d285db8si17269456plf.308.2023.09.27.12.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:10:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vMCoY3KR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4F6EB8239E87; Wed, 27 Sep 2023 05:34:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231235AbjI0MeT (ORCPT + 99 others); Wed, 27 Sep 2023 08:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjI0MeS (ORCPT ); Wed, 27 Sep 2023 08:34:18 -0400 Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C5BBE6 for ; Wed, 27 Sep 2023 05:34:17 -0700 (PDT) Received: by mail-ua1-x92c.google.com with SMTP id a1e0cc1a2514c-7abcef80a82so2527870241.3 for ; Wed, 27 Sep 2023 05:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695818056; x=1696422856; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0B1rH84Q0zQKtWn5iPGBgUbFVQHRp03937YMHNZVgSY=; b=vMCoY3KRBrgvPse/ihJlS0fvdagCIbeA6GwthYL9ofl81AxT/1GAp3BkRK/wLTzGUP ytLV/cUCpQUU5XU1csJxdxd+GN2shIiiH+l8KutusiW0PyGzSvT8Ky9quFi5rzKpmGGp 9yPy3zNUn1zdktxpxdKby12ELBkpDRaZoNNe+Fe4l/gUTbQM9fqvl5R5pd8rlXSpeO03 9I36hfqYofglaqY/0t/0YY1oIMCeHQhm1J3Bep9ignrBnc26MS+SjeBTBUV0jf/YWa38 Nb/w8JJt2+Z/xMjeF2tz5ivZj/bHc6+aeQ3r17yVqsuW7N6QoifqChqUUgv5G2aH6zIE V/kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695818056; x=1696422856; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0B1rH84Q0zQKtWn5iPGBgUbFVQHRp03937YMHNZVgSY=; b=kFDc5/+OhwJkxXawJyGXTS+WaPa/IjpczwlC1ReHwaUnPjrJRD3Xey/MzOZHAafL1h UN78XlfqbRXOS+bT0s+xxlIhYKNXB6iIX+tnfgMy+DjOwJSOV28D8twD1CSIpnj3NKjU wJ3/dGjXeazeC9ln2VaNX5mjDb0OW6EKMskfvdH6bSz5rJmoOC58bgUuvojv8jIP50Po R1my0rxoBdb4OtfL9CEOLZdSTsjbWGowpMS7t5nyZWXYvTzu+S67eim4je5P0+VuwgJx u6o8d6dNw7kraRWFO4ijnKBlHq/mME84QPaZ+85ubdzhQvCURIXuA3F6WPfG8QUGktwx TPLw== X-Gm-Message-State: AOJu0YxsZCIxAwtqL45MKsTO262SRitlBO7RPw2WMJRlTF3lChuJXGIC DYLSUl2uA4gElKJTLE1anvb0qVq0wmnYE5w4qc9kAg== X-Received: by 2002:a67:ff82:0:b0:452:cfeb:1613 with SMTP id v2-20020a67ff82000000b00452cfeb1613mr1929597vsq.23.1695818056376; Wed, 27 Sep 2023 05:34:16 -0700 (PDT) MIME-Version: 1.0 References: <20230720173956.3674987-1-glider@google.com> <20230720173956.3674987-3-glider@google.com> In-Reply-To: From: Alexander Potapenko Date: Wed, 27 Sep 2023 14:33:35 +0200 Message-ID: Subject: Re: [PATCH v4 2/5] lib/test_bitmap: add tests for bitmap_{set,get}_value() To: Yury Norov Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com, syednwaris@gmail.com, william.gray@linaro.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 05:34:25 -0700 (PDT) On Fri, Sep 22, 2023 at 3:30=E2=80=AFPM Yury Norov w= rote: > > On Fri, Sep 22, 2023 at 09:57:32AM +0200, Alexander Potapenko wrote: > > > > + unsigned long val, bit; > > > > + int i; > > > > + > > > > + /* Setting/getting zero bytes should not crash the kernel. */ > > > > + bitmap_write(NULL, 0, 0, zero_bits); > > > > + val =3D bitmap_read(NULL, 0, zero_bits); > > > > + expect_eq_ulong(0, val); > > > > > > No, val is undefined. > > > > Why? bitmap_read(..., ..., 0) always returns 0. > > Because it's unexpected and most likely wrong to pass 0 bits. We > guarantee that bitmap_read() will return immediately, and will not > touch the memory. But we don't guarantee that we return any specific > value. Fair enough, I'll remove the expect_eq_ulong() from the test in v6 and will also add the requirement for nbits to be nonzero to the doc comments for bitmap_read() and bitmap_write(). > It's not a hot path, at least now, and we can spend few extra cycles > to clear output register and return 0, but user should not rely on it > in any way, especially in a test that is intended to show an example > of using the new API. Ok, for now I'll keep the "return 0" part. > Consider a less relaxed environment, where we really have to count > cycles. In such environment, we'd return a content of the 1st input > argument, just because it's already in R0, and compiled doesn't have > to: > > mov r0, #0 > ret