Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1268686ybg; Thu, 4 Jun 2020 05:38:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySq4sIjY1ncGjTMOoVMtZaB8pQ2xTNXqa6ijbezxlGotxKEazyl4aKSew3n+lbpGLhPyDD X-Received: by 2002:a05:6402:1c8b:: with SMTP id cy11mr3988444edb.122.1591274314192; Thu, 04 Jun 2020 05:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591274314; cv=none; d=google.com; s=arc-20160816; b=F/bAARvQ1po3gqASb31xuW90fw4OgsCuTg0eWzp1CYkceeNO/IWmw7rS417B7FfH8T JpFy3P9bqHrq2iZrqTRhAQH4DUaCHN0OXzBKimyNV2NEaVHTNhTR/2kPlVrjEZOOJqLA 8GNL/bqXb68WEppxEMDKKr0OLLMrrNMxjJupnrw+44EJ/A4sz89UcjxquQZh8d9MCNE2 tIkgy0m8k3MklrCnrAJ5L5rVvteJA10jWxOXG8r9pEfm7BsKlGgROtEmm2o3XUrvwN27 iz6goXrojqwtTN7L8NMqilIq0XBFLaTtXBSm8Xuor2WQrHgjcXo+VTZf/RGcE1BIcTn+ z+VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=lSORlFcZSsY0YSYfNIbAg9Ey6cjiYjeRcAyhIYfab3I=; b=PJ8LLVPuKlwxLMZpKmiwGlH2dLnY9fsLmXH/oYKeGk3xJVH9eLt7FLjLGHufYjW6wd 1RdnMXSRG6rLwzn/s/2O5yVegJ73eNyxUhR1yEuioOPYcSHqlG5kICL0UZeL/9AJaGAN bIiUe1bMOtYUMy9Udz8yi/U97OtUQeELJY40VJCrYrrzXkI4YVnRaQSzsIHAPMTYZOqP vGPd6ybtwV/a/hB90dZirQuDlN7Z4x3l6l+9CwJoWGEpyKFk3w/1YNqnFjucK+ifvoL7 Iv5CZ3R93zZtNnqXGADDaxhinYbyRzugJqBEH1BuiXHezRowKdq994ZAKn63gLTNGPqj amwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aAOzMm5U; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si1496279ejr.37.2020.06.04.05.38.10; Thu, 04 Jun 2020 05:38:34 -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=@gmail.com header.s=20161025 header.b=aAOzMm5U; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbgFDM2J (ORCPT + 99 others); Thu, 4 Jun 2020 08:28:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728262AbgFDM2I (ORCPT ); Thu, 4 Jun 2020 08:28:08 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 611ADC08C5C0 for ; Thu, 4 Jun 2020 05:28:08 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id x93so4520112ede.9 for ; Thu, 04 Jun 2020 05:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lSORlFcZSsY0YSYfNIbAg9Ey6cjiYjeRcAyhIYfab3I=; b=aAOzMm5UYQpWbPFKaS58u3xmexgi14qRjZYMPdk27iHfnfatHZaJkoaaGb7u4J4r9h MK5gOApbLjnpV4o3ZLyoqRvc7tyN8lL08IP+a1sy8UllVWCC9SHMmBoFda5JhMIFjJL8 y8CFvNqAK3/9VmtctD+5twE1KWqehVim9TOxeQl49SbPWpd8IWOTaD/SiUwTgAJ1vgkb e3VXOjKeFEY6Jys8jWzuZQdwLeml0XCPJO4T/XiFADDsLllmN8lfzOIE/0/wtgisrwPK +u7+VwUM5hjfsmumtmwa+air5aMBVhpBeNa3XCBzPduaXSC3z0x6TexwzznqQS2Dv6bG uLBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=lSORlFcZSsY0YSYfNIbAg9Ey6cjiYjeRcAyhIYfab3I=; b=trFrZr7MPFveADy25TWtuIHr+c5nU4dpFdjKbn22R9UkUwnexLmefcNBJFGUxkqtOa hoyW9VMw5/zOK9xBY2UfORzsvvmcVryKJTRI7KvtAtLzthytI9o86BxGwOJ3f5qrRB2E S//rXTjZMowVcTcotKG+2hnkEO3HeyFHACZp8pI69xRvubTFQQJTRQ6tSJHSye8jruzz qtwTDycKLKYNmaGv9L5a6jDx1lfuf8NQbga1ojPofMOif95WFj4cyvnGr3Iq6+Xk3ftr /5bIpME68ecFdKX3gHFuE42Mg/u3rze/VohH2lrYwJkA5PXZL8lGOVkksKeBqhncxHR3 gFGw== X-Gm-Message-State: AOAM533GxzxujdmZ/y795X0+eHGBicmDPE8yTmwDiMR5uGAtKh6G7a9p B0Gzaw0I0ABM1QwbZIGP1jA= X-Received: by 2002:aa7:d6d0:: with SMTP id x16mr4172336edr.175.1591273687067; Thu, 04 Jun 2020 05:28:07 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id la5sm2084347ejb.94.2020.06.04.05.28.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jun 2020 05:28:06 -0700 (PDT) Date: Thu, 4 Jun 2020 12:28:05 +0000 From: Wei Yang To: Geert Uytterhoeven Cc: Wei Yang , Andrew Morton , Andy Shevchenko , Christian Brauner , Linux Kernel Mailing List Subject: Re: [Patch v2] lib: test get_count_order/long in test_bitops.c Message-ID: <20200604122805.d2ndjmkmti6wl3nz@master> Reply-To: Wei Yang References: <20200602223728.32722-1-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 04, 2020 at 01:50:13PM +0200, Geert Uytterhoeven wrote: >Hi Wei, > >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}, >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 -- Wei Yang Help you, Help me