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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF4AAC433EF for ; Mon, 18 Jul 2022 21:01:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13B2A6B0073; Mon, 18 Jul 2022 17:01:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EAC68E0002; Mon, 18 Jul 2022 17:01:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF3D96B0075; Mon, 18 Jul 2022 17:01:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E13F56B0073 for ; Mon, 18 Jul 2022 17:01:49 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B08EA34AC4 for ; Mon, 18 Jul 2022 21:01:49 +0000 (UTC) X-FDA: 79701442338.10.E480A16 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf01.hostedemail.com (Postfix) with ESMTP id BBAAC4006C for ; Mon, 18 Jul 2022 21:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658178108; x=1689714108; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=UQvO2SGkmfD9hjqb37rGZKMgLdkMhJ/GnFkJAWX9FrE=; b=LS9SAYBTFIW3vGQHHlzr5j9TFpgzGXRmO5U289ua788rx1WazhuR1BfX vSRgzLBLXKrY2T5B8pxqEnxVCQz4vkBJvMt1LSY5uRucKsibB0x1fFASS aYr9L7pyTe7QNzlM2d+bsS2CT2pZlVTLklIWG1WsWbMXxd15xmZq4QeNi MPNzomSKkFak5+82bJJvakxxSRt/EKuu7WbB9JziU5YhYDH3TETx6kCh5 +YPOefnZmEvidWUVflKqMCi4vHkA4JwkA2qLbbWjD5wp630E0z/Nf7qeC LxflvFATg2qxd/MUlseAzBQ+ry8Lu36ezxuB+oNi24w0I3EJhnZScSF7/ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10412"; a="287061813" X-IronPort-AV: E=Sophos;i="5.92,282,1650956400"; d="scan'208";a="287061813" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658178109; a=rsa-sha256; cv=none; b=Im73e9TZuWOfux3aqNqXBv2DPArKsEI+t3s/oJV8QjNhBu1uwOPbIy0/Xd/HF7DouNLuce DFToC0ravf3k/LukUirLvfc805rFqMDrdOhAkPRkhK8BDhiVd1ApQ9JUWfHDO9LaH8goLJ Wj5i1l7wZ216ZXAzJriF6MTadAygJZg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=LS9SAYBT; spf=none (imf01.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658178109; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S3vKNO6VQlH4RzvfxIyDjJdoGGyovTmxOq9tQmqP2ys=; b=Kd2Dzn7jHdrzR7ne3AslGm9WMF2FsjbDpP4l0UKbuKxCBNvs/GaISVGHI+m3U79Qvo9mud RATIDVUXe8x7mlTNSXql62xxXruReSFUtMx0WF168ukXMdGxCyuQ1rSCJ6q5bjI+SaNSHH 6oqiI9eVn+6BjVB901Bg0D8BPFN9SEY= X-Stat-Signature: f7xsfccw86osm9etwkuu88e1sfjfp8hw X-Rspamd-Queue-Id: BBAAC4006C Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=LS9SAYBT; spf=none (imf01.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1658178108-102051 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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