Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1534677ybt; Mon, 15 Jun 2020 02:50:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysl1Gzvl2hyTsBCfUCyxVKFF2s533zFGa7pG9icODJWfnMz2mUktgtnLYccbR1554PubXH X-Received: by 2002:a17:906:d973:: with SMTP id rp19mr23639334ejb.475.1592214631553; Mon, 15 Jun 2020 02:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592214631; cv=none; d=google.com; s=arc-20160816; b=VbP9wbwaJq2XVhDbdq1Td9/lsdlCzSpdfOTJG08JdoEiV+6dJ/KYMCm4FWjIDIAzxZ FAAzZyRieckUoJvbpzM1lTivWKRSf5FO/RoXsowS9suySxWZZj83IL2as4rmlwIn9Glg zu19E5OaSJ9nUoqHy1w1GYCNYJzyvQIfGn8bozrFRmw9GeZa0cYMKn41QuAIgflwF8L3 VaMoHofvg4FHoMIN/Pz+CigAcTeRANo6SGMI1TCqQHza0dxfdRu9WQQMU8GqwPuOe1mV GuaOIQne9FJPNnLtuDduVYLInFor25P+b6pKzmkO7dUHYj56fOnU0ziT5pn30DlfRK1i s/RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=55J8iTTeElSWR+4Nv/x4gwnPpkDbhKBL+IBP9Aju2Xs=; b=p2VBO+UnVnHtMsXy660L9mcdTyTtvZ28nnzN9gbdoLm4f8oZFWQiecOwjuZHb9k04y 1GyqiwDkOWeEKCE+TZVyIHaycH6XE/qdDTOWOYf9o2DhS15ZJse75UGIU7nQrFS1Icqf e7+afn6mzgxLqFadfkiYJ8j3qTuxVL5R00l9Mzj+mdkWBO3dTkWTHyoorui5+MjEwE6D +gsGshFLkIPD5EEOE/W0yLprbBMVxLAy2gjbBEWEV6081uqD7IvrAkUX8EPTlWpcaTMc cvylUvZBESir4tq17Of0J9jf0aahoWWRk0LDfFxR//zEvzBcJpitxlhGm5SFUZzlhirM +LVg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si9425402ejb.100.2020.06.15.02.50.08; Mon, 15 Jun 2020 02:50:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729337AbgFOJqS (ORCPT + 99 others); Mon, 15 Jun 2020 05:46:18 -0400 Received: from mga07.intel.com ([134.134.136.100]:22419 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729280AbgFOJqR (ORCPT ); Mon, 15 Jun 2020 05:46:17 -0400 IronPort-SDR: gLT94mxs0xf/kNnHbM6fx+B4sO+rVREzUq/QHMbh/uP+OdzlLqtwUuo1ZmidUpuKBilgbDrhDK nJGF1AwJ4NDQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2020 02:46:16 -0700 IronPort-SDR: XgcFG50rtij0zNyxTx2eR7e6aWzEN6HIam4/YmBQuH3xC3wQR3oGQthNEmbEaSIJFXuzH0JtCC SxQFfD/j7Lmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,514,1583222400"; d="scan'208";a="316860786" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jun 2020 02:46:14 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1jklh2-00DXSL-Uk; Mon, 15 Jun 2020 12:46:16 +0300 Date: Mon, 15 Jun 2020 12:46:16 +0300 From: Andy Shevchenko To: Stefano Brivio , Alexander Gordeev Cc: Andrew Morton , Yury Norov , Rasmus Villemoes , Pablo Neira Ayuso , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] bitmap: Add test for bitmap_cut() Message-ID: <20200615094616.GS2428291@smile.fi.intel.com> References: <5fc45e6bbd4fa837cd9577f8a0c1d639df90a4ce.1592155364.git.sbrivio@redhat.com> <20200615094155.GQ2428291@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200615094155.GQ2428291@smile.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 12:41:55PM +0300, Andy Shevchenko wrote: > On Sun, Jun 14, 2020 at 07:40:54PM +0200, Stefano Brivio wrote: > > Inspired by an original patch from Yury Norov: introduce a test for > > bitmap_cut() that also makes sure functionality is as described for > > partially overlapping src and dst. > > Taking into account recent fixes for BE 64-bit, do we have test cases for a such? It might be enough to have only these, but perhaps s390 guys can help? Alexander, can you apply this patch (w/o the first one, which is suppose to fix) and confirm that you have test case failure, followed by applying first one and confirm a fix? > > Signed-off-by: Stefano Brivio > > --- > > v2: > > - use expect_eq_bitmap() instead of open coding result check (Andy > > Shevchenko) > > - don't use uncommon Co-authored-by: tag (Andy Shevchenko), drop > > it altogether as Yury asked me to go ahead with this and I haven't > > heard back in a while. Patch is now rather different anyway > > - avoid stack overflow, buffer needs to be five unsigned longs and > > not four as 'in' is shifted by one, spotted by kernel test robot > > with CONFIG_STACKPROTECTOR_STRONG > > > > lib/test_bitmap.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 58 insertions(+) > > > > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c > > index 6b13150667f5..df903c53952b 100644 > > --- a/lib/test_bitmap.c > > +++ b/lib/test_bitmap.c > > @@ -610,6 +610,63 @@ static void __init test_for_each_set_clump8(void) > > expect_eq_clump8(start, CLUMP_EXP_NUMBITS, clump_exp, &clump); > > } > > > > +struct test_bitmap_cut { > > + unsigned int first; > > + unsigned int cut; > > + unsigned int nbits; > > + unsigned long in[4]; > > + unsigned long expected[4]; > > +}; > > + > > +static struct test_bitmap_cut test_cut[] = { > > + { 0, 0, 8, { 0x0000000aUL, }, { 0x0000000aUL, }, }, > > + { 0, 0, 32, { 0xdadadeadUL, }, { 0xdadadeadUL, }, }, > > + { 0, 3, 8, { 0x000000aaUL, }, { 0x00000015UL, }, }, > > + { 3, 3, 8, { 0x000000aaUL, }, { 0x00000012UL, }, }, > > + { 0, 1, 32, { 0xa5a5a5a5UL, }, { 0x52d2d2d2UL, }, }, > > + { 0, 8, 32, { 0xdeadc0deUL, }, { 0x00deadc0UL, }, }, > > + { 1, 1, 32, { 0x5a5a5a5aUL, }, { 0x2d2d2d2cUL, }, }, > > + { 0, 15, 32, { 0xa5a5a5a5UL, }, { 0x00014b4bUL, }, }, > > + { 0, 16, 32, { 0xa5a5a5a5UL, }, { 0x0000a5a5UL, }, }, > > + { 15, 15, 32, { 0xa5a5a5a5UL, }, { 0x000125a5UL, }, }, > > + { 15, 16, 32, { 0xa5a5a5a5UL, }, { 0x0000a5a5UL, }, }, > > + { 16, 15, 32, { 0xa5a5a5a5UL, }, { 0x0001a5a5UL, }, }, > > + > > + { BITS_PER_LONG, BITS_PER_LONG, BITS_PER_LONG, > > + { 0xa5a5a5a5UL, 0xa5a5a5a5UL, }, > > + { 0xa5a5a5a5UL, 0xa5a5a5a5UL, }, > > + }, > > + { 1, BITS_PER_LONG - 1, BITS_PER_LONG, > > + { 0xa5a5a5a5UL, 0xa5a5a5a5UL, }, > > + { 0x00000001UL, 0x00000001UL, }, > > + }, > > + > > + { 0, BITS_PER_LONG * 2, BITS_PER_LONG * 2 + 1, > > + { 0xa5a5a5a5UL, 0x00000001UL, 0x00000001UL, 0x00000001UL }, > > + { 0x00000001UL, }, > > + }, > > + { 16, BITS_PER_LONG * 2 + 1, BITS_PER_LONG * 2 + 1 + 16, > > + { 0x0000ffffUL, 0x5a5a5a5aUL, 0x5a5a5a5aUL, 0x5a5a5a5aUL }, > > + { 0x2d2dffffUL, }, > > + }, > > +}; > > + > > +static void __init test_bitmap_cut(void) > > +{ > > + unsigned long b[5], *in = &b[1], *out = &b[0]; /* Partial overlap */ > > + int i; > > + > > + for (i = 0; i < ARRAY_SIZE(test_cut); i++) { > > + struct test_bitmap_cut *t = &test_cut[i]; > > + > > + memcpy(in, t->in, sizeof(t->in)); > > + > > + bitmap_cut(out, in, t->first, t->cut, t->nbits); > > + > > + expect_eq_bitmap(t->expected, out, t->nbits); > > + } > > +} > > + > > static void __init selftest(void) > > { > > test_zero_clear(); > > @@ -623,6 +680,7 @@ static void __init selftest(void) > > test_bitmap_parselist_user(); > > test_mem_optimisations(); > > test_for_each_set_clump8(); > > + test_bitmap_cut(); > > } > > > > KSTM_MODULE_LOADERS(test_bitmap); > > -- > > 2.27.0 > > > > -- > With Best Regards, > Andy Shevchenko > > -- With Best Regards, Andy Shevchenko