Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3327702rdh; Thu, 28 Sep 2023 08:35:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeYj16zE3ta3jxyaSBkBSdvVL2WYJh+FFbbA36lCAAF/CxKlgPIJpvCARM8OKb2Igu/txk X-Received: by 2002:a05:6a00:b95:b0:693:479f:bd1c with SMTP id g21-20020a056a000b9500b00693479fbd1cmr3052611pfj.1.1695915338072; Thu, 28 Sep 2023 08:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695915338; cv=none; d=google.com; s=arc-20160816; b=VORPw5nVteogIYJilDM26jB2zd6gX3xewqVPer0uVZLgcEVKChm3OpNp43/iqrYXNs Om+Ta3i+JMh/m9aTMUtku4vkyypQ26fZugk7CKB4/THT/R+ORJshAaaglZWCQj8mg+ZF IYoZ1/ZBysjV4Euwesq/eN5O1cMZ3B1k+hDnQGfahZfPXxnPEABuKxXRFpmms5juoPeS p32PgRsn/nml3idA+5xy96RhWGzPjq/au1wSpRHyNULlKkOWFcnzqknimYByuUMTZSMh 2v94BhosbCifKAIBCl/q6n7usEp+1k4BqkuP9C20t4ig7DM7i7B7RRVS2B37knGf+Wul f4ww== 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=mOEFHJN8GV3YDZ8D45YRrX0IKDksNN0ayNy/fn6AF3U=; fh=Cyei342aNVkq7om5pPCjrlL1pextULjwZncrQxg6/+w=; b=QeaiOKImgJJOtDGesTmF076cviR4jmK8AoiBr3qzbiCRl7foLoFSYxqQdfTGNLQP7V vLOgblY0c+aMejoVEka0kJUP+b1hw3Vi4Uz0prizLAy7tJBkqDuAlAx+0TLvaT24DBPN m2Fy+4QW16p8VYNPO/d9hT6OVNKjymNj5r72f0a4VIpxmpwmcMD9kICaMV8tR8ylnePs 7144hoTrQLoBAhv+3Hf/NbimhX09J/6H+kF9ZDOHxoj3VXoLVBldld0xJyJqaL4Upye2 TOO9tjnYIsDRp5sxnBlK0CDVogM054/+4lYgScFVdznVd+m181MIQAm+YQG/j91eOzPk OZHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4pSTNfyc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t185-20020a6381c2000000b00563de35d397si18400764pgd.487.2023.09.28.08.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 08:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4pSTNfyc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 6524E807C6FD; Thu, 28 Sep 2023 07:20:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232186AbjI1OUk (ORCPT + 99 others); Thu, 28 Sep 2023 10:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbjI1OUi (ORCPT ); Thu, 28 Sep 2023 10:20:38 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76370F5 for ; Thu, 28 Sep 2023 07:20:37 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-77574c2cffdso143051285a.0 for ; Thu, 28 Sep 2023 07:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695910836; x=1696515636; 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=mOEFHJN8GV3YDZ8D45YRrX0IKDksNN0ayNy/fn6AF3U=; b=4pSTNfycYV379eqYLPfTP+xP077NADXi8g5EW3ZMevAaGOPWT5I2kWC+uYye7/PJiT Y+NM/9r6RPHph1Ya1aUNLXhchFPDKvQadeaHASykHBTXUPSgTVC8ZOClthdH/cBtNrNr wtlj6njUBjwLE+lrxtLl4UZCmCWoEL1oo+pxkus0WomgV7IQu5e9w/EXvxMvaYMv9tJi MHzcuJkXnQxIQIe2KU10lNjFn/781chm9NByw3wLpBi6w08EIBe2o+yYCWCqJcJxw7n1 olrD387gSSIB7LAalsSnFWsuAe4mb6voxiJkd1RkMNg1PcPB1nd/gjUQNl2Lf6KXYrZ+ RRAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695910836; x=1696515636; 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=mOEFHJN8GV3YDZ8D45YRrX0IKDksNN0ayNy/fn6AF3U=; b=guOfUwEpBs9TEt3gZV1iA9L57GGYRZwAaj/l/7Hgm4r47js1NeAvjmfO4pr78PSOPs rheHEEqqdWnIAsKDjSg1Ezf//H8BTRuLF6V9PrQ62cIuRCfz6P6/6XM8tTRJaO9Q8GUy qRDQ2jFWoxg050vxRxiHNT3cl6kvy9r74xRWOMAliMfvVPbBQjAQrcON7SBH7nIRjPrK 629Nlqdy91FpgEd3P/XIKLR6aOgX7POJL1+8xhvQMaLYNDkT0OWlHGiNz0hV1poLMLhl yMzYTltwx39R4OwPxIcub02DZjiccn66upp6MM6GquG7ZyOkGeK8/kQZzl0rAXkrCDlI jR1w== X-Gm-Message-State: AOJu0YyJm5INfAcO6Q6YvUHPqEbFz2vGmGAMQebf41LU5hOTPXXfeyOr 2LBemSgSc7XDOCuMWfQ1yLnbk1orlvu14OXjEaEDcA== X-Received: by 2002:a05:620a:4081:b0:774:3933:1f2c with SMTP id f1-20020a05620a408100b0077439331f2cmr1411409qko.22.1695910836443; Thu, 28 Sep 2023 07:20:36 -0700 (PDT) MIME-Version: 1.0 References: <20230922080848.1261487-1-glider@google.com> <20230922080848.1261487-3-glider@google.com> <3bc8fda47dc04e3b8cfd0e3f6fc7bbee@AcuMS.aculab.com> In-Reply-To: <3bc8fda47dc04e3b8cfd0e3f6fc7bbee@AcuMS.aculab.com> From: Alexander Potapenko Date: Thu, 28 Sep 2023 16:19:56 +0200 Message-ID: Subject: Re: [PATCH v5 2/5] lib/test_bitmap: add tests for bitmap_{read,write}() To: David Laight Cc: Andy Shevchenko , "catalin.marinas@arm.com" , "will@kernel.org" , "pcc@google.com" , "andreyknvl@gmail.com" , "linux@rasmusvillemoes.dk" , "yury.norov@gmail.com" , "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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 28 Sep 2023 07:20:52 -0700 (PDT) On Wed, Sep 27, 2023 at 9:51=E2=80=AFAM David Laight wrote: > > ... > > Overall, unless allocating and initializing bitmaps with size > > divisible by sizeof(long), most of bitmap.c is undefined behavior, so > > I don't think it makes much sense to specifically test this case here > > (given that we do not extend bitmap_equal() in the patch set). > > Bitmaps are arrays of unsigned long. > Using any of the APIs on anything else is a bug. > So it is always wrong to try to initialise 'a number of bytes'. > The size used in the definition need not be a multiple of 8 (on 64bit) > but the allocated data is always a multiple of 8. > > Any calls to the functions that have a cast of the bitmap > parameter are likely to be buggy. > And yes, there are loads of them, and many are buggy. I got rid of the casts in the bitmap test, but they remain in mtecomp.c, where 16-, 32-, 64-byte buffers allocated by kmem_cache_alloc() are treated as bitmaps: https://lore.kernel.org/linux-arm-kernel/20230922080848.1261487-6-glider@go= ogle.com/T/#mdb0d636d2d357f8ffe6ac79cef1145df3440f659 Having them allocated by bitmap_alloc() won't work, because on Android bitmap_alloc() will allocate the buffers from the kmalloc-64 cache, defeating the purpose of the compression. Would it be better to extend the bitmap.h API so that it is possible to allocate from a kmem cache (which would in turn require bitmap_kmem_cache_create() to ensure the alignment requirements)? > On LE you mostly get away with shorter memory allocations. > But still get errors when trying to do locked operations > on misaligned addresses. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1= 1PT, UK > Registration No: 1397386 (Wales) -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg