Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934206AbeAJIt5 (ORCPT + 1 other); Wed, 10 Jan 2018 03:49:57 -0500 Received: from mail-co1nam03on0069.outbound.protection.outlook.com ([104.47.40.69]:25369 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753200AbeAJItz (ORCPT ); Wed, 10 Jan 2018 03:49:55 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Wed, 10 Jan 2018 11:49:38 +0300 From: Yury Norov To: Andy Shevchenko Cc: Andrew Morton , linux-kernel@vger.kernel.org, Rasmus Villemoes , Randy Dunlap Subject: Re: [PATCH v1 4/4] bitmap: Make bitmap_fill() and bitmap_zero() consistent Message-ID: <20180110084938.ggb3x4pq5suprnne@yury-thinkpad> References: <20180109172430.87452-1-andriy.shevchenko@linux.intel.com> <20180109172430.87452-4-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180109172430.87452-4-andriy.shevchenko@linux.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [42.107.85.128] X-ClientProxiedBy: HE1PR06CA0137.eurprd06.prod.outlook.com (2603:10a6:7:16::24) To CY4PR0701MB3828.namprd07.prod.outlook.com (2603:10b6:910:94::34) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cd03ed4-1e45-4f39-8c9d-08d558071e45 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:CY4PR0701MB3828; X-Microsoft-Exchange-Diagnostics: 1;CY4PR0701MB3828;3:IzauEeNSepKtn/nkEmLhMWXec0cTXK8mXQku7ho6KS8JNXNdcR0w2YZI1d8PwGDV2Olzm2KNSp5AIzOtNCw4ki7E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DTbq6CtCg8Og+zxWWxJ7GJkihnVhcfQ6de4gblrh4tLeg/bQlQbp5b591ntrO28+ylE2p2Jb3KXB7bPJSlb/Zs8bq/yFbz4yHfzMVPPLMirxSgLk8imoCdoX8g3N7biFwuFx2eTVXK7APYPPx/z1KzHFNXn/whcmCSZtKJfkxGRDpH4fUJ1QPzPBI5FVgZzwrnmZQMU7MA6tER/nDznbYgCgRuUgd77mZNxc1a30PyJiXWapW8Muf31CKFGgGgJ82ATQfXOaWrisZT8Lj4heFbSm2UsGiU2DzGKyy/PlPmciZqczHRW5eZE2r0ab8TV84xnGSkWBBKiq9WdS8M7WJIcM1SIDApozN4=;4:Fqje92e/qxzHFrWAZe0NO4sdDKuFTHuXTjQXcR+MK6CWihjCipUtCeC9FaUX05VD2ufB0meW259ypigu61oQRfHRanTcZ7M3o6Bh7yxPhLuL122l/8TMv5w9XLviDN8rYhvdonhhIDMKuTmEpCxawczSHmxBHPyP1vZvrTUAs5Uo+CQZqh8igQgGjHZTl3YUSy8boyijsyJAUNj6JrAAscEJmi8GTxiv8kpquwP6qygbZTlF9SUvvCXCcGGQ1e/7EYpeIZY+zAxNpSGUQjJabzpy3Bez0DziuR1BsOLkQdH0bj02EEizoZEakwMQYYKM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(3002001)(93006095)(10201501046)(6041268)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:CY4PR0701MB3828;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR0701MB3828; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(39860400002)(376002)(346002)(39380400002)(366004)(396003)(24454002)(199004)(189003)(97736004)(386003)(42882006)(6916009)(229853002)(4326008)(72206003)(2950100002)(106356001)(6666003)(6486002)(5009440100003)(105586002)(8936002)(478600001)(7736002)(58126008)(6496006)(33896004)(81166006)(8676002)(16586007)(81156014)(50466002)(25786009)(52116002)(305945005)(6246003)(3846002)(33716001)(6116002)(1076002)(68736007)(47776003)(54906003)(16526018)(83506002)(575784001)(5660300001)(316002)(76176011)(9686003)(2906002)(66066001)(53936002)(76506005)(23726003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR0701MB3828;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR0701MB3828;23:x6pDb6cSAu1pQrAlElEAkMGX52FuA38L805K3H0?= =?us-ascii?Q?Xj486bWDE3cZky2wRRzFS94boyIZKTQlLFrH8BJLr7Ml4cTprtIXNP57sqYg?= =?us-ascii?Q?6ZlMN7orzo091AARB3H4tz72q2jSjCmf9o2WyIgzWY6xQkDAHcbePLI9v7Sr?= =?us-ascii?Q?FmO5/RXm5kP7Eoum8eM7VU6vOj7fVBbB5OIVe+U5FHp1HEgo3LuQjMnXR8eQ?= =?us-ascii?Q?pCmlRQCuZA/nTBPJvb4ZGRAh/kwG6QRPzYBjlb4wK2L5zZ0BiYKMNFJbk9ms?= =?us-ascii?Q?wA7q/lorLuBpZ68YAkv6O4H2/R/RqnGzh9PhCHa9aMpYprfRW38+KLgS+aaQ?= =?us-ascii?Q?Dn9TdmLrg6I/y4SNS3CK74sXu9nlZLzeflYuoGmgcnTCFCBZ6eAph+39qRla?= =?us-ascii?Q?lXqGgfrucCukM/wqSioSw3vuyJSNNmbXIERZ3zYo2nR1Wq9kvTj4tFwoF2mO?= =?us-ascii?Q?bYCbo7Hwo+A8u0aNWdHWIsEAJ6orW4d0gBd9hVAspVYnWqkeDKG+s6iDgIOV?= =?us-ascii?Q?X85ZYVTi3XPyTsnbxFpMkHUMHqJNSaiJck/u4yXwLix4btoV7y6JFydEjl9I?= =?us-ascii?Q?qbmEXyriyDo5s0dlGAWWDFWEm7bv6dBHBHebNsAlZREe+txVkR27rDsekgzD?= =?us-ascii?Q?GBWtLWnvtIaC03SJzYwWYB52Lt1mgnvkKuKYjU45oodNBBefMO6nC5DeX+V/?= =?us-ascii?Q?PGkJStQWDWgthUWqkrLvfJVXLyAiHpw7kHENwIKDWU+AHgOJU7WjbmEEwowV?= =?us-ascii?Q?ANOPjR38Msr47vrRMw3I8z5Cg8NL29YbimbDFyA4xw8UdWsExesnwX+w0i0X?= =?us-ascii?Q?hD1/RYggc8I34iMbmWwbqnR4ZbvFN9ZgMx51RtYDPiwziHuPTXrx6hYf1ZLP?= =?us-ascii?Q?OyW7WH33za+J4GURNdpwnzUivoIEF4riydtj3M9j/rKTcPYq875Oxis024Ut?= =?us-ascii?Q?aoG5FyzBSeMX6I1P1bDkGhT53PYtutYYmY7T5VBibA0vJCEXCB+wOgBPzFOr?= =?us-ascii?Q?CID1YNeDWh7BTmjzA27iHphU8CRk/N3UaWzosUsi40cy6romI3Mt+Vv6ncjw?= =?us-ascii?Q?IQ+ltXoFSzPBvn9JF7lumq55L9a+8BpBaX/HgW2PAYNe06GrjsGdhxwxfwNh?= =?us-ascii?Q?rlyn7+vJ+alZV5YODkhRNFM9fA/+qudVU+QD+1IktVLYtugulKKJrKkxFh7E?= =?us-ascii?Q?Rb4W8+AFi+lYp06XiDSWGM/HWBHhwSN56nQwxbxdeucuQLRnqRFMvCVPA0vz?= =?us-ascii?Q?ddWbjkQ3qENYa0xUcAaNDntJOpIKyueBP0jgC1/8a3Qsoz+UE777R8MaAby7?= =?us-ascii?Q?pbcNXX/Nj0OVtNQPqfZS02mhk7lpmFEOplP7eEw+wv99b?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR0701MB3828;6:tAf+oTqxp69YXvwg60g6Ifu6wUYDhqDWehqaV4TkKGgKhtMTe4bkqlHSvRumUWB7ptg2Ai94iZ9Ndy5TiRaMAL5FmGwVaqmp30D2ZUHWbYcm94OuHshu8KhiWhyIqY9bIkTwZH4uGZw52b7gpZJiLp+gx8pRS/7ioTe9JzXKrmD+SKPvC7zTEcc2IY1y5p8zPhrqmS1jnwYEFBTgFlsqTBeyI3BlPByhdq9qsU8XZnJSy9sdvn/umMKja5Yv0jorQRVg044Hd9BZKfCXJ84OqkxlIqgcgByi6GM5T2U3mFym421uMVb6JmQfoDAKCZGZQtL9hpxYR2dXiWLA6a5juUWPTkl+KAIT+sMlREOl53E=;5:Rg9wBICdFqvPQADmWXazrBjl6tlRsSowSWjg1kizT9nRb4waJZWiUuRmWtot0MTeISECpT9FV/1kQwfICvx2H4YY3H4SGasQj4+uwdXFPx7Zad6oaoF0KZO5Jv1RQh7cQYs9v5tO7Z/CxlS7ig6eyIjbFzSj6VUwoFupk7RXNsY=;24:loHgK4lKelUOEFIYcNN6ew4EfE3bvF9tcBqdnqbWpggC9IkneWYXKYonsapdcaK8DO0RXwykPy1v6ZmKCduomrj3b3lR+TxXowsk3dkAhOs=;7:06Hzs1x8jbctrhEGg/5X0FESo3oN1HiSgZjSnZb7TiIzx3Jcnc8lOLEF8M1y29t0XiFjo3g1vWdj/9aSUNOsdEIFF7TNeAEV0uyRM7vnkLzgiGtfdUVXvpm4WRMrMHB8UfJH5dVf8ULgrcJeFLXk92eBNQ1QV9cz5HPsP7lnHpOlOqFfeMey8nLWbmgj9MYae0jBEg8jOjNZVEWiXR27icaY/wIoXxbmzjBbn5PUszWhGf4ce6+CclzpCrSHaHie SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 08:49:52.6339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cd03ed4-1e45-4f39-8c9d-08d558071e45 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3828 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 09, 2018 at 07:24:30PM +0200, Andy Shevchenko wrote: > Behaviour of bitmap_fill() differs from bitmap_zero() in a way > how bits behind bitmap are handed. bitmap_zero() clears entire bitmap > by unsigned long boundary, while bitmap_fill() mimics bitmap_set(). > > Here we change bitmap_fill() behaviour to be consistent with bitmap_zero() > and add a note to documentation. > > The change might reveal some bugs in the code where unused bits handled > differently and in such cases bitmap_set() has to be used. There is only 51 users of bitmap_fill() in the kernel, including tests. If you propose this change, I think you'd check them all manually. Sorry that. Also, there's tools/include/linux/bitmap.h which has a copy of bitmap_fill(), and should be consistent with main kernel sources. > Suggested-by: Rasmus Villemoes > Signed-off-by: Andy Shevchenko > --- > include/linux/bitmap.h | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index a17b5121d4f5..49aea0b37994 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -67,6 +67,11 @@ > * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst > * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst > * > + * Note, bitmap_zero() and bitmap_fill() operate over the region of > + * unsigned longs, that is, bits behind bitmap till the unsigned long > + * boundary will be zeroed or filled as well. Consider to use > + * bitmap_clear() or bitmap_set() to make explicit zeroing or filling > + * respectively. > */ > > /** > @@ -206,12 +211,12 @@ static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) > > static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) > { > - unsigned int nlongs = BITS_TO_LONGS(nbits); > - if (!small_const_nbits(nbits)) { > - unsigned int len = (nlongs - 1) * sizeof(unsigned long); > - memset(dst, 0xff, len); > + if (small_const_nbits(nbits)) > + *dst = ~0UL; > + else { > + unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); > + memset(dst, 0xff, len); > } > - dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); > } > > static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, > -- > 2.15.1