From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68C9CC43334 for ; Mon, 18 Jul 2022 21:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236206AbiGRVBx (ORCPT ); Mon, 18 Jul 2022 17:01:53 -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 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