From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932352AbdJYJLh (ORCPT ); Wed, 25 Oct 2017 05:11:37 -0400 Received: from mail-bl2nam02on0091.outbound.protection.outlook.com ([104.47.38.91]:58672 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932084AbdJYJLc (ORCPT ); Wed, 25 Oct 2017 05:11:32 -0400 From: Matthew Wilcox To: Paul Mackerras CC: Linus Torvalds , "linux-kernel@vger.kernel.org" , "linuxppc-dev@ozlabs.org" , "linux-s390@vger.kernel.org" Subject: RE: [PATCH] bitmap: Fix optimization of bitmap_set/clear for big-endian machines Thread-Topic: [PATCH] bitmap: Fix optimization of bitmap_set/clear for big-endian machines Thread-Index: AQHTTV6M7CTX8ku2Y0qrhIGWQ0nwz6L0LX2wgAATJQCAAAHeAA== Date: Wed, 25 Oct 2017 09:11:29 +0000 Message-ID: References: <20171025065726.GA25140@fergus.ozlabs.ibm.com> <20171025084602.GC25140@fergus.ozlabs.ibm.com> In-Reply-To: <20171025084602.GC25140@fergus.ozlabs.ibm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Ref=https://api.informationprotection.azure.com/api/72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=mawilcox@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-10-25T05:11:26.7503008-04:00; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [62.168.35.108] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR21MB0510;6:Hl/jsurNY/pLuS53DLb9Q5WBPnRTeLRIU9myYhbmHIC3b95eDn1ThuMhNJftl8ftxtkA1nPRPuPvKzNWPojiwdxaP9peQ4pEoJICZnF6g7pnk+P1gUEpRDyXOJsUV79HGvEz9NA654VJkXFebz/pLhPiWdvPUqaP6oGCSTqM1RSD3hiAmJNuMOP2InHyT/cvXyh5Ah3HwLHB54aixKmMpGnMhVyBG69C7VnGTAe8gYe8WnsBnWYO8b/wFNUs6kPO1QaaS0VCp7W52DcityBNMx0v8EVtGqaf0UeK0FiCs9ETdFXRG5eOVlXLV/s0uVe+aRWbAgJkqHyLeTq+h1F/665yIwpyRPrLzpjaRhexO90=;5:oOEE1MS1Fl1XlcobaW8eu7MVVGe+I+8IJrXMQJ/vEZ9C5UjmeFKVVHjK4YVwsm1XG/5GXjQTLuRCQDPj7xyLFwhoqvhPprsN9pVzzR9fKzhe2zk7lnug764tIpCD5I5Bw63c8O/L5WOqQhzyDyps9DWPY02Pwy92mvKwb2lBAyo=;24:CB4Aw5IuetRD3oyy55WNa0PP8zWfpo0Ui7a6Pj100jCPIJ1VbrPcnbcj9IAUxoJaAZ8Io5b4MgrUbYrV8Y1DRiJcjUSbVPdCaEZlfl9ekYM=;7:lyb6UDsvDnMeHvqiBtWBcJQKK+pX9x/8qLVSAKFWNCimQL3vlQ66s5HrGyAHUS92a//N9aaUhKJhbzxDcOW6w5EUeaiBJ5HFzIp+Gr8sq6FyfmOuGTbsZmuojlljk4qHh9UdKAPnP1BpBXEclWdQg2uyuKJEi/O8XNwffAoUopwHOcHvXKIen4f0gIPX6SWmc2O5DuMq+7P+XDoT4wjNNmpqd8A4BuGZ7TYFsMW/To4JBSTDEp5lyLr5Fl+5Blq+ x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 720e5fae-abd6-40dc-9371-08d51b8860f6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603238);SRVR:MWHPR21MB0510; x-ms-traffictypediagnostic: MWHPR21MB0510: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(3231020)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR21MB0510;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR21MB0510; x-forefront-prvs: 0471B73328 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(376002)(346002)(47760400005)(189002)(24454002)(199003)(25786009)(10290500003)(54356999)(77096006)(10090500001)(8936002)(101416001)(6436002)(4326008)(55016002)(99286003)(9686003)(53936002)(6506006)(3660700001)(7736002)(50986999)(8676002)(86362001)(6246003)(8990500004)(76176999)(81156014)(66066001)(86612001)(3280700002)(106356001)(81166006)(105586002)(229853002)(7696004)(5660300001)(2906002)(6916009)(2950100002)(54906003)(316002)(22452003)(33656002)(14454004)(97736004)(2900100001)(189998001)(102836003)(478600001)(74316002)(6116002)(3846002)(68736007)(305945005);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR21MB0510;H:MWHPR21MB0845.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; authentication-results: spf=none (sender IP is ) smtp.mailfrom=mawilcox@microsoft.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 720e5fae-abd6-40dc-9371-08d51b8860f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2017 09:11:29.6625 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0510 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v9P9BgEt005635 From: Paul Mackerras [mailto:paulus@ozlabs.org] > On Wed, Oct 25, 2017 at 07:39:48AM +0000, Matthew Wilcox wrote: > > Hang on, don't tell me you found this by inspection. Are you not running the > bitmap testcase, enabled by CONFIG_TEST_BITMAP? Either that should be > producing an error, or there's a missing test case, or your inspection is wrong ... > > I did find it by inspection. I was looking for a version of the > bitmap_* API that does little-endian style bitmaps on all systems, and > the inline bitmap_set() does that in the case where it calls memset, > but not in the case where it calls __bitmap_set. I do believe that you noticed it by inspection, but you shouldn't've had to. I thought we had a comprehensive set of tests for exactly this, which means that either 01.org isn't running the right set of tests on a BE system or the tests are broken. > I'll fire up a big-endian system tomorrow when I get to work to run > the test case. (PPC64 is almost entirely little-endian these days as > far as the IBM POWER systems are concerned.) > > In any case, it's pretty clearly wrong as it is. On a big-endian > 64-bit system, bitmap_set(p, 56, 16) should set bytes 0 and 15 to > 0xff, and there's no way a single memset can do that. So ... this loop should include that case, right? for (start = 0; start < 1024; start += 8) { memset(bmap1, 0x5a, sizeof(bmap1)); memset(bmap2, 0x5a, sizeof(bmap2)); for (nbits = 0; nbits < 1024 - start; nbits += 8) { bitmap_set(bmap1, start, nbits); __bitmap_set(bmap2, start, nbits); if (!bitmap_equal(bmap1, bmap2, 1024)) printk("set not equal %d %d\n", start, nbits); if (!__bitmap_equal(bmap1, bmap2, 1024)) printk("set not __equal %d %d\n", start, nbits);