Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3766714imw; Mon, 18 Jul 2022 14:12:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sh7Xbam9PfFXa4grueH2jS9X6N9ZWHSFm+WCyOfGaz25fnQE8macL7ek5c1nh0bCG84DoE X-Received: by 2002:a17:90a:a796:b0:1ef:85de:6d9c with SMTP id f22-20020a17090aa79600b001ef85de6d9cmr39786536pjq.201.1658178761582; Mon, 18 Jul 2022 14:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658178761; cv=none; d=google.com; s=arc-20160816; b=jQIkQFF0jHLL6vaMWiWxY616hq0Yq0uqd5qA0JVVMKyyUtUHoPylmTKWjsEAPnKAF/ DskNBuVlyTcyNYDHIqDWOkb7hR38DEm5m63tbPVmsyU2tbxGp9J1gh1jlS2JHP9LeQCN Js1ZI1g+AAk6owz4OZsKDRV+nypaNe5Gf36b7EOfQyrEecdjz62GSiLxnJMPOSn25O7q 0TCnORy0KiVZX+0MvTaw5IhLiw/1clGT12Kn/GPIsjES9+eHo7YwSPQ2IHaTUP6oBrZx iypUp+xQ2ZLTszH7t4dC4oZqS6tD39ApRssJYVgiN8n0WZywGleil/HT/RVzYzE9vU2n vUog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=S3vKNO6VQlH4RzvfxIyDjJdoGGyovTmxOq9tQmqP2ys=; b=n288dyZcqWjEl/mhGHB1C+c5+PM3ZcKeans8QygU1e9dNqXRWuRGn6lsoGcSAi3K4R m7lwd2TjRfU7moN/LDKc05LTC3Zg1J9kzDikw2dgk2bGW28yJp3AkZ3elwZvShC63wEV 5A3Xj/M2WXljPUzSpvf7WyGvHY6T6ypS9dZ/vU85+TRvZ3wjKsbtJbUPVm7dlpGIG7FL XyNYBJ4Hn5O2d39c2HEvTf4oR++kySXsYVrUL35RqDipNQH/hAev2fWKRLnrEAjqhZkw GfcEfLwaL3f5BNT6oAPqSnMvgdHtDbgflWKRSAW8IwtVZ5qk8Eh85WORp+S1Kd+rIoCp j00w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fjwH4FRQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb9-20020a17090b35c900b001ef6ea57d7esi19688445pjb.55.2022.07.18.14.12.25; Mon, 18 Jul 2022 14:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fjwH4FRQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236207AbiGRVBw (ORCPT + 99 others); Mon, 18 Jul 2022 17:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236123AbiGRVBs (ORCPT ); Mon, 18 Jul 2022 17:01:48 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812313244B; Mon, 18 Jul 2022 14:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658178107; x=1689714107; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=UQvO2SGkmfD9hjqb37rGZKMgLdkMhJ/GnFkJAWX9FrE=; b=fjwH4FRQzpNGmNOpln1zXlFEZzIQY/JgGT9JJEhakn1KHStDPDVgtwid RGoUUpCfoYYunRylVctZff5K1o3Dec3dEpYEFid3p7Llw91IU5sTQz/ur wFjI9h6FK9wFLa6NN4i+KvfWdqplClt7ZUPU5lCUIGqMlRDIPOvK1vESi OD/pd5yW8XvQpN80OCjmfX0qlJEE9ZLavU8CyhyEZFK9jtSFtIPttmnTq 3yETCFKEis/sj4MrgcJ8BBjph2Fz2LHkMZ9Q26SeNAhmeTfLpMRJ8sUhD UDU1L0nS2u4al7MsCTt/QTcjh4fKnB2xQ2JTJGxuqsBOJaWREYlT9C8/S Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10412"; a="283885982" X-IronPort-AV: E=Sophos;i="5.92,282,1650956400"; d="scan'208";a="283885982" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 14:01:46 -0700 X-IronPort-AV: E=Sophos;i="5.92,282,1650956400"; d="scan'208";a="655450280" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 14:01:37 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oDXrw-001OYG-1f; Tue, 19 Jul 2022 00:01:32 +0300 Date: Tue, 19 Jul 2022 00:01:32 +0300 From: Andy Shevchenko To: Yury Norov Cc: linux-kernel@vger.kernel.org, Alexander Lobakin , Alexei Starovoitov , Alexey Klimov , Andrew Morton , Andrii Nakryiko , Ben Segall , Christoph Lameter , Dan Williams , Daniel Borkmann , Daniel Bristot de Oliveira , Dennis Zhou , Dietmar Eggemann , Eric Dumazet , Frederic Weisbecker , Guenter Roeck , Ingo Molnar , Isabella Basso , John Fastabend , Josh Poimboeuf , Juergen Gross , Juri Lelli , KP Singh , Kees Cook , Martin KaFai Lau , Mel Gorman , Miroslav Benes , Nathan Chancellor , "Paul E . McKenney" , Peter Zijlstra , Randy Dunlap , Rasmus Villemoes , Sebastian Andrzej Siewior , Song Liu , Steven Rostedt , Tejun Heo , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Vlastimil Babka , Yonghong Song , linux-mm@kvack.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 01/16] lib/bitmap: add bitmap_check_params() Message-ID: References: <20220718192844.1805158-1-yury.norov@gmail.com> <20220718192844.1805158-2-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220718192844.1805158-2-yury.norov@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2022 at 12:28:29PM -0700, Yury Norov wrote: > bitmap_check_params() takes all arguments passed into bitmap functions > and runs sanity checks. bitmap_check(), bitmap_check_op() and > bitmap_check_move() are convenient wrappers for frequent cases. > > The following patches of this series clear all warnings found with > bitmap_check_params() for x86_64, arm64 and powerpc64. > > The last patch introduces CONFIG_DEBUG_BITMAP option to let user enable > bitmap_check_params(). > > No functional changes for existing kernel users, and for the following > functions inline parameters checks removed: > - bitmap_pos_to_ord; > - bitmap_remap; > - bitmap_onto; > - bitmap_fold. ... > +#define bitmap_check_params(b1, b2, b3, nbits, start, off, flags) \ > + do { \ > + if (__bitmap_check_params((b1), (b2), (b3), (nbits), \ > + (start), (off), (flags))) { \ > + pr_warn("Bitmap: parameters check failed"); \ > + pr_warn("%s [%d]: %s\n", __FILE__, __LINE__, __func__); \ > + } \ > + } while (0) Why printk() and not trace points? Also, try to avoid WARN() / etc in the generic code, it may be easily converted to the BUG() (by kernel command line option, no recompilation needed), and hence make all WARN() effectively reboot machine. Can you guarantee that in all cases the functionality is critical to continue only with correct parameters? -- With Best Regards, Andy Shevchenko