From patchwork Mon Jul 18 19:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12921668 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 A5567CCA479 for ; Mon, 18 Jul 2022 19:29:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AD5E94000C; Mon, 18 Jul 2022 15:28:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D86294000D; Mon, 18 Jul 2022 15:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF82594000C; Mon, 18 Jul 2022 15:28:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D4979940007 for ; Mon, 18 Jul 2022 15:28:58 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B0A5020C76 for ; Mon, 18 Jul 2022 19:28:58 +0000 (UTC) X-FDA: 79701208356.09.5924C05 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf14.hostedemail.com (Postfix) with ESMTP id 5DD4A100081 for ; Mon, 18 Jul 2022 19:28:58 +0000 (UTC) Received: by mail-qt1-f170.google.com with SMTP id bz13so3158136qtb.7 for ; Mon, 18 Jul 2022 12:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=OWEXlSbAfAwywlnXDil6CYNW0FSVu9hGAT+NA18MHDQ=; b=EdkRpor4TlGyKnTLZL6ybUgdj9y+RP1U2qMx+qo2WRbae6kczgkFok4CRrhKnmECjE BkNDZq/325XPSSByV3oQf/TzCJs5c0+pyMopjHMn+DloZPH4YCia6agETBzkZ9O2R63r Sfzc43oRP8KkOnmqDB65zJIgv4o3qXdvG+V6aFbNWCQKf1EsDN37x+1WeR3Nt4oMt769 2KPNHOqvnz2G/wmJSU5SWhdVktHz7N8FZU6k1/q5lT1ljCiNPCjqMSlIUzNrNatzQ0XQ lFN5p4uVklAw74PmFXTeVo1V90esQebTmWviZEGmWjkKyWhJEsnO56dg/6lR7uMiRsY9 6e6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=OWEXlSbAfAwywlnXDil6CYNW0FSVu9hGAT+NA18MHDQ=; b=vsb+87NFESuhip8+l6Vhh/dmTlDTVDNUq7uLvSM66dWwQhqJwyLJRYybl9sEHM5RU2 w1GYQMv9adZea3ZCSR/c3R6+qpD+McjP6jAwo/WVi+8UNe4xVJYNV/XCGDYcyqfJj8Lm o8FJtxAoRx4P6AcnsO1TnRFvO6HKSW+pZ54my4l3uD4YYfx8Y+Km+WHnuZBDxw9Qvbap jXGkF6q0gXcGOn6+SUePHIF7OKYlctPmdmiWaI6Oc7NGHvt+6x9frKnkULP+y+j0esNm byQxrKfhlsAWo7IJguzdHtAWPlzl1gm8OFyo9BgxRA4vKocmQSxE3xxxTr3bBhScUeun aR7A== X-Gm-Message-State: AJIora+VS+BVR5/ASvvAVOgswOFeEQndirYHWZ4Hq+0PQ3V98Jgcm+kn V051mIq9dqWeBdhxau7zoNXbdY2SuUP7Uw== X-Google-Smtp-Source: AGRyM1vqDidU2mj3mjL1nyFt/o9b/6DrRe9boOZKOh5cfsbupafmIWKyPwSd3R9NQ0P+as9cY9uNww== X-Received: by 2002:a05:622a:58d:b0:317:ca0d:91a5 with SMTP id c13-20020a05622a058d00b00317ca0d91a5mr21815757qtb.601.1658172526705; Mon, 18 Jul 2022 12:28:46 -0700 (PDT) Received: from localhost ([2601:4c1:c100:1230:ab01:d009:465a:5ab1]) by smtp.gmail.com with ESMTPSA id q9-20020ac84509000000b0031eb3af3ffesm9650206qtn.52.2022.07.18.12.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 12:28:46 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, Alexander Lobakin , Alexei Starovoitov , Alexey Klimov , Andrew Morton , Andrii Nakryiko , Andy Shevchenko , 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 , Yury Norov , linux-mm@kvack.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 00/16] Introduce DEBUG_BITMAP config option and bitmap_check_params() Date: Mon, 18 Jul 2022 12:28:28 -0700 Message-Id: <20220718192844.1805158-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EdkRpor4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=yury.norov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658172538; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=OWEXlSbAfAwywlnXDil6CYNW0FSVu9hGAT+NA18MHDQ=; b=f6o+J/RXLsSPaaUOqZ0uz4fzNy6h3OcjJ0spg3n0GDmP30RNvaUGX+XPSyZvkqHCdFvt37 odnkendlEeXuJMFIL4gwCKfIxHt1jF0WBctZgzAwd9eJWFR///OTCT+3VvV/nZjJwFc7bL WCjJgMWJD6Bt3EKX4ylzRJFVar1wIBw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658172538; a=rsa-sha256; cv=none; b=x76H2hu+DIcq/K6vE3K5TkYeqSsbsGt1QXKM5xS1kPuAq1iw7cJL5Y3Vxo3RpM7AT9RUMr KhYd69oyYHjibLd/bFWcnlP6UZHexwodZyL9jCVgOOZFVyuXR7mWIbqZ83R4n1k7jpiBnD CE0mW0JvtsJW4QaEfJgmEw39Mxj7jhU= X-Rspamd-Queue-Id: 5DD4A100081 X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EdkRpor4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=yury.norov@gmail.com X-Rspamd-Server: rspam11 X-Stat-Signature: ruw4otukm9q8nhteqce5ramqttiyja5f X-HE-Tag: 1658172538-899428 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: Bitmap functions are often a part of hot paths, and we can't put argument sanity checks inside them. Sometimes wrong parameters combination cause bug reports that are pretty hard to investigate: https://lore.kernel.org/linux-mm/YsbpTNmDaam8pl+f@xsang-OptiPlex-9020/ And sometimes we can optimize caller code. For example, to avoid copying of bitmap if source and destination are the same. It's quite tricky to detect such places unless we've covered all bitmap API calls with the parameters checker. This series: - introduces bitmap_check_params() with a couple of common-used wrappers; - clears all bitmap warnings found for x86_64, arm64 and powerpc64 in boot test. Yury Norov (16): lib/bitmap: add bitmap_check_params() lib/bitmap: don't call bitmap_set() with len == 0 lib/test_bitmap: don't test bitmap_set if nbits == 0 lib/test_bitmap: test test_bitmap_arr{32,64} starting from nbits == 1 lib/test_bitmap: disable compile-time test if DEBUG_BITMAP() is enabled lib/test_bitmap: delete meaningless test for bitmap_cut smp: optimize smp_call_function_many_cond() smp: optimize smp_call_function_many_cond() for more irq: don't copy cpu affinity mask if source is equal to destination sched: optimize __set_cpus_allowed_ptr_locked() time: optimize tick_check_preferred() time: optimize tick_check_percpu() time: optimize tick_setup_device() mm/percpu: optimize pcpu_alloc_area() sched/topology: optimize topology_span_sane() lib: create CONFIG_DEBUG_BITMAP parameter include/linux/bitmap.h | 95 +++++++++++++++++++++++++++ kernel/irq/manage.c | 3 +- kernel/sched/core.c | 3 +- kernel/sched/topology.c | 10 ++- kernel/smp.c | 35 ++++++++-- kernel/time/tick-common.c | 18 ++++-- lib/Kconfig.debug | 7 ++ lib/bitmap.c | 132 ++++++++++++++++++++++++++++++++++---- lib/test_bitmap.c | 12 ++-- mm/percpu.c | 3 +- 10 files changed, 281 insertions(+), 37 deletions(-)