Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1720173pxb; Thu, 28 Oct 2021 08:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy24rWdN6NGX8Uzwi1QVvIsbr9Um4275HRxErVEHIJbfnt7gpaX78wHV1loqXimoLTRVKO X-Received: by 2002:a17:902:b94a:b0:141:8454:d665 with SMTP id h10-20020a170902b94a00b001418454d665mr4462521pls.88.1635436266834; Thu, 28 Oct 2021 08:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635436266; cv=none; d=google.com; s=arc-20160816; b=sVTEzplmVf2XhSy0d3pS2RAmuhdfy93SkYv7yWNT65hhuK8X3beSEf1MGOh1VRnuAF 9Wuh2ddtHfDd5vqVocTc/JCwVS5YJQ7pRwGXiNOuswFxal+jf/I5p3ns75qoZSi52eb4 RLXy5T86pwEzsjh+6NAiXJkiMRNygTUSpv2wnBpFMWJH6zxozNO4JWJ5Yc6NfO7diSeo QJl4EKAMwJMs+1YoV4Nn1u1TqBWQbRNGf4grefyiE4Wt4IheOegAHClIOg7DktDEHPsa ig1p1EYypXMU9TD8Y9fptUyx4XTYfhpXJIHcgSh81781wqN3x7ULVWsawArzhrcNMbm3 yfTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zbZ9TZiWVecEQFiE8v0DssKnTP5W+NVcms/8fiOavLY=; b=1GakpAREFbNMgGKYBzXWC3UdDYA/CMb3p40tjS+nCgymkD7MmVspAMBvgGBMqf1f7t xZkqHeJ05Zy7/1N6tMZJsbiehGj6/zToQIdoEhc0yQ7b9bSD8q2KfYNq4XMCz6VQuuo1 tH+NO79iK2O34MGlJqX/lLCWIZl2ES0J0x6dY6T2sjmQZXhzqz3IzA6Uu34JdG4inWCH 1pnWHb+iCqYerE2OV2n6EK1VeX/fOG0m5Kr0Lm355i0LZR0Ce0eevb5CjSpfULQg0b69 mitKaatK0JqhSn+EWH3yaNRoNug6TeljtKczJh6ySgnawQa3Jp2nHeOU6ASk5v/Zc4cV HX9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=IL+vSHwi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j25si3909210pfr.374.2021.10.28.08.50.50; Thu, 28 Oct 2021 08:51:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=IL+vSHwi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbhJ1PvG (ORCPT + 99 others); Thu, 28 Oct 2021 11:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbhJ1PvG (ORCPT ); Thu, 28 Oct 2021 11:51:06 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F06C061570 for ; Thu, 28 Oct 2021 08:48:38 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id g8so26965997edb.2 for ; Thu, 28 Oct 2021 08:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zbZ9TZiWVecEQFiE8v0DssKnTP5W+NVcms/8fiOavLY=; b=IL+vSHwit3FV6PaMoc8v9POwLt+FCZzBEedybH5B42uCW5WDwt689x4g/UywfEgpvt k7Nu4Rzg3vlI1y82D/ACednq26m+YAepiVRc5TYaieaarxW7zfy6/VqwlleaL0J6k6xW YQpP/7t++vw+oJz94ANpMCaroaJ+qhQuYuezemuSaDD7NMga8XPK0Qxj7cVNzOtCqgBi MTU3eZJLAdHB4bEzRZAx7aGROcd8yhtOR2CUFqSeHKhj3tIkSlEHBwwfydcXZ6e4pbCA 6RlcRoJ1WalAI1RNzk+xnduYU/eUYa5k/iWfoLyJrqB0it6c7hF9v7NWXKEW4sBN5wHT D++g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zbZ9TZiWVecEQFiE8v0DssKnTP5W+NVcms/8fiOavLY=; b=piHdjgr5ZAKukgdOdmrLwt7CgMsyBJIr+Ii7Y89ZqgssYAHlCxihNIzQBNh5jijJEG U3ucf8ESe4WH4/soR7JBD99gPOmU3B86djwQIaN38oK/zZe1uXxw2YAvhWTRIanYGQDn KSAqP3GGT51NReulLdeb7+DKScd1o7aZpKjCYNAPdicCObF7053QsI0okuyKfyz5BTic Vok+JU1ezOgXkB97Guo7yKeM1DnvRNwF4a6NFAyIP7+zo7E0vspB3YPzOt6Nrw4Glyu/ zWerCk1eU+IvEZag2gOfoJ9WxpudTomNpH9VhI7ECilFnNoZ1L5ffNZSd/7IRzaHEUq5 YujA== X-Gm-Message-State: AOAM5316Z8qRvzM7K2MY8UGe6EOQrRsXHdRa9Xdl+gBINUinBW0UY9Yc y20mCNF9FUppMtS4k2Dhx3dWaWQdDZ5mvEDJ4E2N3g== X-Received: by 2002:aa7:cac2:: with SMTP id l2mr7153749edt.168.1635436117146; Thu, 28 Oct 2021 08:48:37 -0700 (PDT) MIME-Version: 1.0 References: <20210926223322.848641-1-isabellabdoamaral@usp.br> <20210926223322.848641-3-isabellabdoamaral@usp.br> In-Reply-To: From: Isabella B do Amaral Date: Thu, 28 Oct 2021 12:48:26 -0300 Message-ID: Subject: Re: [PATCH v2 2/5] test_hash.c: split test_int_hash into arch-specific functions To: David Gow Cc: Geert Uytterhoeven , Enzo Ferreira , =?UTF-8?Q?Augusto_Dur=C3=A3es_Camargo?= , Brendan Higgins , Daniel Latypov , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Kernel Mailing List , KUnit Development , ~lkcamp/patches@lists.sr.ht, Rodrigo Siqueira Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 2, 2021 at 4:20 AM David Gow wrote: > > On Mon, Sep 27, 2021 at 6:33 AM Isabella Basso wrote: > > > > Split the test_int_hash function to keep its mainloop separate from > > arch-specific chunks, which are only compiled as needed. This aims at > > improving readability. > > > > Tested-by: David Gow > > Signed-off-by: Isabella Basso > > --- > > This looks good to me. It's possibly worth fixing up the changelog > mixup between this and patch 3 if you send out a v3. > > A minor suggestion re: commenting below, otherwise this is: > > Reviewed-by: David Gow > > -- David > > > lib/test_hash.c | 86 ++++++++++++++++++++++++++++++++----------------- > > 1 file changed, 57 insertions(+), 29 deletions(-) > > > > diff --git a/lib/test_hash.c b/lib/test_hash.c > > index d4b0cfdb0377..08fe63776c4f 100644 > > --- a/lib/test_hash.c > > +++ b/lib/test_hash.c > > @@ -56,6 +56,53 @@ fill_buf(char *buf, size_t len, u32 seed) > > } > > } > > > > +/* Holds most testing variables for the int test */ > > It might be worth commenting what these variables actually are here, > as it's pretty confusing on a quick read through. > > Maybe something like: > > > +struct test_hash_params { > > + unsigned long long *h64; > > /* Pointer to integer to be hashed. */ > > > + u32 h0; > > /* Low 32-bits of integer to be hashed. */ > > > + u32 h1; > > /* Arch-specific hash result. */ > > > + u32 h2; > > /* Generic hash result. */ > > > + u32 (*hash_or)[33]; > > /* ORed hashes of given size (in bits) */ > Those comments look pretty sensible to me! I think I'll stick with them :) Thanks, -- Isabella Basso > > > +}; > > + > > +#ifdef HAVE_ARCH__HASH_32 > > +static bool __init > > +test_int__hash_32(struct test_hash_params *params) > > +{ > > + params->hash_or[1][0] |= params->h2 = __hash_32_generic(params->h0); > > +#if HAVE_ARCH__HASH_32 == 1 > > + if (params->h1 != params->h2) { > > + pr_err("__hash_32(%#x) = %#x != __hash_32_generic() = %#x", > > + params->h0, params->h1, params->h2); > > + return false; > > + } > > +#endif > > + return true; > > +} > > +#endif > > + > > +#ifdef HAVE_ARCH_HASH_64 > > +static bool __init > > +test_int_hash_64(struct test_hash_params *params, u32 const *m, int *k) > > +{ > > + params->h2 = hash_64_generic(*params->h64, *k); > > +#if HAVE_ARCH_HASH_64 == 1 > > + if (params->h1 != params->h2) { > > + pr_err("hash_64(%#llx, %d) = %#x != hash_64_generic() = %#x", > > + *params->h64, *k, params->h1, params->h2); > > + return false; > > + } > > +#else > > + if (params->h2 > *m) { > > + pr_err("hash_64_generic(%#llx, %d) = %#x > %#x", > > + *params->h64, *k, params->h1, *m); > > + return false; > > + } > > +#endif > > + return true; > > +} > > +#endif > > + > > /* > > * Test the various integer hash functions. h64 (or its low-order bits) > > * is the integer to hash. hash_or accumulates the OR of the hash values, > > @@ -69,19 +116,13 @@ static bool __init > > test_int_hash(unsigned long long h64, u32 hash_or[2][33]) > > { > > int k; > > - u32 h0 = (u32)h64, h1, h2; > > + struct test_hash_params params = { &h64, (u32)h64, 0, 0, hash_or }; > > > > /* Test __hash32 */ > > - hash_or[0][0] |= h1 = __hash_32(h0); > > + hash_or[0][0] |= params.h1 = __hash_32(params.h0); > > #ifdef HAVE_ARCH__HASH_32 > > - hash_or[1][0] |= h2 = __hash_32_generic(h0); > > -#if HAVE_ARCH__HASH_32 == 1 > > - if (h1 != h2) { > > - pr_err("__hash_32(%#x) = %#x != __hash_32_generic() = %#x", > > - h0, h1, h2); > > + if (!test_int__hash_32(¶ms)) > > return false; > > - } > > -#endif > > #endif > > > > /* Test k = 1..32 bits */ > > @@ -89,37 +130,24 @@ test_int_hash(unsigned long long h64, u32 hash_or[2][33]) > > u32 const m = ((u32)2 << (k-1)) - 1; /* Low k bits set */ > > > > /* Test hash_32 */ > > - hash_or[0][k] |= h1 = hash_32(h0, k); > > - if (h1 > m) { > > - pr_err("hash_32(%#x, %d) = %#x > %#x", h0, k, h1, m); > > + hash_or[0][k] |= params.h1 = hash_32(params.h0, k); > > + if (params.h1 > m) { > > + pr_err("hash_32(%#x, %d) = %#x > %#x", params.h0, k, params.h1, m); > > return false; > > } > > > > /* Test hash_64 */ > > - hash_or[1][k] |= h1 = hash_64(h64, k); > > - if (h1 > m) { > > - pr_err("hash_64(%#llx, %d) = %#x > %#x", h64, k, h1, m); > > + hash_or[1][k] |= params.h1 = hash_64(h64, k); > > + if (params.h1 > m) { > > + pr_err("hash_64(%#llx, %d) = %#x > %#x", h64, k, params.h1, m); > > return false; > > } > > #ifdef HAVE_ARCH_HASH_64 > > - h2 = hash_64_generic(h64, k); > > -#if HAVE_ARCH_HASH_64 == 1 > > - if (h1 != h2) { > > - pr_err("hash_64(%#llx, %d) = %#x != hash_64_generic() " > > - "= %#x", h64, k, h1, h2); > > + if (!test_int_hash_64(¶ms, &m, &k)) > > return false; > > - } > > -#else > > - if (h2 > m) { > > - pr_err("hash_64_generic(%#llx, %d) = %#x > %#x", > > - h64, k, h1, m); > > - return false; > > - } > > -#endif > > #endif > > } > > > > - (void)h2; /* Suppress unused variable warning */ > > return true; > > } > > > > -- > > 2.33.0 > >