Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757846AbeAIFQF (ORCPT + 1 other); Tue, 9 Jan 2018 00:16:05 -0500 Received: from mail-sn1nam01on0045.outbound.protection.outlook.com ([104.47.32.45]:23948 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756682AbeAIFQD (ORCPT ); Tue, 9 Jan 2018 00:16:03 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Tue, 9 Jan 2018 08:15:44 +0300 From: Yury Norov To: Rasmus Villemoes Cc: linux-kernel@vger.kernel.org, Andrew Morton , Ben Hutchings , David Decotigny , "David S . Miller" , Geert Uytterhoeven , Matthew Wilcox Subject: Re: [PATCH 1/2] bitmap: new bitmap_copy_safe and bitmap_{from,to}_arr32 Message-ID: <20180109051544.4rpf3u2l6poq7zio@yury-thinkpad> References: <20171228150019.27953-1-ynorov@caviumnetworks.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) X-Originating-IP: [42.107.70.164] X-ClientProxiedBy: VI1PR0701CA0043.eurprd07.prod.outlook.com (2603:10a6:800:90::29) To DM5PR0701MB3830.namprd07.prod.outlook.com (2603:10b6:4:7f::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f79e391-f51e-4f08-6ff7-08d55720126a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:DM5PR0701MB3830; X-Microsoft-Exchange-Diagnostics: 1;DM5PR0701MB3830;3:0IwYPSBWartIA+bmeTJkOdEM7bHL4O1zTEPKzfallQrEuJpkzk4lqnS7mp68iddYPdSYKnALOWT7J5HGGV0Yu3GQVpPxvHJzK1PfSe+FBBSXqcvqhz1ZmBC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DPtgtDeEnHVpkBbWgfpTQfEJWZCErMHgNJsFHpTdprerSa7KUjMN8VKl8e5R3YukdGCSqE/gw2nGh+quXIU3qYvY0leDMzeidf/AhWUvKL4wxH974ILlt9dK4Ze837Z2iFRT/qsabm5tVBpIuRXFfMr81gGOuVDN9RU886g4sWlABEOPK/Ivxc8fGkdJdQqu89b0LkdWcdE+yQMAqEr8qA9xn1z1jnRHbHYrDSMcKeA48FdlDQpg4u675RGvNFuKFXicfRs6xN/l/XO9aCdWU+W3QlVxcXHcGurOhA1twT1MG5/JdXApchwbmtqcCqkoGVGsFCmQgDktcDtYM/1FNAqkk=;4:7mPSMc06VkbHPdEUXzLHrTiJ+W0tdYF9FGTB6SFtM6FDZxQAfkxlMkrQMluJDTB3IZyqGnMptZeKMmUkc2GoCZE8M0FnY1GMecJMB7WwUz35daOMeX1qObANDiusW689NnLo77zNS3Zql/EP9bpipexugqbZ/aVMYj4kmpnsSx/A94aaRV0CQM8nrz81MYHexyQs7QUvlkLttI1Mq+9frH0CZwmNCnyqvU38SSyuTEnR+lntzYiNVg04vXMrSoSBNrJF0xaMhxkIQXeh+Y+efw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(3002001)(10201501046)(93006095)(6041268)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR0701MB3830;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DM5PR0701MB3830; X-Forefront-PRVS: 0547116B72 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(346002)(39850400004)(396003)(376002)(39380400002)(366004)(24454002)(199004)(189003)(52314003)(50466002)(316002)(83506002)(5009440100003)(105586002)(47776003)(106356001)(5660300001)(16586007)(76506005)(6916009)(2950100002)(6666003)(54906003)(58126008)(42882006)(16526018)(66066001)(33716001)(305945005)(386003)(53546011)(229853002)(8666007)(25786009)(1076002)(97736004)(68736007)(4326008)(3846002)(9686003)(23726003)(76176011)(33896004)(6306002)(478600001)(966005)(52116002)(8676002)(6116002)(6496006)(6486002)(2906002)(6246003)(81166006)(72206003)(81156014)(8936002)(7736002)(53936002)(142933001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR0701MB3830;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR0701MB3830;23:9YC2VuzVlHnaSEVla5q0Lyn3Yes9f4DSUg+I6NB?= =?us-ascii?Q?xeHHHBR/skrrpY8v9JDzzstYrOjZT8NK1DYyDx9DrT18g0fP9Q0tBQ8CKVTD?= =?us-ascii?Q?lr213/PfYyq5hqTxSZ3W26B5sN2e4WM/3bAO33OXya/kcZ2l2hCH+MX0uPtr?= =?us-ascii?Q?oyhzJRm3SA+Uy68iqnrYMp0AJfVlOwSql4bAQnGvW4GOmULvOm5R4zGRAgcP?= =?us-ascii?Q?dhoi8eW6ZkjuK2KpvXjL2fx8o/HRz1BN7FLlgHAzrKvP5SSd1ZNDPxmstOF/?= =?us-ascii?Q?nt9+BYMf6BhvKcme2lvuTgJfB2wrMGhymaVmxRHBqocQWG5OdsBAQzYX+Hfu?= =?us-ascii?Q?asCLddwjX3GIRJGrARzzTftdRKD9I9fx9KuaMau9Ls31NwSa8YlAY9Jd5p8/?= =?us-ascii?Q?hbqCun2LViNRsOTbAXpfVyCy3nB/M34Pa2UJCh1t1Zw14aqNALU8uUt0uclq?= =?us-ascii?Q?O6Jjx1MHaMKTrXSrGA4pqrXKYcr7hhDQKaFH8wvuk7p2Lddlk36jR7kI0Tnj?= =?us-ascii?Q?4uDa4xcnDGnKSf/IhcajGfKO8sJ6WSiAFqcI8QId3K8VoIWPUKIt6ctvtxE2?= =?us-ascii?Q?W2vx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5PR0701MB3830;6:V6APrgRKv7C90mBvMhFRrrp8mTn+OKrpUybHxBpRq6DQAdt2LUROnGIYVJC12vMocUich4mxM5ooKv+gzB7q3/1laUnMVY8kJ6ZeW+el4Ldnz6leC5LuZlo58lRpRGA2Jf+LUR6A+1K+byDZiKRujl0AzjDEHOF9jB2g+faVHNH/yqSwUwXbyW7H01sP688THO20+mc9Glodufq1WauqqaoWYkSYsMdTYOCxmW+BsdMgspW5iUZiYO9cTJAtYoJNowTU4qLX16BsSaHOhCLt+Q/2tM8zlnImcjGaqEt2SvGrTusSvuzlySbPPd8H9Kisq0e1D5FpnAD/PNnUTX2n5mgq1YLDgYq3HMYYCQdfKWU=;5:ox2w16Ks2vPZeL7Y1tGD88WXZoQxfsi6Lu/8zaNoVphnB9dPkCpgzLDkXd+E3jFWkBmomH7N0dVuY8V/cJrn5WFUXDbJhhDtJIg+WquYIXB2CmzgeZZ54wywrzTT0Nt1MvGCt8Xeeyfz46SjMJQXhzvUXYsZDzB7GaR+oXGmT5E=;24:h6pjdXcwyjMz6vVDMnTWvUQ89+YNRJ9cxxTyQ/nOQnP83SdSa5q/qxwHCkH9jYo65c3unvZFgTk/rf2aOO9jpAJ7puLZCOU+nwFVu5FCNoU=;7:2nZ60+OJuZaIo502HXp3RJNlFs8IMPKD9ZzXCBSYwTR4FHnK39Pd9nL9eMxr0dNch5+2G4f0DmlAmxz7UB8p5xeW9Nn2ZVVTSYafEgu/Ix5myngxqJJXUpkWNb7/IJHoE0aE1pZI8PsMf+wBJsPB4LHM9CmufIEyIDuLw3LyHcIUPmP+khwcA36aHqhELTBRCT2SVZRnqaPrnjYJCWlJckn8wWYzO7tYhMy3e/AgLT36yMKW/Cnauy1T1DPYK4nY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 05:15:58.9984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f79e391-f51e-4f08-6ff7-08d55720126a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0701MB3830 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 12:29:23AM +0100, Rasmus Villemoes wrote: > On 28 December 2017 at 16:00, Yury Norov wrote: > > > > In this patch, bitmap_copy_safe and bitmap_{from,to}_arr32 are introduced. > > > > 'Safe' in bitmap_copy_safe() stands for clearing unused bits in bitmap > > beyond last bit till the end of last word. It is useful for hardening > > API when bitmap is assumed to be exposed to userspace. > > I agree completely with getting rid of the complexity of the u32array > functions, and also think they should simply be implemented as a > memcpy() when possible. > > I'm not a fan of the _safe suffix, though. It doesn't say what it's > safe from. For example, one possible interpretation is that it allows > src or dst to be NULL (becoming a noop in such a case). Why not say > what it does? _clear_tail, _clear_rest, something like that. OK, _clear_tail sounds good. I have to send v2 anyway because there's new driver coming that uses u32array, and I'll also do rename. https://www.spinics.net/lists/arm-kernel/msg627220.html > Or maybe, > can we simply make bitmap_copy behave that way? Hm, probably not, a > bit too many users to check they'd all be ok with that. Yep, and there's explicit comment in lib/bitmap.c: * The possible unused bits in the last, partially used word * of a bitmap are 'don't care'. The implementation makes * no particular effort to keep them zero. It ensures that * their value will not affect the results of any operation. * The bitmap operations that return Boolean (bitmap_empty, * for example) or scalar (bitmap_weight, for example) results * carefully filter out these unused bits from impacting their * results. Changing this may potentially affect performance, and anyway, too revolutionary to me. Yury