Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp103770imm; Thu, 16 Aug 2018 16:24:11 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyB40P9Fik3WPXM1VVi3tGszm6caAgo21TUIzTnlp01GsDHNK7g9QGZR51pfH95ZDJMpkPc X-Received: by 2002:a63:3089:: with SMTP id w131-v6mr6264199pgw.79.1534461851207; Thu, 16 Aug 2018 16:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534461851; cv=none; d=google.com; s=arc-20160816; b=C8fiT/GRK8HU9G3J3mNcvANEhX3S5Tjlmnmu98ryKgrsDy8S7gYkxFHEUoHa46m4e1 DWu624Hbre38SerloCUm/WHFvJaoFOrzLWyNbROY6IOocM4vTfjZUCkor/GGFN1i6Vz4 qFaz3AY8zsmx5uJySggu6aMOY6Fd78PDfeYhG1VcHQxaYZFZbT/741aosKQnvidv4vRF 6D8dqkTQHMCAvZlhtiSnDWD1DTpdq/+aJyHtFlrs2f+jdNFKe8Cbc869wvk5Z5RvUkKf btnE4uKnq7inm13uaBowLowPKB3xKRtntO4GyHIrz79hmBIvEHczfRxRr6a+Ig+qvaus ahhQ== 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=/MK+kXmDbbe5m5Y/6Bbu+NxXAw6Dcelfu0tJQwy8RS8=; b=MTRHIu28bmIrWVLLVJh/FBYK/uEkm5yZq99OB7nuLZW3DHXcFCgAHd6JF6zAnEpIHj GNMzshcu8y+kCIwkzlZPfWcKsYvn1QNpV2Umg0gPJWzxWSwrjue3Vg0bQedJdJQZMtIj Y5uSPlDETFy83/vVD55jS5xwABH2AEy6beuuoqhKo3pABxCpz6HUjK0MKUFFp99/sduX Yn16mFVR8Kq9TYAPkL5heU8nkuzdzLkDZ1luGbZc7J8MiUQOgsxpEYg8EZ5A+JbGO2pc vmTrpajdLtOAGwnlP7gwX1UY+fILdabP2EwMlMxabKCC6rg0FrtRrwGzZcvt1BK4rLv/ 2JJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b="ln/e3g5i"; 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 n14-v6si498947pgg.216.2018.08.16.16.23.43; Thu, 16 Aug 2018 16:24:11 -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="ln/e3g5i"; 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 S1726061AbeHQCWs (ORCPT + 99 others); Thu, 16 Aug 2018 22:22:48 -0400 Received: from mail-eopbgr690071.outbound.protection.outlook.com ([40.107.69.71]:59472 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725903AbeHQCWr (ORCPT ); Thu, 16 Aug 2018 22:22:47 -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=/MK+kXmDbbe5m5Y/6Bbu+NxXAw6Dcelfu0tJQwy8RS8=; b=ln/e3g5ikNjRxsxQWZHokrZdqczOWO8Ox4ZBKWIf7wEep6Jj45Dl46ZSgGfIlbLI/CDB9zfOWTjM72+NiH79N+PZ0OOFOkByuwKY1mTWajSIUTGtPC5YkkAimExjZ/Tkr0bmihMbak1Omr0eJZjR2h4P3NYE5W+lpJrvpkafw2M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (80.122.1.10) 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.1038.25; Thu, 16 Aug 2018 23:21:41 +0000 Date: Fri, 17 Aug 2018 02:21:25 +0300 From: Yury Norov To: Rasmus Villemoes Cc: linux-kernel@vger.kernel.org, lkp@lists.01.org, akpm@linux-foundation.org, Andy Shevchenko Subject: Re: [PATCH] linux/bitmap.h: (buildbot-only) check if we have any compile-time zero-size bitmaps Message-ID: <20180816232125.GA6119@yury-thinkpad> References: <20180815085539.27485-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180815085539.27485-1-linux@rasmusvillemoes.dk> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [80.122.1.10] X-ClientProxiedBy: HE1PR0301CA0011.eurprd03.prod.outlook.com (2603:10a6:3:76::21) To SN6PR07MB4384.namprd07.prod.outlook.com (2603:10b6:805:58::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6a24fde6-ba44-4aca-7e77-08d603cf064f X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:SN6PR07MB4384; X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4384;3:SyEYQpo2XFxma5uzSsWz0iQC3LWRbrbTga9PX9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Fmun82jBUUksMCnYPXl+7lIohpSztvx+BNhQhEPPTQ8yffJIkFZRAkY5099uqB9N8j7ya7RmJ7QZYNrsf5xaaCYWPGY9cLTC/xKOermI+Tv0E+Qfq1bs9lVolLtO0rODnOuLF7JxR59NBeLkdnRr+40GppthYD9COh+cq490GgGI9oUGFa7N0fnEb4JEkemkbmwX4HAlixPYUuNYHkhMcZwfcKuM+RUzD4pecVxCBDzeZVBRvQOxFv2oOHRrbzTkv/muq5F05QOpEzHVLbO7kPydo7UHqyyNl0wP4ELaynnStQKGQFHJ5ZaYhhA7siD+R5LphzWLkn9CPtcC5lhregGsMP7GeDXKZRC4OxLrzy+IUcfY2rH110eqtnA/0CKb7YXYP4NLxjKaOzDJRg9yN8cGPD74WpGoAfsVkicqtXliI=;4:PIpu7NayqN7XGtWJTy4z3EhLuMnGHAuxKSyGNDYCJUmQM6qcUcrdSsUrXRjmYo2tQ3m5C7KUzAPsNj2ErEHVMdBJhinx7Dmw5nh6qmiIZXEpH4iMxmoKvyJ7LYzlcZx1vsuRJE2qU2XkZehgf4bKWiUD8low/GITe5CrMrXT9wbxeo0tx+t2oIIO/f0RR9IFgxAaxdfPrLx8suLeIYOWDr/MkW30jNj583BflRSIEtQBDaJabzLcaQE6fCuBuDssTUR+JvsGuDHaQS1wq3FapA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3231311)(944501410)(52105095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699016);SRVR:SN6PR07MB4384;BCL:0;PCL:0;RULEID:;SRVR:SN6PR07MB4384; X-Forefront-PRVS: 07665BE9D1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(366004)(346002)(136003)(376002)(396003)(39860400002)(189003)(199004)(26005)(229853002)(7736002)(53936002)(76506005)(6916009)(1076002)(105586002)(305945005)(6666003)(106356001)(66066001)(47776003)(42882007)(33896004)(476003)(386003)(52116002)(76176011)(446003)(6496006)(8676002)(81156014)(486006)(16526019)(6486002)(16586007)(14444005)(81166006)(316002)(58126008)(9686003)(956004)(11346002)(186003)(6246003)(97736004)(33656002)(72206003)(478600001)(25786009)(68736007)(39060400002)(8936002)(3846002)(23726003)(50466002)(6116002)(2906002)(33716001)(5660300001)(4326008)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR07MB4384;H:localhost;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A: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:OC82kSHfboDmZQ5dEz0TVnmZHR8dPNOBIW78Fdfr6?= =?us-ascii?Q?OYdhRCiv1YFSYIZVCJH4fKRHjWLSfxNUYsPwZRMC3pAUBQR9TCwpEyD/TBeu?= =?us-ascii?Q?zO9s+80M2aFwMm4Lptb3Gg80QIpycXlLnkDQegER0LjEVi2HJYTbycVMtbXj?= =?us-ascii?Q?OaDHyyvH3V/szcwqpxkzO901dPd3PIuX6wFG6C+ijkwk0zW0vkZ4puHwMt1q?= =?us-ascii?Q?BnTyHr9rUif+RSa+IdVILg23hKIenWpEhPNDIC6/3v4MhQce2dShbNC62oSD?= =?us-ascii?Q?s7s7sriAUbnN7sW//4Q0PleMm8KpWVzwLYXZGunYYqFQdY+/HgGuiKsB4jG0?= =?us-ascii?Q?qYKY1ab9OD9AOVTFiCVD+z2zD61pkOt68o3bf3nOrK9HhpQ9wAe/8HFQIiIG?= =?us-ascii?Q?Pl9ru0v2p7LD0+YPBcc9Iupo5J6DE9RYQIipq2m9I+Rj/DEiwCTgyEAKdzvG?= =?us-ascii?Q?Xse52UICWBeo+spWdqxqq2eTPYRAzL+VyV9+12+U8/pVfjKk3vZwgEV56oWC?= =?us-ascii?Q?xxQ5uM8f8a3sU57EqA7r73nwFRxLbzWPlSUXuTU3cgQail8IhJur8g5YqUi2?= =?us-ascii?Q?byzMXxEqFaiQC7QQnmp/gCJpCFstuVWPQo034UUS4I0La7g9JmhysZIac1mr?= =?us-ascii?Q?qq1mqJxZtMPLOkMIWGs7YqPWUjw7T/ZDfL0lg/B9nV1OexwMTS6b7G2yxCQE?= =?us-ascii?Q?Bd8IX/SVnMav72pR2Ao6S4Wv8g6jUcYw477EX7nWryi8GExTZED2DN2jqfv8?= =?us-ascii?Q?mj94I5uaSeuIEPMtbvg2hMedcsvq6+DcyebsXrymfYZLHjFTiC2vgI7Citc+?= =?us-ascii?Q?O7fMZ9znEWBUNfjaDg1vIS2utPUVR6kmIZpO6FybPvS/eMFvUVUC+qhm1ooj?= =?us-ascii?Q?JAjt+KHWq4Xedm3b6nH9RW5NKuweCieozQk4HRvfCYKZXuAqrevo12zPriIL?= =?us-ascii?Q?Kx7SXtWhHRuc5bCYR7CU3g+lhn8Mq8QuYFxk2gauHMdnVNSz9ipD60l8iVDg?= =?us-ascii?Q?N0SPi4qTnrlPbYJ36Xblv5GbPIVBWw6fpYzJEA4X+3fGVLj14yskyqut2Urf?= =?us-ascii?Q?MlejCk1ok4POq1aRhXDxpxKLOKvtWVnW5gMhlfrIgWmbqkGKYedLxOzhbiwS?= =?us-ascii?Q?NVx2FPtPp4I/OVItPzCNPcPqbLolQPR4azYm3rfnwLRhCu4sUQsKfA7xAa+r?= =?us-ascii?Q?r4tSnMURaPIBxorXegNl2VRP8zV7670bPO727RFDeuuGpO+V8AnzeA1KGy8u?= =?us-ascii?Q?qggNiHj3d6iFZOI8OxJOYmWHatImdrFV18d5ibm194eqQ+rsLkFSLmVqeobL?= =?us-ascii?Q?WgAIf9qRBbK4COXkF09z23VoEhXu86OZKkSR0VOok9+ASYYWB68bPJMlCRUQ?= =?us-ascii?Q?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Lszywqu/I=;7:LNhzdnNIrTrodC2W3dwDaeEvzAgJKYuA4t/usDvR9QazMn52h0B2jIeGj1Nax8DAZDwtFReO53QZGG/FU+pwl6BSO7zsxc9MuHMc09PWBXJcnH9qdVQpe6AoEo2jzh6hhs1VF8hF7ISnoJ82ZDihQNLrPwwdPvjXufT+hOOl/O9GGCw1eVSS9sUIXTDKq1ViEKHnTG+hSjSSDX5i5IruBLERbPX2bMStGdfxcZQcMVylWrrzDXy4mJ7LuwhRlYGV SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2018 23:21:41.3646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a24fde6-ba44-4aca-7e77-08d603cf064f 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 Hi Rasmus, On Wed, Aug 15, 2018 at 10:55:39AM +0200, Rasmus Villemoes wrote: > Most of the inline bitmap functions are buggy if passed a compile-time > constant nbits==0. I think it's bad wording. Functions are OK. The problem is in users. Also, run-time nbits==0 is buggy as well. On the other hand, we have a rule in include/linux/bitmap.h: * Note that nbits should be always a compile time evaluable constant. * Otherwise many inlines will generate horrible code. So runtime-defined nbits is bad thing by itself. > The convention is that the caller only guarantees > BITS_TO_LONGS(nbits) words can be accessed, which for nbits==0 is of > course 0. However, all the small_const_nbits() cases proceed to > dereferencing the passed src or dst pointers unconditionally. > > Of course, nobody passes a literal 0 as nbits, but it could come about > from some odd CONFIG_ combination, or because the compiler is smart > enough to reduce some expression to 0, or... In any case, this patch is > just for the build-bots to chew on for various .config and arches to see > if we have any. > > Since most (if not all, I'll check) of the out-of-line implementations > handle nbits==0 correctly, I'll probably just unconditionally add the > nbits>0 clause to small_const_nbits() to force the ool versions to be > used if any compile-time zero-size bitmap should turn up. > > Not-really-signed-off-by: Rasmus Villemoes > --- > include/linux/bitmap.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index 1ee46f492267..a5879cb45687 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -196,8 +196,10 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf, > #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) > #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) > > +int const_zero_size_bitmaps_are_buggy(void); It introduces undefined symbol and uses it in pretty unusual way. I think it worth to add comment about it. > #define small_const_nbits(nbits) \ > - (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) > + (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && \ > + ((nbits) > 0 || const_zero_size_bitmaps_are_buggy())) Some functions in bitmap API has signed type for nbits. (This is wrong by itself. I think I'll write patch for it.) So in fact you check here that nbits is not negative as well. Would it be better name like const_nonpositive_size_bitmaps_are_buggy? Yury > > static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) > { > -- > 2.16.4