Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1278219ybg; Thu, 4 Jun 2020 05:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5v0ARvFGM+JIslVnPXr7uuwLB+lJt43fuwH6qpyrogw63KH9WqY4jtV2e3IcoxjwGDeQn X-Received: by 2002:aa7:ce93:: with SMTP id y19mr2433119edv.50.1591275278706; Thu, 04 Jun 2020 05:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591275278; cv=none; d=google.com; s=arc-20160816; b=JZ9znM0yrzfCYCmHCdRhWo8BSbOQKwh3iT3oUJltKsXIh8+DTNEAq17SKen9DGzko6 K9b4MwWW82kuqDwkOyE3oN4QZuBHuWEwhpjQjE7Y0pqRrbI3oopXgDFR+4JOQzFAG35n m2O3ZqGJBTXiXBlkbDRUHPZovgVi8H1u/BjLYpjglrvDwB8yuA0o7RR8i6cBezHGfBEn n9GI1z+QWSlK4bkdvwrc4sURTTav99xdMucPH/aEzqB4ORgZR0MuLX/tJsA2VTwrnnNm hty7NuKShPwBzHtKJ4qvztxuKIm9gpb76XzguSmtGcQYwJLpoyEOR6WczKhJEtD6JlNb Mz6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ZN38JmrN8vqGz8+PUtDOXoeKLTv7lNfegH7QoQuS+Cg=; b=qvxc6HUeJJn5CwUu32Wa70qbOcSRYX+qu76J6FJx+MQTcDY9ysQVE/gnpGmz1Kw//+ JsGHbMMbYVmeuOGNpuFqZweM56Mv0VXT8v89MuOjfjQa7LkGPKr7iCfKMHgWHokBEh1/ pVTw20tqiVrJrfGLAo7DKDlk3pR4oFa7/pYk9bIv7RiTF6exNOHSEll3tHW/Ak/2Pk4/ X2knFGM4xE0PxTkx1YwTGCgnrD++y2cWwiBgFGiW9oNGOblKaEUj22r9OfM8Id1Ezqkg GwUCht1piuEDGKnxRMJga67NRNGkMZmTalr908RreD+ePwWIMeaxmHrSYtJU14vrev6C A9aQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si1692704edr.297.2020.06.04.05.54.15; Thu, 04 Jun 2020 05:54:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgFDMvx (ORCPT + 99 others); Thu, 4 Jun 2020 08:51:53 -0400 Received: from mail-oo1-f68.google.com ([209.85.161.68]:34872 "EHLO mail-oo1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgFDMvx (ORCPT ); Thu, 4 Jun 2020 08:51:53 -0400 Received: by mail-oo1-f68.google.com with SMTP id e12so1216539oou.2 for ; Thu, 04 Jun 2020 05:51:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZN38JmrN8vqGz8+PUtDOXoeKLTv7lNfegH7QoQuS+Cg=; b=DUAKQqVw43qLIxB2578m07C5zwQwHR7OQGrWkOrdDZuAsXRgGTPWl4ireGic1IYrTZ 7XbW9VGs7bf93NW5ywrqHSkL6QDyxltJvTmYMNiJc7CY5RNRVDUJAhtwJTf68lzw7VME 01SDeQ6d1WNssu1OdpTPvzqKl9NPsM8UjFWDLRS4fKVxdZU6Dvss+XPlho7pv82N3cI2 mjUTwW48WZjBhkBfqP3LTCWS4a2ArDQIzWlQMPM6nX651LI2mz+V7gqv43wgORQMBIiV 8j7vdjYjaj4kR5UIJzLkGRv8/DhQW/eJkVStNKic7gHPpi/VJ4A4AV9Z8rBAucPrsY9l UAvA== X-Gm-Message-State: AOAM530tMnutF3tuck0SxqHk+3bcbOyfzhzXON+SPx3mE6UMX8V1coeR Ay1RuOzYYwsnYJqr5zaSzTifDfdbAkvG12uFAgQ= X-Received: by 2002:a4a:95d0:: with SMTP id p16mr3638116ooi.40.1591275112310; Thu, 04 Jun 2020 05:51:52 -0700 (PDT) MIME-Version: 1.0 References: <20200602223728.32722-1-richard.weiyang@gmail.com> <20200604122805.d2ndjmkmti6wl3nz@master> In-Reply-To: <20200604122805.d2ndjmkmti6wl3nz@master> From: Geert Uytterhoeven Date: Thu, 4 Jun 2020 14:51:40 +0200 Message-ID: Subject: Re: [Patch v2] lib: test get_count_order/long in test_bitops.c To: Wei Yang Cc: Andrew Morton , Andy Shevchenko , Christian Brauner , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wei, On Thu, Jun 4, 2020 at 2:28 PM Wei Yang wrote: > On Thu, Jun 04, 2020 at 01:50:13PM +0200, Geert Uytterhoeven wrote: > >On Wed, Jun 3, 2020 at 1:11 AM Wei Yang wrote: > >> Add some test for get_count_order/long in test_bitops.c. > >> > >> Signed-off-by: Wei Yang > > > >Thanks for your patch, which is now commit 7851d6639caeea40 ("lib: > >test get_count_order/long in test_bitops.c") in linux-next. > > > >> --- a/lib/test_bitops.c > >> +++ b/lib/test_bitops.c > > > >> @@ -24,6 +28,26 @@ enum bitops_fun { > >> > >> static DECLARE_BITMAP(g_bitmap, BITOPS_LENGTH); > >> > >> +unsigned int order_comb[][2] = { > >> + {0x00000003, 2}, > >> + {0x00000004, 2}, > >> + {0x00001fff, 13}, > >> + {0x00002000, 13}, > >> + {0x50000000, 31}, > >> + {0x80000000, 31}, > >> + {0x80003000, 32}, > >> +}; > >> + > >> +unsigned long order_comb_long[][2] = { > >> + {0x0000000300000000, 34}, > >> + {0x0000000400000000, 34}, > >> + {0x00001fff00000000, 45}, > >> + {0x0000200000000000, 45}, > >> + {0x5000000000000000, 63}, > >> + {0x8000000000000000, 63}, > >> + {0x8000300000000000, 64}, > >> +}; > > > >noreply@ellerman.id.au reported for m68k-allmodconfig: > > > >lib/test_bitops.c:42:3: error: unsigned conversion from 'long long > >int' to 'long unsigned int' changes value from '12884901888' to '0' > >[-Werror=overflow] > >lib/test_bitops.c:43:3: error: unsigned conversion from 'long long > >int' to 'long unsigned int' changes value from '17179869184' to '0' > >[-Werror=overflow] > >lib/test_bitops.c:44:3: error: unsigned conversion from 'long long > >int' to 'long unsigned int' changes value from '35180077121536' to '0' > >[-Werror=overflow] > >lib/test_bitops.c:45:3: error: unsigned conversion from 'long long > >int' to 'long unsigned int' changes value from '35184372088832' to '0' > >[-Werror=overflow] > >lib/test_bitops.c:46:3: error: unsigned conversion from 'long long > >int' to 'long unsigned int' changes value from '5764607523034234880' > >to '0' [-Werror=overflow] > >lib/test_bitops.c:47:3: error: conversion from 'long long unsigned > >int' to 'long unsigned int' changes value from '9223372036854775808' > >to '0' [-Werror=overflow] > >lib/test_bitops.c:48:3: error: conversion from 'long long unsigned > >int' to 'long unsigned int' changes value from '9223424813412909056' > >to '0' [-Werror=overflow] > > > >Indeed, on 32-bit, none of these values fit in unsigned long. > > > > Hmm... I didn't test on 32bit platform. Sorry for that. > > >> static int __init test_bitops_startup(void) > >> { > >> pr_warn("Loaded test module\n"); > >> @@ -32,6 +56,18 @@ static int __init test_bitops_startup(void) > >> set_bit(BITOPS_11, g_bitmap); > >> set_bit(BITOPS_31, g_bitmap); > >> set_bit(BITOPS_88, g_bitmap); > >> + > >> + for (i = 0; i < ARRAY_SIZE(order_comb); i++) { > >> + if (order_comb[i][1] != get_count_order(order_comb[i][0])) > >> + pr_warn("get_count_order wrong for %x\n", > >> + order_comb[i][0]); } > >> + > >> + for (i = 0; i < ARRAY_SIZE(order_comb_long); i++) { > >> + if (order_comb_long[i][1] != > >> + get_count_order_long(order_comb_long[i][0])) > >> + pr_warn("get_count_order_long wrong for %lx\n", > >> + order_comb_long[i][0]); } > >> + > >> return 0; > > > >BTW, shouldn't get_count_order_long() be tested with the values in > >order_comb[], too? > > > > You mean > > {0x0000000000000003, 2}, > {0x0000000000000004, 2}, > {0x0000000000001fff, 13}, > {0x0000000000002000, 13}, > {0x0000000050000000, 31}, > {0x0000000080000000, 31}, > {0x0000000080003000, 32}, Yes, those values. And those should work with get_count_order_long() on both 32-bit and 64-bit. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds