Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp237380imm; Thu, 26 Jul 2018 02:38:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfYPeukgnZwwTA8SpgO2iF+Kg9t53G0od391AsBrdvIrT5qdqQqWoBuQMi8GUs9QoqqajhB X-Received: by 2002:a63:161a:: with SMTP id w26-v6mr1238408pgl.257.1532597928215; Thu, 26 Jul 2018 02:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532597928; cv=none; d=google.com; s=arc-20160816; b=lKIXDMRqah4yTO35H5LvGoxXpJ8n9ytZtZaIQJQ08EzdX+AYaYxmb74TlpHkvJ0bY0 5M95GFNqWL9jUnucVSy5DjPvv3ZRRlzuWHNj1u5fe/lPi6TaJc0haBJr/5TcpP8ssO82 5t48ARIT/J2LuDrJIXVZylkwdOfIBVAmORX66UY/BDh+68JVuLUq1MV1K49+mKGLcsnj E9/G1t1TnpuZw7SFSZ2+OXlUUnuBjiKcfHoxYJATqTk4GhZpqCnbgD6zJuM9SPFVimjn EGOp5YaEU+yQqxV5od2uDiJGCZZsfRBB04iTmbFcZyVhsoMn9dhXmpCUtuc7PTbFPVZP 5qJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=ZdW0CyMkLYobrM5ooAmgtCBtfqAnL4dGRSntUnVVBYk=; b=HF8ykb4uUxDB5RoNRafdzBWoo4FjP4DBsf4pSOcTjF0v/2Fff1pOkUAaKN9a/ln2pS B90qR2emNVOLvcmrj1a7aB/+Wj0AJPKD+AvuqkIB8b7kF01B5usN/Q0BttY/J8DgHCAY 0v6nV5N3w1LA8+LmzrYTHlueu8SPvzhowpxwYG0yjcuRrGdSnLuqkdwiAcNbxpQ0fEjj hHK3V9qzCTjQlbwnTVkm1yfjEO962BBoqR3Fqq9jHMwhQo13wIdXw/crKN9XODcm3fgE GNCR35M1SjzWvkN71+gcfRPyeAcyiJTVCFQwzEQZqcifOxYyAgYHPScUX+CE2n5PkpHK wqeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=GJOajr5P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1-v6si956618pgx.60.2018.07.26.02.38.33; Thu, 26 Jul 2018 02:38:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=GJOajr5P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbeGZKxo (ORCPT + 99 others); Thu, 26 Jul 2018 06:53:44 -0400 Received: from mail-eopbgr710047.outbound.protection.outlook.com ([40.107.71.47]:12448 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729031AbeGZKxn (ORCPT ); Thu, 26 Jul 2018 06:53:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZdW0CyMkLYobrM5ooAmgtCBtfqAnL4dGRSntUnVVBYk=; b=GJOajr5PZyidtproZcx0v8gP9OVketWEqUgjUU0XmDCW3xuxGiQX3hjegvawGY2Rw3eEH3gowLxOWSOvMz9WhIJHyv1pK6gERRBE16/4FlpBOu7nHOcE01L1C5yE7DGYqDrnvk1PYwUpKP/IVcGmSrlSt/TtwDtPBOV5ez+0m7g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (5.2.211.124) by SN6PR07MB4384.namprd07.prod.outlook.com (2603:10b6:805:58::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Thu, 26 Jul 2018 09:37:39 +0000 Date: Thu, 26 Jul 2018 12:37:28 +0300 From: Yury Norov To: Wei Wang Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, corbet@lwn.net, linux@rasmusvillemoes.dk, dgilbert@redhat.com, mawilcox@microsoft.com Subject: Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK Message-ID: <20180726093728.GA9069@yury-thinkpad> References: <1532592471-21177-1-git-send-email-wei.w.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1532592471-21177-1-git-send-email-wei.w.wang@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [5.2.211.124] X-ClientProxiedBy: HE1PR06CA0162.eurprd06.prod.outlook.com (2603:10a6:7:16::49) To SN6PR07MB4384.namprd07.prod.outlook.com (2603:10b6:805:58::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb59c5a8-020d-4f76-4cd9-08d5f2db6dfa X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(2017052603328)(7153060)(7193020);SRVR:SN6PR07MB4384; X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4384;3:0gq8QbZyjqdQRggT+plenFGwT7P5wOYHOVRSDe0qIbcfjbCMq3mvf4/MsUEAma02SVtjQv/4jdqH4TPQJzoc0YV6OIyLAMBVTlha/nop21rAw3Lu4N/AROKykQVSiC9AQ89uG/A9zw41qzajP9HeOYJuZ83HrFlX3OBh0nD0FQbnDYBQ8n+3gjO12pvxJwGy6LwvQF5Q+l3L2Grl9KAT+AJkR3PU3pGRmSgCbEm6iOjDqqkxOyQvOdzDzxVmPyCq;25:M//q8VopERHq1sUll8RfEnVAwKR52zY10HvbMVAQP4wEfJ/YeY81080ndUTZIgBsJGCwSmrnBFlJifYBL6inTRYdrUNX+O0exEr8qHX093Zot26zkVnV+jRIMYQRTzPeVMN6bvWAIm0zyQFJCfKFebobfgMqhK81fscpufUrf9/A95Xv6TA86xHPLZWMb8JtlDKC4alkGWuDC4x4j00IW+Run+GdCZSQxwffm+cxHy39bvZzUL1WjGRgw+RdzW2i/oqsaghGy8JALsy9XlJXg+VePHlG4Hgbfuea6EjGAieqI3kHjFekKy1zFkG6xUkFr7rwOmypHqd8Y1j3/Df8rA==;31:fRg9QO5ZAGSf4VNos90DYzyVP70/5BDGXeh2F8x4opTscZ7Fin3Wzxj161Evw94QtW02CKDRnsiNZkKid87m1lTKmvVM9dIPlHfNBgvPyz6n5Y5Am4d47SWO7FaSZMfQvsJMoavagxcuWfJzE9JheIs8p0m7YZQXnQQrJvUTjU1XkA2tn1bK/Fgjk/eWY+VZgNI1JawLQqLLexn4YzVv763Vz03oopYLWPtaininzwk= X-MS-TrafficTypeDiagnostic: SN6PR07MB4384: X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4384;20:7/uCTBOhJN1fLn69YJnHD0EAoLNskWlEbMRSPXtd09NpwExaue8+1RVec9FmtxYC9KGA6Y5uxHHAwrHiheNQQCUz6IhIl9geK7g5uHXplnaCV25Onj4LJnL5gJ0DMecqg93vqojMLfI2P+cExX/WuDpNeKWCJZ91RtFpzF3whdoYWa0lYR5VPtv/nShaHbmyYpZcPNc1xUaKOxfgX7xByK34YtrJMIIFK3VMOD3rRGiu/cT7gRBfoDyM7woghK2IVC3i4UwDHutvTA1AcWPcDe6R61gpVJIa58rMPx+35Svfwb/D1EjlScZnZg4xWTo4GlNvY4IaEycWu+Bt88kPCih3djQQyXvfz8RVvif1bUuPGABm5/3CD0FJXl0SA6yxxqkBNIZPGZ8dMXCZgVNz8ckdMAaNcGqFABfU0o0mp1SCPvq1JgJh0LtPZThhP/sQYCUS050LLwTi8H4CENshdFFInkbijlqtz2l8LBLkRUr0WNxKteUTsX2bq4/XJSuDk2lLUo978FJ+Yn/GAVweztUIw7O0FC/bKgHNFXH/QpKHJ2NB6oo8yXotQ74j5uelAYtJeQA7aIKJKu2RShxeQZE7Kdd/iYwP5GXY1whRMmE=;4:6jgR6YuYD/E/9/AvstXIYiiYQu8H+mkOFPznKOFSESfc5lJXsz6vY3poa1au2sZR8yeoU9WA0xTIJNy+8TfNiIv7XwOgj+mauzN6ZCOUNkqYPU6t0WU+3BgxZcUXkdITJdMgNzYJA0hlxDG6yZsGN/EmCXaSBh8d/1yGLvfEvl396Y2gBYrQZWZ2TGWD2RtEfj237yUZAself77I1k/HqawRM9fqHVrEhhR9Rlbk7WELq+ctX1qUqMMNwb8HheJmadQq14tUU45g3s3LmIvjnK3E7Kn0+zCucYpvdho34qQDrfc2+fMhiOVw/EsvwjQK X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(93006095)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:SN6PR07MB4384;BCL:0;PCL:0;RULEID:;SRVR:SN6PR07MB4384; X-Forefront-PRVS: 07459438AA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(396003)(39850400004)(136003)(346002)(376002)(366004)(199004)(189003)(16586007)(33896004)(58126008)(6246003)(8676002)(50466002)(52116002)(81156014)(186003)(11346002)(76176011)(2906002)(68736007)(42882007)(316002)(4326008)(105586002)(66066001)(6496006)(6916009)(26005)(53936002)(106356001)(6486002)(486006)(8936002)(16526019)(81166006)(14444005)(386003)(446003)(9686003)(7736002)(229853002)(33656002)(23726003)(97736004)(76506005)(47776003)(72206003)(6116002)(1076002)(71446004)(33716001)(478600001)(25786009)(305945005)(956004)(476003)(5660300001)(3846002)(6666003)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR07MB4384;H:localhost;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN6PR07MB4384;23:Fjg0sbMuC4hhoSKMMlumq6pj53M8lDGcHcMlsASOH?= =?us-ascii?Q?k+FdIoPlendG4JzKZ+oNZWbC7FJaJaIvEg0xi1nvrNs4/F08yrvZn1VKwxi5?= =?us-ascii?Q?e1k4XueDfA5u2Sa+Ngfz+V+800fV0e/US0Av3AxJeJiSTK03lI7MfrE7mvZS?= =?us-ascii?Q?szfSQcHl1vQTA4KajSTHf0dOp0GTMMOMn7DO6IE7eTgJpTnmOPrMuQ/X+d5M?= =?us-ascii?Q?to2khIbGHtBnwiDGpFahRu455lHF8rx+z5sXbWf1vv7eQSeugLfcdEGLO7mB?= =?us-ascii?Q?if8HJ0z5QDUNbFHDkYJmwyTTIrV49ugVIrKOG/elnntk+teDvw5IYhmnm+5I?= =?us-ascii?Q?xmpicPSgZjDXVOdMLr9UtjmqCdEoeqGR1i99Q0HTDjaGd9NMP2cK9x4lsCnt?= =?us-ascii?Q?BVIB5vcRraFxOHi91ivFSjDeFw8DYFsdBOEHM6LQxP4luxUMWRnhu33qq5Ed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wDu8bLwC6BeoZczyJjaSMjo24LiD5ACDHAVDOdoRk+80xW/q/QE6jQXfg=;7:t79ioCNI1GHiILpyrni7s30O9K/FPabjUGx8uiVS6F1JBpBEygumZikPFNdbgXVaXHXPgk8APoswt9nLTTRl4Pry3GIgzB5If5odRzniDDibyeF5P/BU8fDJG7ee4ZMXxdkcMVatnhDslrEROfUC83sR1urvKuX7UueDPnnnngAmxwKBVcVw/qkB5hO7hE+IMPTmI219RahzXOBvO2sTnEmVxUIeuVH0jcALDfoxlKq7difAS3pzSHuyoQQXPgie SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2018 09:37:39.4360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb59c5a8-020d-4f76-4cd9-08d5f2db6dfa X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4384 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: > The existing BITMAP_LAST_WORD_MASK macro returns 0xffffffff if nbits is > 0. This patch changes the macro to return 0 when there is no bit needs to > be masked. I think this is intentional behavour. Previous version did return ~0UL explicitly in this case. See patch 89c1e79eb3023 (linux/bitmap.h: improve BITMAP_{LAST,FIRST}_WORD_MASK) from Rasmus. Introducing conditional branch would affect performance. All existing code checks nbits for 0 before handling last word where needed explicitly. So I think we'd better change nothing here. Yury > Signed-off-by: Wei Wang > Cc: Andrew Morton > Cc: Rasmus Villemoes > Cc: Yury Norov > --- > include/linux/bitmap.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index 1ee46f4..12af3d7 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -194,7 +194,10 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf, > const unsigned long *maskp, int nmaskbits); > > #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) > -#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) > +#define BITMAP_LAST_WORD_MASK(nbits) \ > +( \ > + nbits ? (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) : 0 \ > +) > > #define small_const_nbits(nbits) \ > (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) > -- > 2.7.4