From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C6ABE6FE2C for ; Fri, 22 Sep 2023 13:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/CPB/K7mvDZyfBmU6gP88Psc3UOUF6HAkZGUKk6b/tY=; b=BEy83BFkSlmhAO /xZfXDMQcQ55lthPdVBqEadQrMd6ieBZ0ROFZx5n7bxHWM4TRPGzOh4X5AI1PMWM4/fR1jb/CgwHH Db8siTiHm23AIb6jo6t8ocxea5Q5WbLsDb1ifILBCnY9BlCW3m8iuZe6ENFQ+f5VXBKBDyv89oEYK 85oa3oMdy+O2mylt7F+4FJ0NadWeVU+Rw5oNoJFPI+lM6hpEF9+qEcdvQ7E7TiOm13DkOTtWiLLo0 iyJMoKMcVRdFYr8SC088N+xUy7gDhmPx96vsLiJfRep3g/FBMbl0KJxbkA9QsvcIi2uIU7/3/1J2s btEs1X1BPo31ctPrg2XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjgEt-0097T5-0o; Fri, 22 Sep 2023 13:30:35 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjgEq-0097Sa-0q for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 13:30:33 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-690d8c05784so1683858b3a.2 for ; Fri, 22 Sep 2023 06:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695389429; x=1695994229; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yEXXxtAaC4ky8k28Oo7NrqKscKudBPHppqHeDnkzTvg=; b=bYfC0n6p3Qimsvcs3bT6+1rsZ/NOLlKdeDCj+pabMith9z/2AK1J4D0SGTzHUKy00F eQTyrrFN9T1l00VccPN3rYOR6SVFPAm1jRGmOvR9/iEiOLBiL37H7WfvWhZI5Yn5WKDU c2we9v1BRkLJlfSZYNzJbxdMk/VFFa7Kjo5rQLUYsyklTk/dbWSWZ47PQkeb1FPuhU0O IpbK1lOChdJ+nChMQMs50oIp4G5Ck2mUFbm75BNjB3k113ugzizpsCHqstHxbvjqJjdf hCxLZu0rmiVbH/ykKBD+pRmckCfEZfKTSQ1br4qezemymCBM8OrSTuKxPbghsNzVjue4 GwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695389429; x=1695994229; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yEXXxtAaC4ky8k28Oo7NrqKscKudBPHppqHeDnkzTvg=; b=VzEmgVHNnDR5aqh7ypo3UbD54f6+uQSimr6JyoyySFsIsjh+LwQ5shediP2sTbwpXE U4XuQKCBeBzVuhjHeQUvPH4nY5e1Py+QeMVpQn/ylJY5DTfKPwjms4MPsUXY3+j7Xcc2 upw0DAJjh9gwNigMzCyzYHzpkwqUqH7wf4hU1qYPBr8ecMADe7x4NpSKVCzYLMt3vqVk rBqgnStWcK6eiD8NpD15ke9ufOikXqSIuHpvdmW3foRHlvv+FMTDpqLTmOGGbpDpyY+w Fra5q6+S7ZS3Rf9MeD6YECyiuKTGHFfwZf1xRIvQ84LgyPCDMcAx7rLOWQIY0ralDXkm n0Uw== X-Gm-Message-State: AOJu0YzG2bV9c/8hHpJvghvF4u6LdADLigiMIf6GkVGK7M4UAFX+IwMR RGEPOJkpOH9VdIcjP0AcBARXy5DoF8U= X-Google-Smtp-Source: AGHT+IFcUTc5fw6pAkQV0oegpKWkDcHaEnc5xW/PawogxBs/JPnE+nt1X9Qi+rnPHNtesftRYd4lFA== X-Received: by 2002:a05:6a20:428e:b0:15a:478f:9f2e with SMTP id o14-20020a056a20428e00b0015a478f9f2emr9656017pzj.1.1695389428733; Fri, 22 Sep 2023 06:30:28 -0700 (PDT) Received: from localhost ([216.228.127.130]) by smtp.gmail.com with ESMTPSA id j21-20020a62e915000000b00686bef984e2sm3148424pfh.80.2023.09.22.06.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:30:28 -0700 (PDT) Date: Fri, 22 Sep 2023 06:28:14 -0700 From: Yury Norov To: Alexander Potapenko 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 Subject: Re: [PATCH v4 2/5] lib/test_bitmap: add tests for bitmap_{set,get}_value() Message-ID: References: <20230720173956.3674987-1-glider@google.com> <20230720173956.3674987-3-glider@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_063032_320410_7DCD054D X-CRM114-Status: GOOD ( 15.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 = 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. 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. 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel